View in context in the libbitcoin Slack #general mirror.
#include <iostream>
#include <vector>
#include <string>
#include <cstdint>
#include <bitcoin/system.hpp>
#include <secp256k1.h>
// http://aaronjaramillo.org/libbitcoin-building-a-raw-transaction
// https://github.com/bitcoin/bips/blob/master/bip-0178.mediawiki
// the obvious stuff that should be covered by the usecase example would be
// (first out we do for P2PKH & P2SH, THEN we extend to all the other four: native & P2SH-wrapped P2WPKH & P2WSH):
/*
g++ \
-std=c++11 \
-o conceptual_usecase_script \
conceptual_usecase_script.cpp \
-fpermissive \
$(pkg-config --cflags libbitcoin-system --libs libbitcoin-system)
*/
using namespace bc;
using namespace bc::system;
using namespace bc::system::chain;
using namespace bc::system::wallet;
using namespace bc::system::machine;
int main(int argc, char const *argv[])
{
// * (unrelated to segwit:) generate an HD wallet
std::cout << std::endl << std::endl << std::setw(40) << std::setfill('-') << "-" << std::endl;
std::cout << std::endl << "* (unrelated to segwit:) generate an HD wallet" << std::endl;
{
data_chunk hd_entropy{16};
pseudo_random_fill(hd_entropy);
data_chunk hd_seed = to_chunk(decode_mnemonic(create_mnemonic(hd_entropy)));
hd_private hd_private_key{hd_seed, hd_private::testnet};
hd_public hd_public_key = hd_private_key.to_public();
std::cout << "\nHd private key: " << std::endl;full file