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

Download history 54/week @ 2024-03-11 46/week @ 2024-03-18 8/week @ 2024-03-25 64/week @ 2024-04-01 39/week @ 2024-04-08 58/week @ 2024-04-15 29/week @ 2024-04-22 8/week @ 2024-04-29 16/week @ 2024-05-20 31/week @ 2024-05-27 20/week @ 2024-06-03 4/week @ 2024-06-10 50/week @ 2024-06-17 16/week @ 2024-06-24

91 downloads per month
Used in 4 crates

MIT license

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