Archive of the libbitcoin Slack #general channel.
extract_output() ... there are many different output scripts with valid address types.channel->subscribe<bc::message::inventory>(headers_subscription_handler);
Instead of bc::message::headers, and changed the declaration of headers_subscription_handler to
const auto headers_subscription_handler = [](const bc::code& ec, bc::message::inventory::const_ptr message)const std::string master_chain_code = "xpub68xePK7VvVcVQikShVGveYd8c7eTsU8VW2RmjVpfLuPn2v188qBeT9hhXTsDi3qrTQMj6uuvwMm4jtm6WiySEpSoF54fEaSmqs1mxP3v6W7";
std::string get_address(uint32_t user_id, uint32_t chain_index)
{
bc::wallet::hd_public master(master_chain_code,
bc::wallet::hd_public::mainnet);
auto user_chain = master.derive_public(user_id);
auto key_chain = user_chain.derive_public(chain_index);
bc::wallet::ec_public public_key(key_chain.point());
auto payaddr = public_key.to_payment_address();
return payaddr.encoded();
}
echo e171367ca589c056589c5a837b5f79b3aea61d947b5dccd5 | bx hd-new | bx hd-public | bx hd-to-ec | bx ec-to-address
$ echo e171367ca589c056589c5a837b5f79b3aea61d947b5dccd5 | bx hd-new -v 70615956 | bx hd-public | bx hd-to-ec | bx ec-to-address
Error: the argument ('ERROR_VERSION') is invalid
Error: the argument is invalid
$ echo e171367ca589c056589c5a837b5f79b3aea61d947b5dccd5 | bx hd-new --version 70617039 tpubD6NzVbkrYhZ4WVyJejvGGNMQ22hjnaJAjJJhb2TPkwWNgek3fY5CLfqF5rVZ8XH4kdVeQaZHv66NegB8nArXhnXJkyCX29w2RWC45PCwJWn
$ echo e171367ca589c056589c5a837b5f79b3aea61d947b5dccd5 | bx hd-new --version 70617039 | bx hd-public -s 70617039 xpub68xePK7Maq5XDpYmLb9M82bNgTAuwCDfFC7tNJrmLZgBDAPgeXDHz3MKyXihRXEZNRHf46h691DpayeCJ7pcgYg5FJQJpR5R9dMAdxvfa2S
$ echo tpubD6NzVbkrYhZ4WmUsVtDM62qG5zPPbAApWqc9nsqT6sYAcDvs1MtVSHG8otsqy45G33nmaBHe4TWNpuQZk3sLX19rfRsYoKmirQuWbuL6TED | bx hd-public -i 0 -s 70617039 -p 70617039 | bx hd-public -i 110 -s 70617039 -p 70617039
tpubDBAE2dXw4Sxt4JJQheSzdEzoozchwRmScq9FXLEAHLj4spM2YTi9BXQmiRcDac2pJfequB8UbLJaAUc3f8iiia2hr9ac2sKckvZURtomCxs
#include <bitcoin/system.hpp>
const std::string master_chain_code = "tpubD6NzVbkrYhZ4WmUsVtDM62qG5zPPbAApWqc9nsqT6sYAcDvs1MtVSHG8otsqy45G33nmaBHe4TWNpuQZk3sLX19rfRsYoKmirQuWbuL6TED";
std::string get_address(uint32_t user_id, uint32_t chain_index)
{
bc::system::wallet::hd_public master(master_chain_code,
bc::system::wallet::hd_public::testnet);
BITCOIN_ASSERT(bc::system::wallet::hd_public::testnet == 70617039);
BITCOIN_ASSERT(master);
auto user_chain = master.derive_public(user_id);
auto key_chain = user_chain.derive_public(chain_index);
// This line asserts
BITCOIN_ASSERT(user_chain);
BITCOIN_ASSERT(key_chain);
bc::system::wallet::ec_public public_key(key_chain.point());
auto payaddr = public_key.to_payment_address(0x6f);
return payaddr.encoded();
}
int main()
{
get_address(0, 110);
return 0;
}
hd_public hd_public::derive_public(uint32_t index) const
{
if (index >= hd_first_hardened_key)
return {};
const auto data = splice(point_, to_big_endian(index));
const auto intermediate = split(hmac_sha512_hash(data, chain_));
// The returned child key Ki is point(parse256(IL)) + Kpar.
auto child = point_;
if (!ec_add(child, intermediate.left))
return {};
if (lineage_.depth == max_uint8)
return {};
const hd_lineage lineage
{
lineage_.prefixes,
static_cast<uint8_t>(lineage_.depth + 1),
fingerprint(),
index
};
return hd_public(child, intermediate.right, lineage);
}
hd_public_version 70617039
hd_secret_version 70615956
pay_to_public_key_hash_version 111
pay_to_script_hash_version 196
transaction_version 1
wif_version 239for (uint8_t attempt = 0; attempt <= max_uint8; attempt++)
for (uint8_t attempt = 0; ; attempt = (attempt == max_uint8) ? 0 : (attempt + 1))
16:22:22.307190 INFO [server] ================= startup Thu May 23 18:22:22 2019 ================== 16:22:22.307216 WARNING [server] ================= startup Thu May 23 18:22:22 2019 ================== 16:22:22.307259 ERROR [server] ================= startup Thu May 23 18:22:22 2019 ================== 16:22:22.307274 FATAL [server] ================= startup Thu May 23 18:22:22 2019 ================== 16:22:22.307285 INFO [server] Using config file: "/home/kk/usr/etc/libbitcoin/bs.cfg" 16:22:22.307299 INFO [server] Please wait while the server is starting... 16:22:22.308752 INFO [network] Starting manual session. 16:22:22.309198 INFO [server] Seeding is complete. 16:22:22.309232 INFO [node] Top confirmed block height is (0). 16:22:22.309260 INFO [node] Top candidate block height is (0). 16:22:22.309274 INFO [node] Top valid candidate block height (0). 16:22:22.309283 INFO [node] Pending candidate block downloads (0). 16:22:22.309329 INFO [network] Starting inbound session on port (18333). 16:22:22.309452 INFO [network] Starting outbound session. 16:22:22.310787 INFO [server] Bound public query service to tcp://*:9091 16:22:22.311137 ERROR [protocol] Configured HTTP root path '"web"' does not exist. 16:22:22.311199 INFO [server] Server failed to start with error, operation failed. 16:22:22.311339 INFO [server] Please wait while the server is stopping...
18:49:12.765642 INFO [network] Connected outbound channel [47.93.2.31:18333] (3) 18:49:13.496026 INFO [network] Connected outbound channel [130.149.80.221:18333] (4) ^C18:49:25.779394 INFO [server] Stop signal detected (code: 2). 18:49:25.787230 INFO [server] Please wait while the server is stopping... ^C08:33:07.591696 INFO [server] Stop signal detected (code: 2).