Bitcoin full node and query server

Apr 4, 2019

View in context in the libbitcoin Slack #general mirror.

J
James14:54
Normal non-segwit LibBitcoin C++ API usecases code, will end up on Github later C++ · 23.2 KB
#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