diff --git a/Sources/ZcashLightClientKit/Account/Account.swift b/Sources/ZcashLightClientKit/Account/Account.swift index 74e544ea..d39a6349 100644 --- a/Sources/ZcashLightClientKit/Account/Account.swift +++ b/Sources/ZcashLightClientKit/Account/Account.swift @@ -14,7 +14,7 @@ public struct Zip32AccountIndex: Equatable, Codable, Hashable { /// - Parameter index: the ZIP 32 account index, which must be less than ``1<<31``. public init(_ index: UInt32) { - guard index < (1<<31) else { + guard index < (1 << 31) else { fatalError("Account index must be less than 1<<31. Input value is \(index).") } diff --git a/Sources/ZcashLightClientKit/Model/WalletTypes.swift b/Sources/ZcashLightClientKit/Model/WalletTypes.swift index 71dc4b4a..ec1ca947 100644 --- a/Sources/ZcashLightClientKit/Model/WalletTypes.swift +++ b/Sources/ZcashLightClientKit/Model/WalletTypes.swift @@ -15,7 +15,7 @@ public struct Account: Equatable, Hashable, Codable, Identifiable { public let name: String public let keySource: String? public let seedFingerprint: [UInt8]? - public let hdAccountIndex: UInt32? + public let hdAccountIndex: Zip32AccountIndex? } public struct UnifiedSpendingKey: Equatable, Undescribable { diff --git a/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift b/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift index aa4aab45..bc590a05 100644 --- a/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift +++ b/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift @@ -136,7 +136,7 @@ struct ZcashRustBackend: ZcashRustBackendWelding { let treeStateBytes = try treeState.serializedData(partial: false).bytes - var kSource: [CChar]? = nil + var kSource: [CChar]? if let keySource { kSource = [CChar](keySource.utf8CString) @@ -1052,12 +1052,11 @@ extension FfiAccount { name: account_name != nil ? String(cString: account_name) : "", keySource: key_source != nil ? String(cString: key_source) : nil, seedFingerprint: seedFingerprintArray, - hdAccountIndex: hd_account_index + hdAccountIndex: Zip32AccountIndex(hd_account_index) ) } } - extension FfiBoxedSlice { /// converts an [`FfiBoxedSlice`] into a [`UnifiedSpendingKey`] /// - Note: This does not check that the converted value actually holds a valid USK