23个版本
0.1.23 | 2022年10月4日 |
---|---|
0.1.22 | 2022年10月4日 |
0.1.21 | 2022年9月29日 |
#155 in #钱包
83 每月下载量
在 create-bitcoin-transactio… 中使用
100KB
3.5K SLoC
☠️⚠️ 进行中 ⚠️☠️
比特币HD密钥
分层确定性(HD)钱包的密钥生成
安装
将包添加到Cargo.toml文件
[dependencies]
bitcoin-hd-keys= "0.1.23"
用法
use bitcoin_hd_keys::{
generate_bip32_hd_wallet_from_mnemonic_words, generate_bip44_hd_wallet_from_mnemonic_words,
generate_bip49_hd_wallet_from_mnemonic_words, generate_bip84_hd_wallet_from_mnemonic_words,
get_128_bits_of_entropy, get_mnemonic_words, AddressType, Network,
};
// Generate entropy
let entropy_array = get_128_bits_of_entropy();
// Get mnemonic words from entropy
let mnemonic_words = get_mnemonic_words(entropy_array.to_vec());
// Generate HD Wallet Keys (bip32) from mnemonic words
let bip32_hd_wallet = generate_bip32_hd_wallet_from_mnemonic_words(
mnemonic_words.clone(),
None,
"m/0'/0'".to_string(),
5,
true,
Network::Testnet,
);
println!("{:#?}", bip32_hd_wallet);
bip32_hd_wallet.pretty_print_derived_addressed(Network::Testnet, AddressType::P2PKH);
// Generate Multi-Account Hierarchy HD Keys (bip44) from mnemonic words.
let bip44_hd_wallet = generate_bip44_hd_wallet_from_mnemonic_words(
mnemonic_words.clone(),
None,
0,
5,
true,
Network::Testnet,
);
println!("{:#?}", bip44_hd_wallet);
bip44_hd_wallet.pretty_print_derived_addressed(Network::Testnet, AddressType::P2PKH);
// Generate Derivation scheme for P2WPKH-nested-in-P2SH based accounts HD Keys (bip49) from mnemonic words.
let bip49_hd_wallet = generate_bip49_hd_wallet_from_mnemonic_words(
mnemonic_words.clone(),
None,
0,
5,
true,
Network::Testnet,
);
println!("{:#?}", bip49_hd_wallet);
bip49_hd_wallet.pretty_print_derived_addressed(Network::Testnet, AddressType::P2SH);
// Generate HD Keys using Deterministic Entropy From BIP32 Keychains (bip85) from mnemonic words.
let bip84_hd_wallet = generate_bip84_hd_wallet_from_mnemonic_words(
mnemonic_words.clone(),
None,
0,
5,
true,
Network::Testnet,
);
println!("{:#?}", bip84_hd_wallet);
bip84_hd_wallet.pretty_print_derived_addressed(Network::Testnet, AddressType::Bech32);
相关
- bitcoin-node-query - 查询比特币节点信息
- bitcoind-request -围绕bitcoind RPC命令的类型安全包装器
- bitcoin-terminal-dashboard -终端中的比特币仪表板
了解HD钱包
要了解更多关于HD钱包的信息并了解创建此包所使用的资源材料,请参阅Resources.md
许可证
MIT © Joe Gesualdo
依赖项
~15MB
~329K SLoC