Address

Libbitcoin 如何從 xpub 按需生成地址?

  • September 9, 2021

好吧,我對此真的很陌生。剛剛安裝了 libbitcoin,我正在閱讀 wiki 和所有內容。

有人真的可以快速提示我如何從 Electrum 錢包導出的 xpub 生成地址嗎?和/或 Ledger 錢包——如果有人知道?

我知道它可以在比特幣核心中完成,但是我想嘗試一下 libbitcoin。非常感謝。

您是否嘗試過他們文件中的這一部分?

<https://github.com/libbitcoin/libbitcoin-system/wiki/Addresses-and-HD-Wallets>

// Load mnemonic sentence into word list
std::string my_sentence = "market parent marriage drive umbrella custom leisure fury recipe steak have enable";
auto my_word_list = split(my_sentence, " ", true);

// Create an optional secret passphrase
std::string my_passphrase = "my secret passphrase";

// Create 512bit seed (without optional secret passphrase)
auto hd_seed = decode_mnemonic(my_word_list);
data_chunk seed_chunk(to_chunk(hd_seed));
hd_private m(seed_chunk, hd_private::mainnet);

// Derivation of master public key M
hd_public M = m.to_public();

// Derive public children of master key M
auto M0 = M.derive_public(0); //Depth 1, Index 0
auto M1 = M.derive_public(1); //Depth 1, Index 1
auto M2 = M.derive_public(2); //Depth 1, Index 2

// Derive further public children
auto M10 = M1.derive_public(0); //Depth 2, Index 0
auto M11 = M1.derive_public(1); //Depth 2, Index 1

引用自:https://bitcoin.stackexchange.com/questions/105350