8 releases
0.4.1 | Feb 16, 2023 |
---|---|
0.4.0 | Feb 15, 2023 |
0.3.0 | Feb 13, 2021 |
0.2.5 | Feb 7, 2020 |
0.1.1 | Mar 3, 2019 |
#4 in #hd-wallet
91 downloads per month
Used in 4 crates
57KB
1K
SLoC
HD wallet Bitcoin extention.
This crate extend the hdwallet
crate, provide Bitcoin key derivation and serialization according to BIP-32.
See hdwallet documentation to learn how to derive HD keys. See secp256k1 documentation to learn how to signature.
Examples
use hdwallet::{KeyChain, DefaultKeyChain, ExtendedPrivKey, traits::Serialize};
use hdwallet_bitcoin::{PrivKey as BitcoinPrivKey, Network as BitcoinNetwork};
let mut rng = rand::thread_rng();
let master_key = ExtendedPrivKey::random(&mut rng).expect("master key");
let key_chain = DefaultKeyChain::new(master_key);
let (extended_key, derivation) = key_chain.derive_private_key("m/1H/0".into()).expect("derive ExtendedPrivKey");
let key = BitcoinPrivKey {
network: BitcoinNetwork::MainNet,
derivation,
extended_key,
};
let serialized_key: String = key.serialize();
println!("derive m/1H/0 key: {}", serialized_key);
Dependencies
~13MB
~289K SLoC