diff --git a/Example/ZcashLightClientSample/Podfile.lock b/Example/ZcashLightClientSample/Podfile.lock index 9c9f9696..d8840fad 100644 --- a/Example/ZcashLightClientSample/Podfile.lock +++ b/Example/ZcashLightClientSample/Podfile.lock @@ -66,10 +66,10 @@ PODS: - SwiftNIOFoundationCompat (< 3, >= 2.22.0) - SwiftNIOTLS (< 3, >= 2.22.0) - SwiftProtobuf (1.12.0) - - ZcashLightClientKit (0.9.1): + - ZcashLightClientKit (0.9.2): - gRPC-Swift (= 1.0.0-alpha.19) - SQLite.swift (~> 0.12.2) - - ZcashLightClientKit/Tests (0.9.1): + - ZcashLightClientKit/Tests (0.9.2): - gRPC-Swift (= 1.0.0-alpha.19) - SQLite.swift (~> 0.12.2) @@ -145,7 +145,7 @@ SPEC CHECKSUMS: SwiftNIOTLS: 46bb3a0ff37d6b52ae6baf5207ec3cd411da327c SwiftNIOTransportServices: 801923921fbecdcde1e1c1ff38e812167d01ead1 SwiftProtobuf: 4ef85479c18ca85b5482b343df9c319c62bda699 - ZcashLightClientKit: d5a681033b3f59c59c93837232ed7890d3e07918 + ZcashLightClientKit: 56d5c41ecf19d290a2aa25437775f11285edb4fe PODFILE CHECKSUM: 7d5095283dc02470f40ab06564d94076ba16d570 diff --git a/ZcashLightClientKit.podspec b/ZcashLightClientKit.podspec index 20318329..1f703e0b 100644 --- a/ZcashLightClientKit.podspec +++ b/ZcashLightClientKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'ZcashLightClientKit' - s.version = '0.9.1' + s.version = '0.9.2' s.summary = 'Zcash Light Client wallet SDK for iOS' s.description = <<-DESC diff --git a/ZcashLightClientKit/Entity/TransactionEntity.swift b/ZcashLightClientKit/Entity/TransactionEntity.swift index 402db09d..c3bdbd70 100644 --- a/ZcashLightClientKit/Entity/TransactionEntity.swift +++ b/ZcashLightClientKit/Entity/TransactionEntity.swift @@ -137,4 +137,3 @@ public extension ConfirmedTransactionEntity { } } - diff --git a/ZcashLightClientKit/Extensions/ZcashRust+Utils.swift b/ZcashLightClientKit/Extensions/ZcashRust+Utils.swift index 25d70bd6..771eef7f 100644 --- a/ZcashLightClientKit/Extensions/ZcashRust+Utils.swift +++ b/ZcashLightClientKit/Extensions/ZcashRust+Utils.swift @@ -12,15 +12,7 @@ import Foundation */ public extension Data { func asZcashTransactionMemo() -> String? { - - self.withUnsafeBytes { (rawPointer) -> String? in - let unsafeBufferPointer = rawPointer.bindMemory(to: CChar.self) - if let unsafePointer = unsafeBufferPointer.baseAddress, let utf8Memo = String(validatingUTF8: unsafePointer) { - return utf8Memo.isEmpty ? nil : utf8Memo - } else { - return nil - } - } + String(data: self, encoding: .utf8) } } diff --git a/ZcashLightClientKit/Rust/ZcashRustBackend.swift b/ZcashLightClientKit/Rust/ZcashRustBackend.swift index b2054fd2..14f7dd3f 100644 --- a/ZcashLightClientKit/Rust/ZcashRustBackend.swift +++ b/ZcashLightClientKit/Rust/ZcashRustBackend.swift @@ -200,11 +200,11 @@ class ZcashRustBackend: ZcashRustBackendWelding { return zcashlc_create_to_address(dbData.0, dbData.1, account, - extsk, + [CChar](extsk.utf8CString), consensusBranchId, - to, + [CChar](to.utf8CString), value, - memoBytes, + [CChar](memoBytes.utf8CString), spendParamsPath, UInt(spendParamsPath.lengthOfBytes(using: .utf8)), outputParamsPath, diff --git a/ZcashLightClientKit/Service/LightWalletGRPCService.swift b/ZcashLightClientKit/Service/LightWalletGRPCService.swift index dabdcf8a..b65ed3b1 100644 --- a/ZcashLightClientKit/Service/LightWalletGRPCService.swift +++ b/ZcashLightClientKit/Service/LightWalletGRPCService.swift @@ -76,8 +76,7 @@ public class LightWalletGRPCService { requestIDHeader: nil, cacheable: false) } - - + } extension LightWalletGRPCService: LightWalletService { @@ -250,4 +249,3 @@ extension LightWalletServiceError { } } } - diff --git a/ZcashLightClientKit/UIKit/Synchronizer/SDKSynchronizer.swift b/ZcashLightClientKit/UIKit/Synchronizer/SDKSynchronizer.swift index 2efb143d..3609b87d 100644 --- a/ZcashLightClientKit/UIKit/Synchronizer/SDKSynchronizer.swift +++ b/ZcashLightClientKit/UIKit/Synchronizer/SDKSynchronizer.swift @@ -91,7 +91,6 @@ public class SDKSynchronizer: Synchronizer { private var transactionManager: OutboundTransactionManager private var transactionRepository: TransactionRepository - /** Creates an SDKSynchronizer instance - Parameter initializer: a wallet Initializer object diff --git a/ZcashLightClientKitTests/BalanceTests.swift b/ZcashLightClientKitTests/BalanceTests.swift index 66eb4b5b..2bfee26c 100644 --- a/ZcashLightClientKitTests/BalanceTests.swift +++ b/ZcashLightClientKitTests/BalanceTests.swift @@ -338,7 +338,7 @@ class BalanceTests: XCTestCase { */ func testVerifyChangeTransaction() throws { - try FakeChainBuilder.buildChain(darksideWallet: coordinator.service) + try FakeChainBuilder.buildSingleNoteChain(darksideWallet: coordinator.service) try coordinator.applyStaged(blockheight: defaultLatestHeight) let sendExpectation = XCTestExpectation(description: "send expectation") @@ -369,19 +369,21 @@ class BalanceTests: XCTestCase { /* Send */ - + let memo = "shielding is fun!" var pendingTx: PendingTransactionEntity? - coordinator.synchronizer.sendToAddress(spendingKey: spendingKeys, zatoshi: Int64(sendAmount), toAddress: testRecipientAddress, memo: "test memo \(self.description)", from: 0) { (sendResult) in - switch sendResult { - case .failure(let sendError): - XCTFail("error sending \(sendError)") - case .success(let tx): - pendingTx = tx + coordinator.synchronizer.sendToAddress(spendingKey: spendingKeys, zatoshi: Int64(sendAmount), toAddress: testRecipientAddress, memo: memo, from: 0) { (sendResult) in + DispatchQueue.main.async { + switch sendResult { + case .failure(let sendError): + XCTFail("error sending \(sendError)") + case .success(let tx): + pendingTx = tx + } + + sendExpectation.fulfill() } - - sendExpectation.fulfill() } - wait(for: [createToAddressExpectation], timeout: 11) + wait(for: [createToAddressExpectation], timeout: 30) let syncToMinedheightExpectation = XCTestExpectation(description: "sync to mined height + 1") @@ -424,6 +426,8 @@ class BalanceTests: XCTestCase { XCTAssertEqual(Int64(confirmedTx.value), self.sendAmount) XCTAssertEqual(confirmedTx.toAddress, self.testRecipientAddress) + XCTAssertEqual(confirmedTx.memo?.asZcashTransactionMemo(), memo) + guard let transactionId = confirmedTx.rawTransactionId else { XCTFail("no raw transaction id") return @@ -452,7 +456,7 @@ class BalanceTests: XCTestCase { /* There’s a change note of value (previous note value - sent amount) */ - XCTAssertEqual(Int64(sentNote.value) - self.sendAmount, Int64(receivedNote.value)) + XCTAssertEqual(previousVerifiedBalance - self.sendAmount - ZcashSDK.defaultFee(for: try! synchronizer.latestDownloadedHeight()), Int64(receivedNote.value)) /* diff --git a/ZcashLightClientKitTests/utils/FakeChainBuilder.swift b/ZcashLightClientKitTests/utils/FakeChainBuilder.swift index 1035eca3..1392f2f0 100644 --- a/ZcashLightClientKitTests/utils/FakeChainBuilder.swift +++ b/ZcashLightClientKitTests/utils/FakeChainBuilder.swift @@ -22,6 +22,15 @@ class FakeChainBuilder { static let testnetPostCanopyTx = "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/testnet-canopy/post-activation-txs/ecaa6c03709d70aa25446a81690b18ddb11daac96a03fe4b5cfd0d89a49fb963.txt" + static func buildSingleNoteChain(darksideWallet: DarksideWalletService) throws { + try darksideWallet.reset(saplingActivation: 663150) + try darksideWallet.useDataset(from: txMainnetBlockUrl) + + try darksideWallet.stageBlocksCreate(from: 663151, count: 100) + + try darksideWallet.stageTransaction(from: txUrls[663174]!, at: 663174) + + } static func buildChain(darksideWallet: DarksideWalletService) throws { try darksideWallet.reset(saplingActivation: 663150) try darksideWallet.useDataset(from: txMainnetBlockUrl)