diff --git a/NthKey/Model/DataManager.swift b/NthKey/Model/DataManager.swift index ee61b25..c02f1ea 100644 --- a/NthKey/Model/DataManager.swift +++ b/NthKey/Model/DataManager.swift @@ -164,11 +164,6 @@ extension DataManager { return } - guard let pathForDerive = BIP32Path("0") else { - completion(.failure(.wrongCosigner)) - return - } - var receivePublicHDkeys: [HDKey] = [] var hdKeys: [(ExtendedKey, HDKey)] = [] desc.extendedKeys.forEach { key in @@ -178,7 +173,7 @@ extension DataManager { return } // ourself key - receivePublicHDkeys.append(try! selfKey.derive(pathForDerive)) + receivePublicHDkeys.append(try! selfKey.derive("0")) return } let extendedKey = Data(base58: key.xpub)! @@ -195,7 +190,7 @@ extension DataManager { } hdKeys.append((key, aKey)) // cosigners keys - receivePublicHDkeys.append(try! aKey.derive(pathForDerive)) + receivePublicHDkeys.append(try! aKey.derive("0")) } // Checking co-signers network @@ -248,15 +243,14 @@ extension DataManager { let signer = CosignerEntity(context: store.container.viewContext) signer.name = "" signer.fingerprint = Data(key.fingerprint) - signer.derivation = BIP32Path(key.origin)?.description + signer.derivation = key.origin signer.xpub = hdKey.description wallet.addToCosigners(signer) } for idx in 0..<1000 { let pubKeys = receivePublicHDkeys.map {key -> PubKey in - let path = try! BIP32Path(idx, relative: true) - let childKey: HDKey = try! key.derive(path) + let childKey: HDKey = try! key.derive(String(idx)) return childKey.pubKey } diff --git a/NthKey/Model/SeedManager.swift b/NthKey/Model/SeedManager.swift index 17b5b31..82a96ff 100644 --- a/NthKey/Model/SeedManager.swift +++ b/NthKey/Model/SeedManager.swift @@ -71,7 +71,7 @@ struct SeedManager { let masterKey = HDKey(seedHex, network)! assert(masterKey.fingerprint == fingerprint) - let path = BIP32Path("m/48h/\(network == .mainnet ? "0h" : "1h")/0h/2h")! + let path = "m/48h/\(network == .mainnet ? "0h" : "1h")/0h/2h" let account = try! masterKey.derive(path) // Specter compatible JSON format: diff --git a/NthKey/Model/Signer.swift b/NthKey/Model/Signer.swift index 7f10d1d..de7ddf1 100644 --- a/NthKey/Model/Signer.swift +++ b/NthKey/Model/Signer.swift @@ -12,11 +12,11 @@ import LibWally public class Signer: NSObject, Identifiable { public let fingerprint: Data - public let derivation: BIP32Path + public let derivation: String public let hdKey: HDKey // TODO: store derivation and fingerprint in HDKey? public let name: String - public init(fingerprint: Data, derivation: BIP32Path, hdKey: HDKey, name: String) { + public init(fingerprint: Data, derivation: String, hdKey: HDKey, name: String) { self.fingerprint = fingerprint self.name = name self.derivation = derivation @@ -30,7 +30,7 @@ public class Signer: NSObject, Identifiable { let masterKey = HDKey(seedHex, network)! assert(masterKey.fingerprint == fingerprint) - let path = BIP32Path("m/48h/\(network == .mainnet ? "0h" : "1h")/0h/2h")! + let path = "m/48h/\(network == .mainnet ? "0h" : "1h")/0h/2h" let ourKey = try! masterKey.derive(path) return Signer(fingerprint: fingerprint, derivation: path, hdKey: ourKey, name: "NthKey") diff --git a/Podfile b/Podfile index 1350d4c..29704a4 100644 --- a/Podfile +++ b/Podfile @@ -5,7 +5,7 @@ target 'NthKey' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! - pod 'LibWally', :git => 'https://github.com/sjors/LibWally-Swift.git', :tag => "v0.0.6", :submodules => true + pod 'LibWally', :git => 'https://github.com/sjors/LibWally-Swift.git', :tag => "v0.0.7", :submodules => true pod 'OutputDescriptors', :git => 'https://github.com/sjors/output-descriptors-swift.git', :tag => "v0.0.2" target 'NthKeyTests' do diff --git a/Podfile.lock b/Podfile.lock index fe4ce9b..97f0164 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -3,14 +3,14 @@ PODS: - OutputDescriptors (0.0.1) DEPENDENCIES: - - LibWally (from `https://github.com/sjors/LibWally-Swift.git`, tag `v0.0.6`) + - LibWally (from `https://github.com/sjors/LibWally-Swift.git`, tag `v0.0.7`) - OutputDescriptors (from `https://github.com/sjors/output-descriptors-swift.git`, tag `v0.0.2`) EXTERNAL SOURCES: LibWally: :git: https://github.com/sjors/LibWally-Swift.git :submodules: true - :tag: v0.0.6 + :tag: v0.0.7 OutputDescriptors: :git: https://github.com/sjors/output-descriptors-swift.git :tag: v0.0.2 @@ -19,15 +19,15 @@ CHECKOUT OPTIONS: LibWally: :git: https://github.com/sjors/LibWally-Swift.git :submodules: true - :tag: v0.0.6 + :tag: v0.0.7 OutputDescriptors: :git: https://github.com/sjors/output-descriptors-swift.git :tag: v0.0.2 SPEC CHECKSUMS: - LibWally: 8192c453746bd8f86978c857aadef57477decbcc + LibWally: ce1e98813b64aa26b4cc3a92d3c7f57db97b2fb2 OutputDescriptors: 700e55b31d3997fb2bf6d9d84f6172ac17a3d573 -PODFILE CHECKSUM: b4a77b28bc7832e680c78bba3eac23a48a0ccfa2 +PODFILE CHECKSUM: 763e5e07a7bf1996fe1d09c9a02fe59870b62a0f -COCOAPODS: 1.10.0 +COCOAPODS: 1.11.3