From 2a484450856616095bd507224c6e96389422a233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=97=A4=E7=94=B0=E5=93=B2=E5=8F=B2?= Date: Thu, 27 Sep 2018 09:26:32 +0900 Subject: [PATCH 1/2] :pencil2: add public --- Sources/BitcoinKit/Core/Keys/HDKeychain.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/BitcoinKit/Core/Keys/HDKeychain.swift b/Sources/BitcoinKit/Core/Keys/HDKeychain.swift index d3df3380..2ccb2f34 100644 --- a/Sources/BitcoinKit/Core/Keys/HDKeychain.swift +++ b/Sources/BitcoinKit/Core/Keys/HDKeychain.swift @@ -28,7 +28,7 @@ import Foundation public final class HDKeychain { let privateKey: HDPrivateKey - init(privateKey: HDPrivateKey) { + public init(privateKey: HDPrivateKey) { self.privateKey = privateKey } @@ -54,7 +54,7 @@ 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 { + public func derivedKey(path: String) throws -> HDPrivateKey { var key = privateKey var path = path From 81533a6cc95b9c345b5421d8068c684d3b8afcdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=97=A4=E7=94=B0=E5=93=B2=E5=8F=B2?= Date: Thu, 27 Sep 2018 09:49:40 +0900 Subject: [PATCH 2/2] :recycle: rename rootKey --- Sources/BitcoinKit/Core/Keys/HDKeychain.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/BitcoinKit/Core/Keys/HDKeychain.swift b/Sources/BitcoinKit/Core/Keys/HDKeychain.swift index 2ccb2f34..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 - public 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]+'?)*)? @@ -55,7 +55,7 @@ public final class HDKeychain { /// "m/b/c" (alphabetical characters instead of numerical indexes) /// "m/1.2^3" (contains illegal characters) public func derivedKey(path: String) throws -> HDPrivateKey { - var key = privateKey + var key = rootKey var path = path if path == "m" || path == "/" || path == "" {