Skip to content

Commit

Permalink
hd_account_index wrapped in Zip32AccountIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasKorba committed Dec 9, 2024
1 parent e48cd60 commit df1b319
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Sources/ZcashLightClientKit/Account/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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).")
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ZcashLightClientKit/Model/WalletTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit df1b319

Please sign in to comment.