From a01205b408ddbf057864dd92ca9863061d6845c5 Mon Sep 17 00:00:00 2001 From: Lukas Korba Date: Thu, 29 Feb 2024 13:31:27 +0100 Subject: [PATCH 1/4] TCA-conformations - Proposal conforms to the Equatable - .zero Proposal added TCA-conformations - internal protection level -> public TCA-conformations - zip317 enabled TCA-conformations - removed public .zero Proposal TCA-conformations - testOnlyFakeProposal for testing purposes outside SDK TCA-conformations - updated code TCA-conformations - typos fixed --- .../ZcashLightClientKit/Model/Proposal.swift | 17 +++++++++++++++-- .../Rust/ZcashRustBackend.swift | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Sources/ZcashLightClientKit/Model/Proposal.swift b/Sources/ZcashLightClientKit/Model/Proposal.swift index 0111c588..fac1c62d 100644 --- a/Sources/ZcashLightClientKit/Model/Proposal.swift +++ b/Sources/ZcashLightClientKit/Model/Proposal.swift @@ -8,11 +8,24 @@ import Foundation /// A data structure that describes a series of transactions to be created. -public struct Proposal { +public struct Proposal: Equatable { let inner: FfiProposal /// Returns the total fee to be paid across all proposed transactions, in zatoshis. public func totalFeeRequired() -> Zatoshi { - return Zatoshi(Int64(inner.balance.feeRequired)) + Zatoshi(Int64(inner.balance.feeRequired)) + } +} + +public extension Proposal { + /// IMPORTANT: Use of this function is for testing purposes only, not recommended to use in production. + /// The instance of `Proposal` should never be created on client's side. + static func testOnlyFakeProposal(totalFee: UInt64) -> Self { + var ffiProposal = FfiProposal() + var balance = FfiTransactionBalance() + + balance.feeRequired = totalFee + + return Self(inner: ffiProposal) } } diff --git a/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift b/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift index 99d128a6..290bce63 100644 --- a/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift +++ b/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift @@ -13,7 +13,7 @@ let globalDBLock = NSLock() actor ZcashRustBackend: ZcashRustBackendWelding { let minimumConfirmations: UInt32 = 10 - let useZIP317Fees = false + let useZIP317Fees = true let dbData: (String, UInt) let fsBlockDbRoot: (String, UInt) From bbdfc2c48c3bb7c885f915604e23756e4f97e2db Mon Sep 17 00:00:00 2001 From: Lukas Korba Date: Thu, 29 Feb 2024 15:46:07 +0100 Subject: [PATCH 2/4] Update Sources/ZcashLightClientKit/Model/Proposal.swift Co-authored-by: str4d --- Sources/ZcashLightClientKit/Model/Proposal.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/ZcashLightClientKit/Model/Proposal.swift b/Sources/ZcashLightClientKit/Model/Proposal.swift index fac1c62d..3148a4a6 100644 --- a/Sources/ZcashLightClientKit/Model/Proposal.swift +++ b/Sources/ZcashLightClientKit/Model/Proposal.swift @@ -18,8 +18,10 @@ public struct Proposal: Equatable { } public extension Proposal { - /// IMPORTANT: Use of this function is for testing purposes only, not recommended to use in production. - /// The instance of `Proposal` should never be created on client's side. + /// IMPORTANT: This function is for testing purposes only. It produces fake invalid + /// data that can be used to check UI elements, but will always produce an error when + /// passed to `Synchronizer.createProposedTransactions`. It should never be called in + /// production code. static func testOnlyFakeProposal(totalFee: UInt64) -> Self { var ffiProposal = FfiProposal() var balance = FfiTransactionBalance() From 33eb55a3c5d85c77142962ddafb3e4a7006a1bc7 Mon Sep 17 00:00:00 2001 From: Lukas Korba Date: Thu, 29 Feb 2024 15:50:42 +0100 Subject: [PATCH 3/4] TCA-conformations - changelog updated --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 947fba7a..f2ee64ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this library adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # Unreleased +## Changed + +### [#1186] Enable ZIP 317 fees +- The `useZIP317Fees` has been enabled. The 1000 Zatoshi fee proposed in ZIP-313 is no longer valid as well as 10k Zatoshi for the fee. Use `Proposal` for the dynamic fees. + ## Added ### [#1204] Expose APIs for working with transaction proposals From a325213a7a657f2586a8cc95ba456b65b9346d71 Mon Sep 17 00:00:00 2001 From: Lukas Korba Date: Thu, 29 Feb 2024 16:09:35 +0100 Subject: [PATCH 4/4] Update CHANGELOG.md Co-authored-by: str4d --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2ee64ad..4e6251f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,9 @@ and this library adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Changed ### [#1186] Enable ZIP 317 fees -- The `useZIP317Fees` has been enabled. The 1000 Zatoshi fee proposed in ZIP-313 is no longer valid as well as 10k Zatoshi for the fee. Use `Proposal` for the dynamic 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