Skip to content

Commit

Permalink
Added KeyVersion and Network
Browse files Browse the repository at this point in the history
  • Loading branch information
anquii committed Feb 4, 2023
1 parent 02b3cc4 commit cfded23
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
@testable import BIP32
@propertyWrapper public struct KeyVersion {
public let wrappedValue: UInt32

@propertyWrapper
struct BitcoinVersion {
let wrappedValue: UInt32

init(network: Network, keyAccessControl: KeyAccessControl) {
public init(network: Network, keyAccessControl: KeyAccessControl) {
switch (network, keyAccessControl) {
case (.mainnet, .`private`):
wrappedValue = 0x0488ADE4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
enum Network {
public enum Network {
case mainnet
case testnet
}
2 changes: 1 addition & 1 deletion Tests/BIP32Tests/KeySerializerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ final class KeySerializerTests: XCTestCase {
func testGivenExtendedKey_AndAttributes_WhenSerialize_ThenNoErrorThrown() throws {
let seed = Data(hex: "000102030405060708090a0b0c0d0e0f")
let extendedKey = try PrivateMasterKeyDerivator().privateKey(seed: seed)
let keyVersion = BitcoinVersion(network: .mainnet, keyAccessControl: .`private`).wrappedValue
let keyVersion = KeyVersion(network: .mainnet, keyAccessControl: .`private`).wrappedValue
let keyAttributes = MasterKeyAttributes(accessControl: .`private`, version: keyVersion)

XCTAssertNoThrow(
Expand Down
2 changes: 1 addition & 1 deletion Tests/BIP32Tests/PrivateChildKeyDerivatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ final class PrivateChildKeyDerivatorTests: XCTestCase {
private let privateMasterKeyDerivator = PrivateMasterKeyDerivator()
private let publicMasterKeyDerivator = PublicMasterKeyDerivator()
private let publicChildKeyDerivator = PublicChildKeyDerivator()
private let keyVersion = BitcoinVersion(network: .mainnet, keyAccessControl: .`private`).wrappedValue
private let keyVersion = KeyVersion(network: .mainnet, keyAccessControl: .`private`).wrappedValue
private let keyFingerprintDerivator = KeyFingerprintDerivator()
private let keyIndexHardener = KeyIndexHardener()
private let keySerializer = KeySerializer()
Expand Down
2 changes: 1 addition & 1 deletion Tests/BIP32Tests/PrivateMasterKeyDerivatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import XCTest
import BIP32

final class PrivateMasterKeyDerivatorTests: XCTestCase {
private let keyVersion = BitcoinVersion(network: .mainnet, keyAccessControl: .`private`).wrappedValue
private let keyVersion = KeyVersion(network: .mainnet, keyAccessControl: .`private`).wrappedValue
private var keyAttributes: MasterKeyAttributes!
private let keySerializer = KeySerializer()
private let serializedKeyCoder = SerializedKeyCoder()
Expand Down
2 changes: 1 addition & 1 deletion Tests/BIP32Tests/PublicChildKeyDerivatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ final class PublicChildKeyDerivatorTests: XCTestCase {
private let privateMasterKeyDerivator = PrivateMasterKeyDerivator()
private let publicMasterKeyDerivator = PublicMasterKeyDerivator()
private let privateChildKeyDerivator = PrivateChildKeyDerivator()
private let keyVersion = BitcoinVersion(network: .mainnet, keyAccessControl: .`public`).wrappedValue
private let keyVersion = KeyVersion(network: .mainnet, keyAccessControl: .`public`).wrappedValue
private let keyFingerprintDerivator = KeyFingerprintDerivator()
private let keyIndexHardener = KeyIndexHardener()
private let keySerializer = KeySerializer()
Expand Down
2 changes: 1 addition & 1 deletion Tests/BIP32Tests/PublicMasterKeyDerivatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import XCTest

final class PublicMasterKeyDerivatorTests: XCTestCase {
private let privateKeyDerivator = PrivateMasterKeyDerivator()
private let keyVersion = BitcoinVersion(network: .mainnet, keyAccessControl: .`public`).wrappedValue
private let keyVersion = KeyVersion(network: .mainnet, keyAccessControl: .`public`).wrappedValue
private var keyAttributes: MasterKeyAttributes!
private let keySerializer = KeySerializer()
private let serializedKeyCoder = SerializedKeyCoder()
Expand Down

0 comments on commit cfded23

Please sign in to comment.