From ed2dc40951f93e9d3e4b5870563da0e837487fe5 Mon Sep 17 00:00:00 2001 From: Francisco Gindre Date: Fri, 26 Aug 2022 19:08:39 -0300 Subject: [PATCH] Fix rebase/merge conflicts and compile errors derived from it --- Package.resolved | 4 ++-- .../ZcashLightClientKit/Entity/AccountEntity.swift | 11 ----------- .../ZcashLightClientKit/Rust/ZcashRustBackend.swift | 9 ++++++--- .../Rust/ZcashRustBackendWelding.swift | 11 ++++++++++- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Package.resolved b/Package.resolved index b8bf7c0f6..a3e95e879 100644 --- a/Package.resolved +++ b/Package.resolved @@ -86,8 +86,8 @@ "package": "libzcashlc", "repositoryURL": "https://github.com/zcash-hackworks/zcash-light-client-ffi", "state": { - "branch": "shield_funds_to_zip_316", - "revision": "63e26a09715486a9ac378e7276cf4f2c09044c57", + "branch": "bin/shield_funds_to_zip_316", + "revision": "2c427bfece56a036bb0370764e4a045c2e456aa5", "version": null } } diff --git a/Sources/ZcashLightClientKit/Entity/AccountEntity.swift b/Sources/ZcashLightClientKit/Entity/AccountEntity.swift index 2e77fd475..1036f1d33 100644 --- a/Sources/ZcashLightClientKit/Entity/AccountEntity.swift +++ b/Sources/ZcashLightClientKit/Entity/AccountEntity.swift @@ -31,17 +31,6 @@ struct Account: AccountEntity, Encodable, Decodable { var transparentAddress: String } -extension Account: UnifiedAddress { - var encoding: String { - get { - address - } - set { - address = newValue - } - } -} - extension Account: Hashable { func hash(into hasher: inout Hasher) { hasher.combine(account) diff --git a/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift b/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift index d633200ac..4420a28d2 100644 --- a/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift +++ b/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift @@ -11,6 +11,8 @@ import libzcashlc class ZcashRustBackend: ZcashRustBackendWelding { + static let minimumConfirmations: UInt32 = 10 + static func lastError() -> RustWeldingError? { guard let message = getLastError() else { return nil } @@ -254,7 +256,7 @@ class ZcashRustBackend: ZcashRustBackendWelding { static func getVerifiedBalance(dbData: URL, account: Int32, networkType: NetworkType) -> Int64 { let dbData = dbData.osStr() - return zcashlc_get_verified_balance(dbData.0, dbData.1, account, networkType.networkId) + return zcashlc_get_verified_balance(dbData.0, dbData.1, account, networkType.networkId, minimumConfirmations) } static func getVerifiedTransparentBalance(dbData: URL, address: String, networkType: NetworkType) throws -> Int64 { @@ -268,7 +270,7 @@ class ZcashRustBackend: ZcashRustBackendWelding { let dbData = dbData.osStr() - return zcashlc_get_verified_transparent_balance(dbData.0, dbData.1, [CChar](address.utf8CString), networkType.networkId) + return zcashlc_get_verified_transparent_balance(dbData.0, dbData.1, [CChar](address.utf8CString), networkType.networkId, minimumConfirmations) } static func getTransparentBalance(dbData: URL, address: String, networkType: NetworkType) throws -> Int64 { @@ -418,7 +420,8 @@ class ZcashRustBackend: ZcashRustBackendWelding { UInt(spendParamsPath.lengthOfBytes(using: .utf8)), outputParamsPath, UInt(outputParamsPath.lengthOfBytes(using: .utf8)), - networkType.networkId + networkType.networkId, + minimumConfirmations ) } diff --git a/Sources/ZcashLightClientKit/Rust/ZcashRustBackendWelding.swift b/Sources/ZcashLightClientKit/Rust/ZcashRustBackendWelding.swift index e7b22052a..4d27e8c18 100644 --- a/Sources/ZcashLightClientKit/Rust/ZcashRustBackendWelding.swift +++ b/Sources/ZcashLightClientKit/Rust/ZcashRustBackendWelding.swift @@ -22,6 +22,15 @@ enum ZcashRustBackendWeldingConstants { static let validChain: Int32 = -1 } +/** + Enumeration of potential return states for database initialization. If `seedRequired` is returned, the caller must + re-attempt initialization providing the seed + */ +public enum DbInitResult { + case success + case seedRequired +} + protocol ZcashRustBackendWelding { /** gets the latest error if available. Clear the existing error @@ -37,7 +46,7 @@ protocol ZcashRustBackendWelding { initializes the data db - Parameter dbData: location of the data db sql file */ - static func initDataDb(dbData: URL, networkType: NetworkType) throws + static func initDataDb(dbData: URL, seed: [UInt8]?, networkType: NetworkType) throws -> DbInitResult /** - Returns: true when the address is valid and shielded. Returns false in any other case