howardwu / wagyu

A Rust library for generating cryptocurrency wallets
https://wagyu.dev
Apache License 2.0
609 stars 107 forks source link

Electrum derivation path #233

Closed alishir closed 3 years ago

alishir commented 3 years ago

I tried to derive some receiving address similar to Electrum derivation path (e.g. m/0/<n>) using following snippet, but the generated addresses is different with addresses that generated by Electrum.

type N = Mainnet;
let ext_key = BitcoinExtendedPublicKey::<N>::from_str("xpub....").unwrap();
let path = BitcoinDerivationPath::<N>::from_str("m/0/0").unwrap();
let child_key = ext_key.derive(&path).unwrap();
let addr = child_key.to_address(&child_key.format()).unwrap();
println!("Derived addr: {}", addr);