diff --git a/Sources/BitcoinKit/Core/Keys/HDKeychain.swift b/Sources/BitcoinKit/Core/Keys/HDKeychain.swift index d3df3380..22ec73e7 100644 --- a/Sources/BitcoinKit/Core/Keys/HDKeychain.swift +++ b/Sources/BitcoinKit/Core/Keys/HDKeychain.swift @@ -26,14 +26,14 @@ import Foundation public final class HDKeychain { - let privateKey: HDPrivateKey + private let rootKey: HDPrivateKey - init(privateKey: HDPrivateKey) { - self.privateKey = privateKey + public init(rootKey: HDPrivateKey) { + self.rootKey = rootKey } public convenience init(seed: Data, network: Network) { - self.init(privateKey: HDPrivateKey(seed: seed, network: network)) + self.init(rootKey: HDPrivateKey(seed: seed, network: network)) } /// Parses the BIP32 path and derives the chain of keychains accordingly. /// Path syntax: (m?/)?([0-9]+'?(/[0-9]+'?)*)? @@ -54,8 +54,8 @@ public final class HDKeychain { /// "m / 0 / 1" (contains spaces) /// "m/b/c" (alphabetical characters instead of numerical indexes) /// "m/1.2^3" (contains illegal characters) - func derivedKey(path: String) throws -> HDPrivateKey { - var key = privateKey + public func derivedKey(path: String) throws -> HDPrivateKey { + var key = rootKey var path = path if path == "m" || path == "/" || path == "" {