Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Commit

Permalink
Add more chains to Blockchain
Browse files Browse the repository at this point in the history
  • Loading branch information
vikmeup committed Jul 13, 2018
1 parent f82f561 commit b5385c8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
11 changes: 11 additions & 0 deletions Sources/Blockchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,15 @@ import Foundation
public enum Blockchain {
case bitcoin
case ethereum
case poa
case ethereumClassic
case callisto
case gochain

// test networks

case ethereumRopsten
case ethereumKovan
case ethereumRinkeby
case ethereumSokol
}
21 changes: 16 additions & 5 deletions Sources/HDWallet/HDWallet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,29 @@ public class HDWallet {
extension Blockchain {
public var coinType: Int {
switch self {
case .bitcoin:
return 0
case .ethereum:
return 60
case .bitcoin: return 0
case .ethereum: return 60
case .ethereumKovan, .ethereumRinkeby, .ethereumRopsten, .ethereumSokol: return 60
case .poa: return 178
case .ethereumClassic: return 61
case .callisto: return 820
case .gochain: return 6060
}
}

public func derivationPath(at index: Int) -> DerivationPath {
switch self {
case .bitcoin:
return DerivationPath(purpose: 44, coinType: coinType, account: 0, change: 0, address: index)
case .ethereum:
case .ethereum,
.poa,
.ethereumClassic,
.callisto,
.gochain,
.ethereumKovan,
.ethereumRinkeby,
.ethereumRopsten,
.ethereumSokol:
return DerivationPath(purpose: 44, coinType: coinType, account: 0, change: 0, address: index)
}
}
Expand Down
10 changes: 9 additions & 1 deletion Sources/PrivateKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ public final class PrivateKey: Hashable, CustomStringConvertible {
switch blockchain {
case .bitcoin:
return BitcoinPublicKey(data: Crypto.getPublicKey(from: data))!
case .ethereum:
case .ethereum,
.poa,
.ethereumClassic,
.callisto,
.gochain,
.ethereumKovan,
.ethereumRinkeby,
.ethereumRopsten,
.ethereumSokol:
return EthereumPublicKey(data: Crypto.getPublicKey(from: data))!
}
}
Expand Down

0 comments on commit b5385c8

Please sign in to comment.