From 7753ac9d3fcb76d4ba1ed15efb5c98a6ff77a187 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 21 Feb 2024 00:54:34 +0000 Subject: [PATCH] Expose APIs for working with transaction proposals Closes Electric-Coin-Company/zcash-swift-wallet-sdk#1204. --- CHANGELOG.md | 21 +++++++++++++ .../Synchronizer/CombineSDKSynchronizer.swift | 30 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e6251f2..a2e081c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,27 @@ The old `Synchronizer.sendToAddress` and `Synchronizer.shieldFunds` APIs have be deprecated, and will be removed in 2.1.0 (which will create multiple transactions at once for some recipients). +# Unreleased + +## Changed + +### [#1186] Enable ZIP 317 fees +- The SDK now generates transactions using [ZIP 317](https://zips.z.cash/zip-0317) fees, + instead of a fixed fee of 10,000 Zatoshi. Use `Proposal.totalFeeRequired` to check the + total fee for a transfer before creating it. + +## Added + +### [#1204] Expose APIs for working with transaction proposals +New `Synchronizer` APIs that enable constructing a proposal for transferring or +shielding funds, and then creating transactions from a proposal. The intermediate +proposal can be used to determine the required fee, before committing to producing +transactions. + +The old `Synchronizer.sendToAddress` and `Synchronizer.shieldFunds` APIs have been +deprecated, and will be removed in 2.1.0 (which will create multiple transactions +at once for some recipients). + # 2.0.10 - 2024-02-12 ## Added diff --git a/Sources/ZcashLightClientKit/Synchronizer/CombineSDKSynchronizer.swift b/Sources/ZcashLightClientKit/Synchronizer/CombineSDKSynchronizer.swift index aa38be92..5aca71b5 100644 --- a/Sources/ZcashLightClientKit/Synchronizer/CombineSDKSynchronizer.swift +++ b/Sources/ZcashLightClientKit/Synchronizer/CombineSDKSynchronizer.swift @@ -80,6 +80,36 @@ extension CombineSDKSynchronizer: CombineSynchronizer { } } + public func proposeShielding( + accountIndex: Int, + shieldingThreshold: Zatoshi, + memo: Memo + ) -> SinglePublisher { + AsyncToCombineGateway.executeThrowingAction() { + try await self.synchronizer.proposeShielding(accountIndex: accountIndex, shieldingThreshold: shieldingThreshold, memo: memo) + } + } + + public func createProposedTransactions( + proposal: Proposal, + spendingKey: UnifiedSpendingKey + ) -> SinglePublisher, Error> { + AsyncToCombineGateway.executeThrowingAction() { + try await self.synchronizer.createProposedTransactions(proposal: proposal, spendingKey: spendingKey) + } + } + + public func proposeTransfer( + accountIndex: Int, + recipient: Recipient, + amount: Zatoshi, + memo: Memo? + ) -> SinglePublisher { + AsyncToCombineGateway.executeThrowingAction() { + try await self.synchronizer.proposeTransfer(accountIndex: accountIndex, recipient: recipient, amount: amount, memo: memo) + } + } + public func proposeShielding( accountIndex: Int, shieldingThreshold: Zatoshi,