Use the correct coin type

This commit is contained in:
Aditya Kulkarni
2019-10-01 17:30:35 -07:00
parent 99894411b2
commit 76980cb6b4
2 changed files with 11 additions and 2 deletions

View File

@@ -213,6 +213,15 @@ impl LightClientConfig {
}.parse().unwrap()
}
pub fn get_coin_type(&self) -> u32 {
match &self.chain_name[..] {
"main" => mainnet::COIN_TYPE,
"test" => testnet::COIN_TYPE,
"regtest" => regtest::COIN_TYPE,
c => panic!("Unknown chain {}", c)
}
}
pub fn hrp_sapling_address(&self) -> &str {
match &self.chain_name[..] {
"main" => mainnet::HRP_SAPLING_PAYMENT_ADDRESS,

View File

@@ -133,13 +133,13 @@ impl LightWallet {
return 2;
}
fn get_pk_from_bip39seed(bip39seed: &[u8]) ->
fn get_pk_from_bip39seed(config: LightClientConfig, bip39seed: &[u8]) ->
(ExtendedSpendingKey, ExtendedFullViewingKey, PaymentAddress<Bls12>) {
let extsk: ExtendedSpendingKey = ExtendedSpendingKey::from_path(
&ExtendedSpendingKey::master(bip39seed),
&[
ChildIndex::Hardened(32),
ChildIndex::Hardened(1), // TODO: Cointype should be 133 for mainnet
ChildIndex::Hardened(config.get_coin_type()),
ChildIndex::Hardened(0)
],
);