mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-02-01 03:12:15 +00:00
Fix bip39
This commit is contained in:
parent
fd90013653
commit
12c712278e
@ -25,7 +25,7 @@ byteorder = "1"
|
||||
rand = "0.5.6"
|
||||
json = "0.12.0"
|
||||
shellwords = "1.0.0"
|
||||
bip39 = "0.6.0-beta.1"
|
||||
tiny-bip39 = "0.6.2"
|
||||
clap = "2.33"
|
||||
secp256k1 = "=0.15.0"
|
||||
sha2 = "0.8.0"
|
||||
|
@ -151,6 +151,7 @@ impl LightWallet {
|
||||
pub fn new(seed_phrase: Option<String>, config: &LightClientConfig) -> io::Result<Self> {
|
||||
use rand::{FromEntropy, ChaChaRng, Rng};
|
||||
|
||||
// This is the source entropy that corresponds to the 24-word seed phrase
|
||||
let mut seed_bytes = [0u8; 32];
|
||||
|
||||
if seed_phrase.is_none() {
|
||||
@ -162,9 +163,12 @@ impl LightWallet {
|
||||
Language::English).unwrap().entropy());
|
||||
}
|
||||
|
||||
// The seed bytes is the raw entropy. To pass it to HD wallet generation,
|
||||
// we need to get the 64 byte bip39 entropy
|
||||
let bip39_seed = bip39::Seed::new(&Mnemonic::from_entropy(&seed_bytes, Language::English).unwrap(), "");
|
||||
|
||||
// TODO: This only reads one key for now
|
||||
println!("{}", hex::encode(seed_bytes));
|
||||
let ext_t_key = ExtendedPrivKey::with_seed(&seed_bytes).unwrap();
|
||||
let ext_t_key = ExtendedPrivKey::with_seed(&bip39_seed.as_bytes()).unwrap();
|
||||
let tpk = ext_t_key
|
||||
.derive_private_key(KeyIndex::hardened_from_normalize_index(44).unwrap()).unwrap()
|
||||
.derive_private_key(KeyIndex::hardened_from_normalize_index(1).unwrap()).unwrap() // TODO: Cointype
|
||||
@ -382,7 +386,6 @@ impl LightWallet {
|
||||
let mut hash160 = ripemd160::Ripemd160::new();
|
||||
hash160.input(Sha256::digest(&pk.serialize()[..].to_vec()));
|
||||
|
||||
// TODO: The taddr version prefix needs to be different for testnet and mainnet
|
||||
hash160.result().to_base58check(&self.config.base58_pubkey_address(), &[])
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user