├── .gitignore ├── .travis.yml ├── AUTHORS ├── COPYING ├── ChangeLog ├── Doxyfile ├── HACKING ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── README.md ├── archive ├── README ├── examples │ ├── protocol.cpp │ └── tx_radar.cpp ├── hash_data │ ├── README.md │ └── generate.py ├── oldtests │ ├── 1vaynert.cpp │ ├── addr.cpp │ ├── bdb-last.cpp │ ├── bdb-test.cpp │ ├── big-number-test.cpp │ ├── bip16 │ │ ├── block-44987.testnet │ │ ├── block-44989.testnet │ │ ├── hachem.cpp │ │ ├── make.sh │ │ ├── raw_block44987.cpp │ │ └── raw_block44989.cpp │ ├── block-hash.cpp │ ├── blockchain.cpp │ ├── chanstop.cpp │ ├── checksig.cpp │ ├── clock-test.cpp │ ├── corot.cpp │ ├── crap │ │ └── main.cpp │ ├── determ.cpp │ ├── development-makefile │ ├── ec-key.cpp │ ├── echo.cpp │ ├── exporter-test.cpp │ ├── feeder.cpp │ ├── fork-blks │ │ ├── README │ │ ├── blk0 │ │ ├── blk1 │ │ ├── blk2 │ │ └── blkspec │ ├── gengen.cpp │ ├── getx.cpp │ ├── hmac512.cpp │ ├── hosts-test.cpp │ ├── import-test.cpp │ ├── irc.cpp │ ├── kyot.cpp │ ├── logtst.cpp │ ├── memcheck │ │ ├── begin.cpp │ │ ├── curl.supp │ │ └── make.sh │ ├── mempool.cpp │ ├── merkle.cpp │ ├── minikey.cpp │ ├── net.cpp │ ├── pol.cpp │ ├── priv.cpp │ ├── protst.cpp │ ├── psql.cpp │ ├── reorg │ │ ├── chains.hpp │ │ ├── main.cpp │ │ └── reorg.cpp │ ├── script-test.cpp │ ├── serial-test.cpp │ ├── sesh.cpp │ ├── subscribe.cpp │ ├── tx-hash.cpp │ ├── types-test.cpp │ └── verify-block.cpp └── script_json │ ├── README.md │ ├── build_vectors.py │ ├── script_invalid.json │ └── script_valid.json ├── autogen.sh ├── builds └── msvc │ ├── .gitignore │ ├── build │ ├── buildall.bat │ └── buildbase.bat │ ├── properties │ ├── Common.props │ ├── DLL.props │ ├── Debug.props │ ├── DebugDEXE.props │ ├── DebugDLL.props │ ├── DebugLEXE.props │ ├── DebugLIB.props │ ├── DebugLTCG.props │ ├── DebugSEXE.props │ ├── EXE.props │ ├── LIB.props │ ├── LTCG.props │ ├── Link.props │ ├── Messages.props │ ├── Output.props │ ├── Release.props │ ├── ReleaseDEXE.props │ ├── ReleaseDLL.props │ ├── ReleaseLEXE.props │ ├── ReleaseLIB.props │ ├── ReleaseLTCG.props │ ├── ReleaseSEXE.props │ ├── Win32.props │ └── x64.props │ ├── resource.h │ ├── resource.rc │ └── vs2013 │ ├── libbitcoin-test │ ├── libbitcoin-test.props │ ├── libbitcoin-test.vcxproj │ ├── libbitcoin-test.vcxproj.filters │ ├── libbitcoin-test.xml │ └── packages.config │ ├── libbitcoin.import.props │ ├── libbitcoin.import.xml │ ├── libbitcoin.sln │ └── libbitcoin │ ├── libbitcoin.props │ ├── libbitcoin.vcxproj │ ├── libbitcoin.vcxproj.filters │ ├── libbitcoin.xml │ └── packages.config ├── configure.ac ├── debian ├── changelog ├── compat ├── control ├── copyright ├── libbitcoin-dev.install ├── libbitcoin0.install ├── rules └── source │ └── format ├── doc ├── README.tutorial ├── libbitcoin │ ├── README │ ├── drawing.svg │ ├── index.html │ ├── inner_core.png │ ├── make_transaction.png │ ├── multiple_currencies.png │ ├── pluggable.png │ ├── python_layer.png │ ├── switching_nets.png │ └── switching_serialisers.png ├── sphinx │ ├── Makefile │ ├── blockchain.rst │ ├── conf.py │ ├── crypto.rst │ ├── examples │ │ ├── accept.rst │ │ ├── balance.rst │ │ ├── connect.rst │ │ ├── determ.rst │ │ ├── display-last.rst │ │ ├── fullnode.rst │ │ ├── initchain.rst │ │ ├── priv.rst │ │ ├── proto.rst │ │ ├── satoshiwords.rst │ │ └── txrad.rst │ ├── fullnode.rst │ ├── img │ │ └── operations.png │ ├── index.rst │ ├── introduction.rst │ ├── make.bat │ ├── network.rst │ ├── offlinetx.rst │ ├── overview.rst │ └── quickstart.rst └── style ├── include └── bitcoin │ ├── bitcoin.hpp │ └── bitcoin │ ├── block.hpp │ ├── compat.h │ ├── compat.hpp │ ├── config │ ├── parameter.hpp │ └── printer.hpp │ ├── constants.hpp │ ├── define.hpp │ ├── error.hpp │ ├── formats │ ├── base10.hpp │ ├── base16.hpp │ ├── base58.hpp │ ├── base64.hpp │ └── base85.hpp │ ├── impl │ ├── formats │ │ └── base16.ipp │ ├── serialize │ │ ├── block.ipp │ │ └── misc.ipp │ └── utility │ │ ├── array_slice.ipp │ │ ├── data.ipp │ │ ├── endian.ipp │ │ ├── general.ipp │ │ └── serializer.ipp │ ├── math │ ├── checksum.hpp │ ├── ec_keys.hpp │ ├── external │ │ ├── hmac_sha256.h │ │ ├── hmac_sha512.h │ │ ├── ripemd160.h │ │ ├── sha1.h │ │ ├── sha256.h │ │ ├── sha512.h │ │ ├── uint256.h │ │ └── zeroize.h │ ├── hash.hpp │ ├── hash_number.hpp │ └── script_number.hpp │ ├── network │ ├── channel.hpp │ ├── handshake.hpp │ ├── hosts.hpp │ ├── network.hpp │ ├── protocol.hpp │ └── shared_const_buffer.hpp │ ├── primitives.hpp │ ├── satoshi_serialize.hpp │ ├── script.hpp │ ├── stealth.hpp │ ├── transaction.hpp │ ├── utility │ ├── array_slice.hpp │ ├── assert.hpp │ ├── async_parallel.hpp │ ├── binary.hpp │ ├── data.hpp │ ├── decorator.hpp │ ├── endian.hpp │ ├── general.hpp │ ├── logger.hpp │ ├── serializer.hpp │ ├── subscriber.hpp │ ├── threadpool.hpp │ ├── timed_section.hpp │ └── weak_bind.hpp │ ├── version.hpp │ └── wallet │ ├── address.hpp │ ├── hd_keys.hpp │ ├── key_formats.hpp │ ├── message.hpp │ ├── mnemonic.hpp │ ├── stealth_address.hpp │ └── uri.hpp ├── install.sh ├── ipynob.py ├── libbitcoin.pc.in ├── m4 ├── .gitignore ├── ax_boost_base.m4 ├── ax_boost_date_time.m4 ├── ax_boost_filesystem.m4 ├── ax_boost_program_options.m4 ├── ax_boost_regex.m4 ├── ax_boost_system.m4 ├── ax_boost_unit_test_framework.m4 ├── ax_check_compile_flag.m4 ├── ax_check_link_flag.m4 ├── ax_cxx_compile_stdcxx_11.m4 └── ax_pthread.m4 ├── src ├── block.cpp ├── compat.cpp ├── config │ ├── parameter.cpp │ └── printer.cpp ├── constants.cpp ├── error.cpp ├── formats │ ├── base10.cpp │ ├── base16.cpp │ ├── base58.cpp │ ├── base64.cpp │ └── base85.cpp ├── math │ ├── checksum.cpp │ ├── ec_keys.cpp │ ├── external │ │ ├── hmac_sha256.c │ │ ├── hmac_sha512.c │ │ ├── ripemd160.c │ │ ├── sha1.c │ │ ├── sha256.c │ │ ├── sha512.c │ │ └── zeroize.c │ ├── hash.cpp │ ├── hash_number.cpp │ └── script_number.cpp ├── network │ ├── channel.cpp │ ├── handshake.cpp │ ├── hosts.cpp │ ├── network.cpp │ └── protocol.cpp ├── satoshi_serialize.cpp ├── script.cpp ├── stealth.cpp ├── transaction.cpp ├── utility │ ├── binary.cpp │ ├── general.cpp │ ├── logger.cpp │ ├── threadpool.cpp │ └── timed_section.cpp └── wallet │ ├── address.cpp │ ├── hd_keys.cpp │ ├── key_formats.cpp │ ├── message.cpp │ ├── mnemonic.cpp │ ├── stealth_address.cpp │ └── uri.cpp ├── test ├── .gitignore ├── base10.cpp ├── base16.cpp ├── base58.cpp ├── base64.cpp ├── base85.cpp ├── big_number.cpp ├── big_number.hpp ├── checksum.cpp ├── config.cpp ├── ec_keys.cpp ├── format.cpp ├── hash.cpp ├── hash.hpp ├── hash_number.cpp ├── hd_keys.cpp ├── key_formats.cpp ├── main.cpp ├── message.cpp ├── parameter.cpp ├── printer.cpp ├── satoshi_words.cpp ├── script.cpp ├── script.hpp ├── script_number.cpp ├── script_number.hpp ├── serialize.cpp ├── stealth.cpp ├── stealth_address.cpp └── uri.cpp ├── version └── version.hpp /.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | .libs 3 | *.la 4 | *.lo 5 | *.o 6 | *.pyc 7 | Makefile 8 | Makefile.in 9 | libbitcoin.pc 10 | 11 | bin 12 | obj 13 | .*.swp 14 | *~ 15 | /*.kdev4 16 | /.cproject 17 | /.project 18 | /.settings 19 | /nbproject 20 | 21 | /aclocal.m4 22 | /autom4te.cache 23 | /build-aux 24 | /config.* 25 | /configure 26 | /libtool 27 | .dirstamp 28 | libbitcoin_1.0.10-1_amd64.deb 29 | 30 | /examples/accept 31 | /examples/balance 32 | /examples/connect 33 | /examples/determ 34 | /examples/display-last 35 | /examples/fullnode 36 | /examples/initchain 37 | /examples/priv 38 | /examples/proto 39 | /examples/satoshiwords 40 | /examples/txrad 41 | /examples/uri 42 | /examples/error.log 43 | /examples/debug.log 44 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Authors: 2 | 3 | * Robert Williamson 4 | Development. Added support for testnet. 5 | 6 | * Eric Voskuil 7 | Windows ports, OpenSSL removal, build and documentation updates. 8 | 9 | * William Swanson 10 | Android port and wallet code development. 11 | 12 | * Amir Taaki (genjix) 13 | Development 14 | amir@unsystem.net 15 | 16 | * Patrick Strateman (phantomcircuit) 17 | Development. Early contributor. 18 | 19 | * Denis Roio (jaromil) 20 | Hosting. 21 | 22 | Thanks: 23 | 24 | Kamil Domański (kdomanski) 25 | Jan Engelhardt (se7) 26 | 27 | Aaron Williamson (SFLC) and Richard Stallman (FSF) for the license, 28 | Luke Dashjr for pointing out OpenSSL license conflict. 29 | 30 | Pablo Castellano - Debian packaging 31 | -------------------------------------------------------------------------------- /HACKING: -------------------------------------------------------------------------------- 1 | Releasing 2 | ========= 3 | 4 | We use the git flow branching model, so you can assume that the code in the 5 | master branch is stable and the bleeding edge is in the develop branch. 6 | 7 | http://nvie.com/posts/a-successful-git-branching-model/ 8 | 9 | Style 10 | ===== 11 | 12 | See our style guide here: 13 | 14 | https://wiki.unsystem.net/index.php/Libbitcoin/Style 15 | 16 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | libbitcoin NEWS - History of user-visible changes. -*- outline -*- 2 | Copyright 2011 - present libbitcoin developers 3 | 4 | Version XXX - replace this as needed 5 | 6 | Version 2.x - Aug 2014, by Amir Taaki and Eric Voskuil 7 | 8 | * openssl no longer used inside libbitcoin. Replaced by libgmp-dev and 9 | libsecp256k1. openssl remains as a dependency for validation of test results. 10 | 11 | * elliptic_curve_key no longer used inside libbitcoin. Replaced by 12 | the new ec_keys class, which is based on libsecp256k1. elliptic_curve_key 13 | now lives in test as a means to compare the test results against the new 14 | implementation. 15 | 16 | Version 2.0 - Jan 2014, by Amir Taaki 17 | 18 | * Migrated crypto stuff to new library libwallet. 19 | 20 | * Rework protocol code to have fixed connection slots. 21 | 22 | * tools/detect-network to see network libbitcoin is compiled for. 23 | 24 | * bootstrap blockchain from .dat tool. 25 | 26 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/libbitcoin-system-Google-Colab/4526ba69ae9700d19deada2e4f6b88a47129314c/README -------------------------------------------------------------------------------- /archive/README: -------------------------------------------------------------------------------- 1 | These directories are not built and currently held for reference purposes. 2 | 3 | The examples (tx_radar.cpp and protocol) remain valid but are not yet incorporated into a make target. -------------------------------------------------------------------------------- /archive/hash_data/README.md: -------------------------------------------------------------------------------- 1 | $ python generate.py > vectors.hpp 2 | 3 | -------------------------------------------------------------------------------- /archive/hash_data/generate.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | import random 3 | import sys 4 | 5 | def random_bytes(): 6 | result = "" 7 | for i in range(random.randint(0, 50)): 8 | result += chr(random.randint(0, 255)) 9 | return result 10 | 11 | def generate(name, hashfunc): 12 | print "hash_result_list %s_tests{{" % name 13 | output_row = lambda bytes, result: \ 14 | ' {"%s", "%s"}' % (bytes.encode("hex"), result) 15 | sys.stdout.write(output_row("", hashfunc(""))) 16 | for i in range(20): 17 | print "," 18 | bytes = random_bytes() 19 | result = hashfunc(bytes) 20 | sys.stdout.write(output_row(bytes, result)) 21 | print 22 | print "}};" 23 | print 24 | 25 | def sha1(data): 26 | return hashlib.sha1(data).hexdigest() 27 | 28 | def sha256(data): 29 | return hashlib.sha256(data).hexdigest() 30 | 31 | def ripemd(data): 32 | hasher = hashlib.new("ripemd160") 33 | hasher.update(data) 34 | return hasher.hexdigest() 35 | 36 | def main(): 37 | print "#include " 38 | print "#include " 39 | print 40 | print "struct hash_result" 41 | print "{" 42 | print " std::string input, result;" 43 | print "};" 44 | print 45 | print "typedef std::vector hash_result_list;" 46 | print 47 | generate("sha1", sha1) 48 | generate("sha256", sha256) 49 | generate("ripemd", ripemd) 50 | 51 | if __name__ == "__main__": 52 | main() 53 | 54 | -------------------------------------------------------------------------------- /archive/oldtests/1vaynert.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace bc; 22 | 23 | int start_time; 24 | 25 | void blockchain_started(const std::error_code& ec, blockchain_ptr) 26 | { 27 | if (ec) 28 | log_error() << ec.message(); 29 | else 30 | log_info() << "Blockchain initialized!"; 31 | } 32 | 33 | void handle_fetch(const std::error_code& ec, 34 | const message::output_point_list& outpoints) 35 | { 36 | log_info() << "Fetch: " << ec.message() 37 | << " (" << (time(nullptr) - start_time) << " seconds)"; 38 | } 39 | 40 | int main() 41 | { 42 | threadpool pool(1); 43 | blockchain_ptr chain = 44 | bdb_blockchain::create(pool, "database", blockchain_started); 45 | payment_address address("1VayNert3x1KzbpzMGt2qdqrAThiRovi8"); 46 | start_time = time(nullptr); 47 | chain->fetch_outputs(address, handle_fetch); 48 | std::cin.get(); 49 | return 0; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /archive/oldtests/addr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | using namespace libbitcoin; 23 | 24 | int main() 25 | { 26 | payment_address addr; 27 | set_public_key(addr, { 28 | 0x04, 0xa3, 0x9b, 0x9e, 0x4f, 0xbd, 0x21, 0x3e, 29 | 0xf2, 0x4b, 0xb9, 0xbe, 0x69, 0xde, 0x4a, 0x11, 30 | 0x8d, 0xd0, 0x64, 0x40, 0x82, 0xe4, 0x7c, 0x01, 31 | 0xfd, 0x91, 0x59, 0xd3, 0x86, 0x37, 0xb8, 0x3f, 32 | 0xbc, 0xdc, 0x11, 0x5a, 0x5d, 0x6e, 0x97, 0x05, 33 | 0x86, 0xa0, 0x12, 0xd1, 0xcf, 0xe3, 0xe3, 0xa8, 34 | 0xb1, 0xa3, 0xd0, 0x4e, 0x76, 0x3b, 0xdc, 0x5a, 35 | 0x07, 0x1c, 0x0e, 0x82, 0x7c, 0x0b, 0xd8, 0x34, 36 | 0xa5}); 37 | BITCOIN_ASSERT(addr.encoded() == "1VayNert3x1KzbpzMGt2qdqrAThiRovi8"); 38 | 39 | payment_address addr1; 40 | set_public_key_hash(addr1, short_hash{ 41 | 0x3a, 0x77, 0x5c, 0x1d, 0x2e, 0xb6, 0x12, 0x3b, 42 | 0xc7, 0x74, 0xcf, 0xcb, 0xee, 0xb9, 0xdd, 0xc3, 43 | 0x01, 0x79, 0x41, 0x6e}); 44 | BITCOIN_ASSERT(addr1.encoded() == "16L9BPjFJ1zbVzpoxGrNrkQea6xL9optR7"); 45 | 46 | payment_address addr2; 47 | addr2.set_encoded("16L9BPjFJ1zbVzpoxGrNrkQea6xL9optR7"); 48 | BITCOIN_ASSERT((addr2.hash() == short_hash{ 49 | 0x3a, 0x77, 0x5c, 0x1d, 0x2e, 0xb6, 0x12, 0x3b, 50 | 0xc7, 0x74, 0xcf, 0xcb, 0xee, 0xb9, 0xdd, 0xc3, 51 | 0x01, 0x79, 0x41, 0x6e})); 52 | BITCOIN_ASSERT(addr2.type() == payment_type::pubkey_hash); 53 | return 0; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /archive/oldtests/bdb-last.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace libbitcoin; 22 | 23 | void show_last(const std::error_code& ec, size_t last_height) 24 | { 25 | if (ec) 26 | { 27 | log_fatal() << ec.message(); 28 | return; 29 | } 30 | log_info() << "Last block height: " << last_height; 31 | } 32 | 33 | void blockchain_started(const std::error_code& ec) 34 | { 35 | if (ec) 36 | log_error() << ec.message(); 37 | else 38 | log_info() << "Blockchain initialized!"; 39 | } 40 | 41 | int main() 42 | { 43 | threadpool pool(1); 44 | leveldb_blockchain chain(pool); 45 | chain.start("database", blockchain_started); 46 | chain.fetch_last_height(show_last); 47 | std::cin.get(); 48 | pool.stop(); 49 | pool.join(); 50 | chain.stop(); 51 | return 0; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /archive/oldtests/big-number-test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace bc; 22 | 23 | void test() 24 | { 25 | big_number bignum; 26 | bignum.set_compact(0x1b0404cb); 27 | BITCOIN_ASSERT((bignum.hash() == hash_digest{0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0xCB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); 28 | 29 | big_number bignum_max; 30 | bignum_max.set_compact(0x1d00ffff); 31 | BITCOIN_ASSERT((bignum_max.hash() == hash_digest{0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); 32 | BITCOIN_ASSERT(bignum_max.compact() == 0x1d00ffff); 33 | 34 | BITCOIN_ASSERT(bignum < bignum_max); 35 | 36 | big_number other; 37 | other.set_hash(bignum.hash()); 38 | BITCOIN_ASSERT(other.data() == bignum.data()); 39 | 40 | BITCOIN_ASSERT(bignum_max <= libbitcoin::max_target()); 41 | BITCOIN_ASSERT(bignum < libbitcoin::max_target()); 42 | 43 | big_number arith, oper; 44 | arith.set_uint64(0x1f1f1f1f1f1f); 45 | oper.set_uint64(0x1f1f1f1f1f1f); 46 | arith *= oper; 47 | //BITCOIN_ASSERT((arith.data() == data_chunk{0x03, 0xc8, 0x8d, 0x52, 0x16, 0xdb, 0x98, 0xd4, 0x0f, 0x4a, 0x85, 0xc1})); 48 | 49 | big_number a, b; 50 | a.set_data({0x70}); 51 | b.set_data({0x0c}); 52 | BITCOIN_ASSERT(big_number(a - b) == 100); 53 | BITCOIN_ASSERT((big_number(a - b).data() == data_chunk{100})); 54 | } 55 | 56 | int main() 57 | { 58 | test(); 59 | return 0; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /archive/oldtests/bip16/hachem.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace bc; 22 | 23 | extern data_chunk raw_block44987; 24 | extern data_chunk raw_block44989; 25 | 26 | int main() 27 | { 28 | satoshi_exporter ex; 29 | const message::block& block44987 = ex.load_block(raw_block44987); 30 | const message::block& block44989 = ex.load_block(raw_block44989); 31 | 32 | const auto& tx_a = block44987.transactions[1]; 33 | const auto& tx_b = block44989.transactions[16]; 34 | 35 | auto output_script = tx_a.outputs[1].output_script; 36 | auto input_script = tx_b.inputs[0].input_script; 37 | 38 | log_debug() << output_script.pretty(); 39 | log_debug(); 40 | log_debug() << input_script.pretty(); 41 | 42 | if (output_script.type() == payment_type::script_hash) 43 | log_debug() << "scrhash"; 44 | 45 | if (output_script.run(input_script, tx_b, 0)) 46 | log_debug() << "pass"; 47 | return 0; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /archive/oldtests/bip16/make.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 4 | # 5 | # This file is part of libbitcoin. 6 | # 7 | # libbitcoin is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License with 9 | # additional permissions to the one published by the Free Software 10 | # Foundation, either version 3 of the License, or (at your option) 11 | # any later version. For more information see LICENSE. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | g++ hachem.cpp raw_block4498*.o `pkg-config --libs --cflags libbitcoin` 22 | -------------------------------------------------------------------------------- /archive/oldtests/block-hash.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | using namespace bc; 23 | 24 | void recv_block(std::error_code ec, message::block block) 25 | { 26 | if (ec) 27 | { 28 | std::cerr << ec.message() << "\n"; 29 | return; 30 | } 31 | std::cout << "version: " << block.version << "\n"; 32 | std::cout << "timestamp: " << block.timestamp << "\n"; 33 | std::cout << "bits: " << std::hex << block.bits << std::dec << "\n"; 34 | std::cout << "nonce: " << block.nonce << "\n"; 35 | BITCOIN_ASSERT((hash_block_header(block) == hash_digest{0x00, 0x00, 0x00, 0x00, 0xd1, 0x14, 0x57, 0x90, 0xa8, 0x69, 0x44, 0x03, 0xd4, 0x06, 0x3f, 0x32, 0x3d, 0x49, 0x9e, 0x65, 0x5c, 0x83, 0x42, 0x68, 0x34, 0xd4, 0xce, 0x2f, 0x8d, 0xd4, 0xa2, 0xee})); 36 | BITCOIN_ASSERT(block.transactions.size() == 2); 37 | std::cout << "\n"; 38 | for (message::transaction tx: block.transactions) 39 | std::cout << pretty(tx); 40 | } 41 | 42 | void loc(const std::error_code& ec, const message::block_locator& ll) 43 | { 44 | if (ec) 45 | log_error() << ec.message(); 46 | else 47 | for (auto h: ll) 48 | log_debug() << h; 49 | } 50 | 51 | void blockchain_started(const std::error_code& ec) 52 | { 53 | if (ec) 54 | log_info() << "Blockchain error"; 55 | else 56 | log_info() << "Blockchain initialized!"; 57 | } 58 | 59 | int main() 60 | { 61 | threadpool pool(1); 62 | bdb_blockchain chain(pool); 63 | chain.start("database", blockchain_started); 64 | //fetch_block(chain, 170, recv_block); 65 | fetch_block_locator(chain, loc); 66 | 67 | //indices_list ind = block_locator_indices(100); 68 | //for (size_t i: ind) 69 | // log_debug() << i; 70 | std::cin.get(); 71 | pool.stop(); 72 | pool.join(); 73 | chain.stop(); 74 | return 0; 75 | } 76 | 77 | -------------------------------------------------------------------------------- /archive/oldtests/chanstop.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace libbitcoin; 22 | 23 | using std::placeholders::_1; 24 | using std::placeholders::_2; 25 | 26 | channel_ptr channode; 27 | 28 | void error_exit(const std::string& message, int status=1) 29 | { 30 | log_error() << "net: " << message; 31 | exit(status); 32 | } 33 | 34 | void handle_send(const std::error_code& ec) 35 | { 36 | if (ec) 37 | error_exit(ec.message()); 38 | log_info() << "handle_send"; 39 | } 40 | 41 | void handle_stop(const std::error_code& ec) 42 | { 43 | if (ec) 44 | log_error() << "Stopped: " << ec.message(); 45 | log_info() << "Channel stopped."; 46 | channode->send(message::verack(), handle_send); 47 | } 48 | 49 | void handle_handshake(const std::error_code& ec, channel_ptr node, 50 | handshake_ptr hs) 51 | { 52 | if (ec) 53 | error_exit(ec.message()); 54 | log_info() << "Connected"; 55 | channode = node; 56 | node->subscribe_stop(handle_stop); 57 | } 58 | void handle_init(const std::error_code& ec, handshake_ptr hs, network_ptr net) 59 | { 60 | if (ec) 61 | error_exit(ec.message()); 62 | hs->connect(net, "localhost", 8333, 63 | std::bind(&handle_handshake, _1, _2, hs)); 64 | } 65 | 66 | int main() 67 | { 68 | network_ptr net = std::make_shared(); 69 | handshake_ptr hs = std::make_shared(); 70 | hs->start(std::bind(handle_init, _1, hs, net)); 71 | std::cin.get(); 72 | return 0; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /archive/oldtests/checksig.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace bc; 22 | 23 | void error_exit(const std::string& message, int status=1) 24 | { 25 | log_error() << "session: " << message; 26 | exit(status); 27 | } 28 | 29 | void blockchain_started(const std::error_code& ec) 30 | { 31 | if (ec) 32 | error_exit(ec.message()); 33 | else 34 | log_info() << "Blockchain initialized!"; 35 | } 36 | 37 | void test_checksig(const std::error_code& ec, 38 | const message::transaction& tx) 39 | { 40 | if (ec) 41 | error_exit(ec.message()); 42 | script output_script; 43 | output_script.push_operation({opcode::dup, data_chunk()}); 44 | output_script.push_operation({opcode::hash160, data_chunk()}); 45 | output_script.push_operation({opcode::special, 46 | data_chunk{0xcb, 0xf0, 0x3d, 0x35, 0x8d, 0xbb, 0xea, 0x55, 47 | 0x97, 0x82, 0xbe, 0x77, 0xb5, 0xf2, 0xb4, 0x3e, 48 | 0xd3, 0xdf, 0xda, 0x24}}); 49 | output_script.push_operation({opcode::equalverify, data_chunk()}); 50 | output_script.push_operation({opcode::checksig, data_chunk()}); 51 | 52 | if (output_script.run(tx.inputs[0].input_script, tx, 0)) 53 | log_info() << "SUCCESS"; 54 | else 55 | log_info() << "FAILURE"; 56 | } 57 | 58 | int main() 59 | { 60 | threadpool pool(1); 61 | bdb_blockchain chain(pool); 62 | chain.start("database", blockchain_started); 63 | chain.fetch_transaction( 64 | hash_digest{0xd2, 0xb5, 0x46, 0x8c, 0xbd, 0x19, 0x4d, 0x7e, 65 | 0x0d, 0xbe, 0xd4, 0x00, 0xdc, 0x75, 0x0a, 0x79, 66 | 0x76, 0x0a, 0x85, 0x59, 0x2b, 0x7b, 0x9b, 0xf7, 67 | 0xe4, 0x11, 0xa8, 0x32, 0x68, 0x9b, 0xe7, 0x36}, 68 | test_checksig); 69 | std::cin.get(); 70 | pool.stop(); 71 | pool.join(); 72 | chain.stop(); 73 | return 0; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /archive/oldtests/clock-test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | using namespace libbitcoin; 23 | 24 | int main() 25 | { 26 | chrono_clock c; 27 | log_debug() << c.time(); 28 | return 0; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /archive/oldtests/determ.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace bc; 22 | 23 | int main() 24 | { 25 | deterministic_wallet wallet; 26 | bool set_seed_success = 27 | wallet.set_seed("a219213f9b12422aa206d988e3e49607"); 28 | BITCOIN_ASSERT(set_seed_success); 29 | // master public key 30 | data_chunk mpk = wallet.master_public_key(); 31 | log_info() << "mpk: " << mpk; 32 | BITCOIN_ASSERT(encode_hex(mpk) == "d996c1a50ca4a57a9dface614338a1d837cb339e08361cfaf66ffd7da8e21786a7142a014056439d579654d7bb58dd5724b93372b5efae62e76783300f2b6cb5"); 33 | // get an address 34 | payment_address addr; 35 | data_chunk pubkey = wallet.generate_public_key(2, true); 36 | bool set_pubkey_success = set_public_key(addr, pubkey); 37 | BITCOIN_ASSERT(set_pubkey_success); 38 | log_info() << addr.encoded(); 39 | BITCOIN_ASSERT(addr.encoded() == "1MstsXwLK8pH7jxpG5HYettWVPSUxwdwgY"); 40 | // get privkey 41 | secret_parameter secret = wallet.generate_secret(2, true); 42 | log_info() << "secret: " << secret; 43 | BITCOIN_ASSERT(encode_hex(secret) == "d5c41f9c49ecbe48eb6fad73f6bc4a795dd1698813892cb0eeaa8362f85c83bc"); 44 | elliptic_curve_key privkey; 45 | bool set_secret_success = privkey.set_secret(secret); 46 | BITCOIN_ASSERT(set_secret_success); 47 | BITCOIN_ASSERT(privkey.public_key() == pubkey); 48 | // new seed 49 | wallet.new_seed(); 50 | log_info() << "new seed: " << wallet.seed(); 51 | 52 | deterministic_wallet wallet2; 53 | wallet2.set_master_public_key(mpk); 54 | BITCOIN_ASSERT(wallet2.generate_public_key(2, true) == pubkey); 55 | BITCOIN_ASSERT(wallet2.generate_secret(2) == null_hash); 56 | return 0; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /archive/oldtests/fork-blks/README: -------------------------------------------------------------------------------- 1 | use feeder to switch blkspec with blk0 blk1, and see blockchain reorg in action. 2 | 3 | -------------------------------------------------------------------------------- /archive/oldtests/hosts-test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace libbitcoin; 22 | 23 | threadpool s; 24 | hosts_ptr h = std::make_shared(s); 25 | 26 | void handle_store(const std::error_code& ec) 27 | { 28 | if (ec) 29 | { 30 | log_fatal() << ec.message(); 31 | return; 32 | } 33 | log_info() << "fone"; 34 | } 35 | 36 | void handle_fetch(const std::error_code& ec, 37 | const message::network_address& netaddr) 38 | { 39 | if (ec) 40 | { 41 | log_fatal() << ec.message(); 42 | return; 43 | } 44 | log_debug() << encode_hex(netaddr.ip) << ' ' << netaddr.port; 45 | } 46 | 47 | int main() 48 | { 49 | //for (uint8_t i1 = 0; i1 < 10; ++i1) 50 | //{ 51 | // for (uint8_t i2 = 0; i2 < 10; ++i2) 52 | // { 53 | // for (uint8_t i3 = 0; i3 < 10; ++i3) 54 | // { 55 | // for (uint8_t i4 = 0; i4 < 26; ++i4) 56 | // { 57 | // message::network_address netaddr; 58 | // netaddr.ip = 59 | // message::ip_address{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 60 | // 0x00, 0x00, 0xff, 0xff, i1, i2, i3, i4}; 61 | // netaddr.port = 8444; 62 | // h->store(netaddr, handle_store); 63 | // } 64 | // } 65 | // } 66 | //} 67 | h->load("hosts", handle_store); 68 | log_info() << "hello"; 69 | h->fetch_address(handle_fetch); 70 | sleep(2); 71 | h->save("hosts1", handle_store); 72 | std::cin.get(); 73 | return 0; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /archive/oldtests/irc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | 23 | void handler(const std::error_code& ec, const std::string hostname) 24 | { 25 | if (ec) 26 | { 27 | libbitcoin::log_fatal() << ec.message(); 28 | exit(-1); 29 | } 30 | 31 | libbitcoin::log_info() << "Got new client: " << hostname; 32 | } 33 | 34 | int main() 35 | { 36 | std::shared_ptr disc = std::make_shared(); 37 | disc->irc_discovery(&handler); 38 | while (std::cin.get() != -1); 39 | } 40 | -------------------------------------------------------------------------------- /archive/oldtests/kyot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace bc; 22 | 23 | void bb(const std::error_code& ec, const message::block& blkhead) 24 | { 25 | log_debug() << ec.message(); 26 | log_debug() << hash_block_header(blkhead); 27 | } 28 | 29 | void blockchain_started(const std::error_code& ec, blockchain_ptr chain, bool isnew) 30 | { 31 | if (ec) 32 | log_error() << ec.message(); 33 | else 34 | log_info() << "Blockchain initialized! " << isnew; 35 | chain->fetch_block_header(0, bb); 36 | } 37 | 38 | int main() 39 | { 40 | threadpool pool(10); 41 | blockchain_ptr chain = 42 | kyoto_blockchain::create(pool, "kydb", blockchain_started); 43 | std::cin.get(); 44 | return 0; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /archive/oldtests/logtst.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace bc; 22 | 23 | void output(log_level level, const std::string& domain, const std::string& body) 24 | { 25 | constexpr size_t lvl_spaces = 7; 26 | constexpr size_t domain_spaces = 10; 27 | if (body.empty()) 28 | return; 29 | std::cout << "["; 30 | std::string lvlrep = level_repr(level); 31 | std::cout << lvlrep; 32 | BITCOIN_ASSERT(lvlrep.size() <= lvl_spaces); 33 | for (size_t i = 0; i < (lvl_spaces - lvlrep.size()); ++i) 34 | std::cout << " "; 35 | std::cout << "] "; 36 | if (!domain.empty()) 37 | { 38 | BITCOIN_ASSERT(domain.size() <= domain_spaces); 39 | std::cout << "[" << domain; 40 | for (size_t i = 0; i < (domain_spaces - domain.size()); ++i) 41 | std::cout << " "; 42 | std::cout << "] "; 43 | } 44 | std::cout << body << std::endl; 45 | } 46 | 47 | int main() 48 | { 49 | log_debug().set_output_function(output); 50 | log_info().set_output_function(output); 51 | log_warning().set_output_function(output); 52 | log_error().set_output_function(output); 53 | log_fatal().set_output_function(output); 54 | 55 | log_debug(LOG_PROTOCOL) << "Connected to 500 nodes."; 56 | log_warning(LOG_BLOCKCHAIN) << "Couldn't start blockchain."; 57 | return 0; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /archive/oldtests/memcheck/begin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace bc; 22 | 23 | int main() 24 | { 25 | elliptic_curve_key ec; 26 | return 0; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /archive/oldtests/memcheck/curl.supp: -------------------------------------------------------------------------------- 1 | { 2 | libcurl 3 | Memcheck:Leak 4 | ... 5 | fun:curl_easy_init 6 | ... 7 | } 8 | { 9 | Ignore OpenSSL malloc 10 | Memcheck:Leak 11 | fun:malloc 12 | fun:CRYPTO_malloc 13 | ... 14 | obj:*libcrypto* 15 | } 16 | { 17 | Ignore OpenSSL realloc 18 | Memcheck:Leak 19 | fun:realloc 20 | fun:CRYPTO_realloc 21 | ... 22 | obj:*libcrypto* 23 | } 24 | 25 | -------------------------------------------------------------------------------- /archive/oldtests/memcheck/make.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 4 | # 5 | # This file is part of libbitcoin. 6 | # 7 | # libbitcoin is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License with 9 | # additional permissions to the one published by the Free Software 10 | # Foundation, either version 3 of the License, or (at your option) 11 | # any later version. For more information see LICENSE. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | g++ begin.cpp `pkg-config --cflags --libs libbitcoin` 22 | valgrind --tool=memcheck --leak-check=yes ./a.out 23 | 24 | -------------------------------------------------------------------------------- /archive/oldtests/pol.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace libbitcoin; 22 | 23 | using std::placeholders::_1; 24 | using std::placeholders::_2; 25 | 26 | void start_polling(const std::error_code& ec, channel_ptr node, 27 | poller& poll) 28 | { 29 | if (ec) 30 | { 31 | log_fatal() << "error: " << ec.message(); 32 | return; 33 | } 34 | poll.query(node); 35 | poll.monitor(node); 36 | } 37 | 38 | void blockchain_started(const std::error_code& ec) 39 | { 40 | if (ec) 41 | log_fatal() << "error: " << ec.message(); 42 | else 43 | log_info() << "Blockchain initialized!"; 44 | } 45 | 46 | int main() 47 | { 48 | //bdb_blockchain::setup("database"); 49 | threadpool s1(1), s2(1); 50 | bdb_blockchain chain(s1); 51 | chain.start("database", blockchain_started); 52 | poller poll(s2, chain); 53 | network net(s2); 54 | handshake hs(s2); 55 | connect(hs, net, "localhost", 8333, 56 | std::bind(start_polling, _1, _2, std::ref(poll))); 57 | std::cin.get(); 58 | s1.stop(); 59 | s2.stop(); 60 | s1.join(); 61 | s2.join(); 62 | chain.stop(); 63 | return 0; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /archive/oldtests/priv.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace bc; 22 | 23 | int main() 24 | { 25 | elliptic_curve_key ec; 26 | ec.new_key_pair(); 27 | private_data raw_private_key = ec.private_key(); 28 | std::cout << std::string(raw_private_key.begin(), raw_private_key.end()); 29 | return 0; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /archive/oldtests/protst.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace libbitcoin; 22 | 23 | protocol* prot; 24 | 25 | void error_exit(const std::error_code& ec) 26 | { 27 | log_fatal() << "Error: " << ec.message(); 28 | exit(-1); 29 | } 30 | 31 | void handle_stop(const std::error_code& ec) 32 | { 33 | if (ec) 34 | error_exit(ec); 35 | log_debug() << "stopped"; 36 | } 37 | void handle_start(const std::error_code& ec) 38 | { 39 | if (ec) 40 | error_exit(ec); 41 | log_debug() << "started"; 42 | //prot->stop(handle_stop); 43 | } 44 | 45 | void display_num_conns(const std::error_code& ec, size_t num) 46 | { 47 | log_debug() << num << " CONNECTIONS"; 48 | } 49 | void mewcj(channel_ptr node) 50 | { 51 | log_debug() << "New channel!"; 52 | prot->subscribe_channel(mewcj); 53 | } 54 | 55 | int main() 56 | { 57 | threadpool pool(1); 58 | hosts hst(pool); 59 | handshake hs(pool); 60 | network net(pool); 61 | prot = new protocol(pool, hst, hs, net); 62 | prot->start(handle_start); 63 | prot->subscribe_channel(mewcj); 64 | //prot->bootstrap(handle_start); 65 | //std::cin.get(); 66 | //prot->stop(handle_stop); 67 | //log_debug() << "stopping."; 68 | std::cin.get(); 69 | //while (true) 70 | //{ 71 | // prot->fetch_connection_count(display_num_conns); 72 | // sleep(1); 73 | //} 74 | pool.stop(); 75 | pool.join(); 76 | delete prot; 77 | return 0; 78 | } 79 | 80 | -------------------------------------------------------------------------------- /archive/oldtests/serial-test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | using namespace libbitcoin; 22 | 23 | int main() 24 | { 25 | data_chunk rawdat(decode_hex("46682488f0a721124a3905a1bb72445bf13493e2cd46c5c0c8db1c15afa0d58e00000000")); 26 | BITCOIN_ASSERT((rawdat == data_chunk{0x46, 0x68, 0x24, 0x88, 0xf0, 0xa7, 0x21, 0x12, 0x4a, 0x39, 0x05, 0xa1, 0xbb, 0x72, 0x44, 0x5b, 0xf1, 0x34, 0x93, 0xe2, 0xcd, 0x46, 0xc5, 0xc0, 0xc8, 0xdb, 0x1c, 0x15, 0xaf, 0xa0, 0xd5, 0x8e, 0x00, 0x00, 0x00, 0x00})); 27 | auto deserial = make_deserializer(rawdat.begin(), rawdat.end()); 28 | output_point outpoint; 29 | outpoint.hash = deserial.read_hash(); 30 | outpoint.index = deserial.read_4_bytes(); 31 | log_debug() << encode_hex(outpoint.hash) << " : " << outpoint.index; 32 | BITCOIN_ASSERT((outpoint.hash == hash_digest{0x8e, 0xd5, 0xa0, 0xaf, 0x15, 0x1c, 0xdb, 0xc8, 0xc0, 0xc5, 0x46, 0xcd, 0xe2, 0x93, 0x34, 0xf1, 0x5b, 0x44, 0x72, 0xbb, 0xa1, 0x05, 0x39, 0x4a, 0x12, 0x21, 0xa7, 0xf0, 0x88, 0x24, 0x68, 0x46})); 33 | BITCOIN_ASSERT(outpoint.index == 0); 34 | data_chunk buff(36); 35 | auto serial = make_serializer(buff.begin()); 36 | serial.write_hash(outpoint.hash); 37 | serial.write_4_bytes(outpoint.index); 38 | BITCOIN_ASSERT(buff == rawdat); 39 | return 0; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /archive/oldtests/subscribe.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | using boost::asio::io_service; 23 | #include 24 | //#include 25 | #include "../include/bitcoin/utility/subscriber.hpp" 26 | #include 27 | using namespace libbitcoin; 28 | 29 | namespace libbitcoin { 30 | 31 | struct abc 32 | { 33 | abc(size_t x) 34 | : x(x) 35 | { 36 | log_error() << "abc()"; 37 | } 38 | ~abc() 39 | { 40 | log_error() << "~abc()"; 41 | } 42 | size_t x; 43 | }; 44 | 45 | } 46 | 47 | void foo(abc_ptr a) 48 | { 49 | log_debug() << "fii " << (a ? "y" : "n"); 50 | log_debug() << "Weeeee #" << a->x; 51 | } 52 | 53 | typedef std::function example_handler_type; 54 | typedef std::shared_ptr> subscribe_ver_ptr; 55 | 56 | void defer_sub(subscribe_ver_ptr s, example_handler_type f) 57 | { 58 | s->subscribe(f); 59 | s->subscribe(f); 60 | } 61 | 62 | void callall(subscribe_ver_ptr s) 63 | { 64 | abc_ptr a = std::make_shared(110); 65 | s->relay(a); 66 | } 67 | 68 | int main() 69 | { 70 | threadpool pool(1); 71 | io_service::strand str(pool.service()); 72 | auto sub = std::make_shared>(str); 73 | str.post(std::bind(defer_sub, sub, foo)); 74 | str.post(std::bind(callall, sub)); 75 | std::cin.get(); 76 | return 0; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /archive/oldtests/types-test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | #include 23 | using namespace libbitcoin; 24 | 25 | int main() 26 | { 27 | data_chunk bs; 28 | // 0 f2 5 2a 1 0 0 0 29 | bs.push_back(0x00); 30 | bs.push_back(0xf2); 31 | bs.push_back(0x05); 32 | bs.push_back(0x2a); 33 | bs.push_back(0x01); 34 | bs.push_back(0x00); 35 | bs.push_back(0x00); 36 | bs.push_back(0x00); 37 | 38 | uint64_t val = from_little_endian(bs.begin()); 39 | std::cout << val << "\n"; 40 | std::cout << std::hex << val << "\n"; 41 | 42 | std::reverse(bs.begin(), bs.end()); 43 | val = 0; 44 | for (size_t i = 0; i < bs.size(); i++) 45 | { 46 | val += static_cast(bs[i]) << (8*i); 47 | } 48 | 49 | std::cout << std::dec << val << "\n"; 50 | std::cout << std::hex << val << "\n"; 51 | return 0; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /archive/oldtests/verify-block.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | using std::shared_ptr; 29 | using libbitcoin::verify_block; 30 | typedef shared_ptr verify_block_ptr; 31 | using libbitcoin::postgresql_storage; 32 | using libbitcoin::satoshi_exporter; 33 | using libbitcoin::storage_ptr; 34 | using libbitcoin::exporter_ptr; 35 | 36 | using std::placeholders::_1; 37 | using std::placeholders::_2; 38 | 39 | void block_status(std::error_code ec, bool is_good) 40 | { 41 | if (ec) 42 | libbitcoin::log_error() << "Verifying block: " << ec.message() << "\n"; 43 | std::cout << "block is " << (is_good ? "good" : "bad") << "\n"; 44 | exit(0); 45 | } 46 | 47 | void recv_block(std::error_code ec, libbitcoin::message::block block, verify_block_ptr verif) 48 | { 49 | if (ec) 50 | { 51 | std::cerr << ec.message() << "\n"; 52 | return; 53 | } 54 | verif->start(block, block_status); 55 | } 56 | 57 | int main() 58 | { 59 | storage_ptr psql(new postgresql_storage("bitcoin", "genjix", "")); 60 | exporter_ptr exporter(new satoshi_exporter); 61 | verify_block_ptr verif(new verify_block(psql, exporter)); 62 | psql->fetch_block_by_height(2, std::bind(recv_block, _1, _2, verif)); 63 | std::cin.get(); 64 | return 0; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /archive/script_json/README.md: -------------------------------------------------------------------------------- 1 | $ python build_vectors.py > vectors.hpp 2 | 3 | -------------------------------------------------------------------------------- /archive/script_json/build_vectors.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 4 | # 5 | # This file is part of libbitcoin. 6 | # 7 | # libbitcoin is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License with 9 | # additional permissions to the one published by the Free Software 10 | # Foundation, either version 3 of the License, or (at your option) 11 | # any later version. For more information see LICENSE. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | import json 22 | import sys 23 | 24 | def display_scripts(json_path): 25 | with open(json_path) as f: 26 | tests = json.loads(f.read()) 27 | is_first = True 28 | for test in tests: 29 | if not is_first: 30 | print "," 31 | is_first = False 32 | input = test[0] 33 | output = test[1] 34 | description = "" 35 | if len(test) == 3: 36 | description = test[2] 37 | sys.stdout.write(' {"%s", "%s", "%s"}' % ( 38 | input, output, description)) 39 | print 40 | 41 | def main(): 42 | print "#include " 43 | print "#include " 44 | print 45 | print "struct script_test" 46 | print "{" 47 | print " std::string input, output, description;" 48 | print "};" 49 | print 50 | print "typedef std::vector script_test_list;" 51 | print 52 | print "script_test_list valid_scripts{{" 53 | display_scripts("script_valid.json") 54 | print "}};" 55 | print 56 | print "script_test_list invalid_scripts{{" 57 | display_scripts("script_invalid.json") 58 | print "}};" 59 | 60 | if __name__ == "__main__": 61 | main() 62 | 63 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | autoreconf -i 3 | 4 | -------------------------------------------------------------------------------- /builds/msvc/.gitignore: -------------------------------------------------------------------------------- 1 | *.suo 2 | *.opensdf 3 | *.sdf 4 | *.log 5 | *.aps 6 | *.user -------------------------------------------------------------------------------- /builds/msvc/build/buildall.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | ECHO. 3 | ECHO Downloading libbitcoin dependencies from NuGet 4 | CALL nuget.exe install ..\vs2013\libbitcoin\packages.config 5 | CALL nuget.exe install ..\vs2013\libbitcoin-test\packages.config 6 | ECHO. 7 | CALL buildbase.bat ..\vs2013\libbitcoin.sln 12 8 | ECHO. 9 | PAUSE -------------------------------------------------------------------------------- /builds/msvc/build/buildbase.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | REM Usage: [buildbase.bat ..\vs2013\mysolution.sln 12] 3 | 4 | SET solution=%1 5 | SET version=%2 6 | SET log=build_%version%.log 7 | SET tools=Microsoft Visual Studio %version%.0\VC\vcvarsall.bat 8 | SET environment="%programfiles(x86)%\%tools%" 9 | IF NOT EXIST %environment% SET environment="%programfiles%\%tools%" 10 | IF NOT EXIST %environment% GOTO no_tools 11 | 12 | ECHO Building: %solution% 13 | 14 | CALL %environment% x86 > nul 15 | ECHO Platform=x86 16 | 17 | ECHO Configuration=StaticDebug 18 | msbuild /m /v:n /p:Configuration=StaticDebug /p:Platform=Win32 %solution% > %log% 19 | IF errorlevel 1 GOTO error 20 | ECHO Configuration=StaticRelease 21 | msbuild /m /v:n /p:Configuration=StaticRelease /p:Platform=Win32 %solution% >> %log% 22 | IF errorlevel 1 GOTO error 23 | 24 | CALL %environment% x86_amd64 > nul 25 | ECHO Platform=x64 26 | 27 | ECHO Configuration=StaticDebug 28 | msbuild /m /v:n /p:Configuration=StaticDebug /p:Platform=x64 %solution% >> %log% 29 | IF errorlevel 1 GOTO error 30 | ECHO Configuration=StaticRelease 31 | msbuild /m /v:n /p:Configuration=StaticRelease /p:Platform=x64 %solution% >> %log% 32 | IF errorlevel 1 GOTO error 33 | 34 | ECHO Complete: %solution% 35 | GOTO end 36 | 37 | :error 38 | ECHO *** ERROR, build terminated early, see: %log% 39 | GOTO end 40 | 41 | :no_tools 42 | ECHO *** ERROR, build tools not found: %tools% 43 | 44 | :end 45 | 46 | -------------------------------------------------------------------------------- /builds/msvc/properties/Common.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Common Settings 6 | Unicode 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | true 16 | UNICODE;_UNICODE;%(PreprocessorDefinitions) 17 | Level3 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /builds/msvc/properties/DLL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Dynamic Library 6 | dynamic 7 | .dll 8 | 9 | 10 | 11 | 12 | _DLL;_WINDLL;%(PreprocessorDefinitions) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /builds/msvc/properties/Debug.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <_PropertySheetDisplayName>Debug Settings 10 | Debug 11 | 12 | 13 | 14 | 15 | EnableFastChecks 16 | ProgramDatabase 17 | true 18 | Disabled 19 | _DEBUG;%(PreprocessorDefinitions) 20 | 21 | 22 | _DEBUG;%(PreprocessorDefinitions) 23 | 24 | 25 | true 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /builds/msvc/properties/DebugDEXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Debug Dynamic 6 | dynamic 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | MultiThreadedDebugDLL 17 | true 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /builds/msvc/properties/DebugDLL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Dynamic Debug Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | MultiThreadedDebugDLL 16 | true 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/DebugLEXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Debug Link Time Code Generation 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | MultiThreadedDebug 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/DebugLIB.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Static Debug Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | OldStyle 16 | MultiThreadedDebug 17 | true 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /builds/msvc/properties/DebugLTCG.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Static Debug Link Time Code Generation Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | OldStyle 16 | MultiThreadedDebug 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/DebugSEXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Debug Static 6 | static 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | MultiThreadedDebug 17 | true 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /builds/msvc/properties/EXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Application 6 | true 7 | 8 | 9 | 10 | 11 | _CONSOLE;%(PreprocessorDefinitions) 12 | 13 | 14 | Console 15 | 16 | 17 | -------------------------------------------------------------------------------- /builds/msvc/properties/LIB.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Static Library 6 | static 7 | .lib 8 | 9 | 10 | 11 | 12 | _LIB;%(PreprocessorDefinitions) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /builds/msvc/properties/LTCG.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Link Time Code Generation Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /builds/msvc/properties/Link.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Link Time Code Generation Settings 6 | ltcg 7 | 8 | 9 | 10 | 11 | true 12 | 13 | 14 | UseLinkTimeCodeGeneration 15 | 16 | 17 | true 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /builds/msvc/properties/Messages.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Build Messages 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /builds/msvc/properties/Output.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Output Settings 6 | 7 | $(ProjectDir)..\..\ 8 | $(ProjectDir)..\..\..\..\ 9 | $(ProjectDir)..\..\..\..\..\ 10 | $(ProjectDir)..\..\..\..\bin\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ 11 | $(ProjectDir)..\..\..\..\obj\$(TargetName)\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ 12 | $(OutDir) 13 | $(TargetName) 14 | $(TargetDir)$(TargetName)$(TargetExt) 15 | 16 | 17 | 18 | 19 | $(OutDir)$(TargetName).lib 20 | 21 | 22 | $(OutDir)$(TargetName).log 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /builds/msvc/properties/Release.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <_PropertySheetDisplayName>Release Settings 10 | Release 11 | false 12 | 13 | 14 | 15 | 16 | /Oy- %(AdditionalOptions) 17 | 18 | true 19 | true 20 | OnlyExplicitInline 21 | false 22 | MaxSpeed 23 | NDEBUG;%(PreprocessorDefinitions) 24 | 25 | 26 | NDEBUG;%(PreprocessorDefinitions) 27 | 28 | 29 | true 30 | 31 | true 32 | 33 | 34 | 35 | 36 | 37 | StreamingSIMDExtensions2 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /builds/msvc/properties/ReleaseDEXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Release Dynamic 6 | dynamic 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | MultiThreadedDebugDLL 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/ReleaseDLL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Dynamic Release Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | MultiThreadedDLL 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /builds/msvc/properties/ReleaseLEXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Release Link Time Code Generation 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | MultiThreaded 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/ReleaseLIB.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Static Release Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | MultiThreaded 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /builds/msvc/properties/ReleaseLTCG.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Static Release Link Time Code Generation Library 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | MultiThreaded 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /builds/msvc/properties/ReleaseSEXE.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Console Release Static 6 | static 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | MultiThreaded 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/Win32.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>x86 Settings 6 | 7 | 8 | 9 | 10 | WIN32;_WIN32;%(PreprocessorDefinitions) 11 | 12 | 13 | MachineX86 14 | 15 | 16 | /MACHINE:X86 %(AdditionalOptions) 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /builds/msvc/properties/x64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>x64 Settings 6 | 7 | 8 | 9 | 10 | 13 | WIN32;_WIN32;WIN64;_WIN64;%(PreprocessorDefinitions) 14 | 15 | 16 | MachineX64 17 | 18 | 19 | /MACHINE:X64 %(AdditionalOptions) 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /builds/msvc/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/libbitcoin-system-Google-Colab/4526ba69ae9700d19deada2e4f6b88a47129314c/builds/msvc/resource.h -------------------------------------------------------------------------------- /builds/msvc/resource.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/libbitcoin-system-Google-Colab/4526ba69ae9700d19deada2e4f6b88a47129314c/builds/msvc/resource.rc -------------------------------------------------------------------------------- /builds/msvc/vs2013/libbitcoin-test/libbitcoin-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /builds/msvc/vs2013/libbitcoin-test/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /builds/msvc/vs2013/libbitcoin.import.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /builds/msvc/vs2013/libbitcoin.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30723.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbitcoin", "libbitcoin\libbitcoin.vcxproj", "{39F60708-FF48-4C22-952D-43470866F684}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbitcoin-test", "libbitcoin-test\libbitcoin-test.vcxproj", "{51A424A9-2C12-4211-8D40-E49D1534C541}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | StaticDebug|Win32 = StaticDebug|Win32 13 | StaticDebug|x64 = StaticDebug|x64 14 | StaticRelease|Win32 = StaticRelease|Win32 15 | StaticRelease|x64 = StaticRelease|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {39F60708-FF48-4C22-952D-43470866F684}.StaticDebug|Win32.ActiveCfg = DebugLIB|Win32 19 | {39F60708-FF48-4C22-952D-43470866F684}.StaticDebug|Win32.Build.0 = DebugLIB|Win32 20 | {39F60708-FF48-4C22-952D-43470866F684}.StaticDebug|x64.ActiveCfg = DebugLIB|x64 21 | {39F60708-FF48-4C22-952D-43470866F684}.StaticDebug|x64.Build.0 = DebugLIB|x64 22 | {39F60708-FF48-4C22-952D-43470866F684}.StaticRelease|Win32.ActiveCfg = ReleaseLIB|Win32 23 | {39F60708-FF48-4C22-952D-43470866F684}.StaticRelease|Win32.Build.0 = ReleaseLIB|Win32 24 | {39F60708-FF48-4C22-952D-43470866F684}.StaticRelease|x64.ActiveCfg = ReleaseLIB|x64 25 | {39F60708-FF48-4C22-952D-43470866F684}.StaticRelease|x64.Build.0 = ReleaseLIB|x64 26 | {51A424A9-2C12-4211-8D40-E49D1534C541}.StaticDebug|Win32.ActiveCfg = DebugSEXE|Win32 27 | {51A424A9-2C12-4211-8D40-E49D1534C541}.StaticDebug|Win32.Build.0 = DebugSEXE|Win32 28 | {51A424A9-2C12-4211-8D40-E49D1534C541}.StaticDebug|x64.ActiveCfg = DebugSEXE|x64 29 | {51A424A9-2C12-4211-8D40-E49D1534C541}.StaticDebug|x64.Build.0 = DebugSEXE|x64 30 | {51A424A9-2C12-4211-8D40-E49D1534C541}.StaticRelease|Win32.ActiveCfg = ReleaseSEXE|Win32 31 | {51A424A9-2C12-4211-8D40-E49D1534C541}.StaticRelease|Win32.Build.0 = ReleaseSEXE|Win32 32 | {51A424A9-2C12-4211-8D40-E49D1534C541}.StaticRelease|x64.ActiveCfg = ReleaseSEXE|x64 33 | {51A424A9-2C12-4211-8D40-E49D1534C541}.StaticRelease|x64.Build.0 = ReleaseSEXE|x64 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /builds/msvc/vs2013/libbitcoin/libbitcoin.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PropertySheetDisplayName>Libbitcoin Library Common Settings 6 | AllRules.ruleset 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | $(RepoRoot)include\;%(AdditionalIncludeDirectories) 21 | 22 | 4996;%(DisableSpecificWarnings) 23 | false 24 | 25 | NOMINMAX;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) 26 | ENABLE_TESTNET;%(PreprocessorDefinitions) 27 | BC_DLL;%(PreprocessorDefinitions) 28 | BC_STATIC;%(PreprocessorDefinitions) 29 | 30 | 31 | 32 | 33 | 34 | 35 | static 36 | 37 | 38 | static 39 | 40 | 41 | static 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /builds/msvc/vs2013/libbitcoin/libbitcoin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /builds/msvc/vs2013/libbitcoin/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | libbitcoin0 (2.0.0+nmu1) unstable; urgency=low 2 | 3 | * Non-maintainer upload. 4 | * Initial release. 5 | Closes: bug#670701 6 | 7 | -- Pablo Castellano (Debian packages) Sun, 19 Mar 2014 01:44:00 +0100 8 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: libbitcoin0 2 | Section: libs 3 | Priority: optional 4 | Maintainer: Pablo Castellano 5 | Build-Depends: debhelper (>= 8.1.3~), pkg-config, autoconf, automake, autotools-dev, libtool, libboost-all-dev, libcurl4-openssl-dev, libleveldb-dev 6 | Standards-Version: 3.9.4 7 | Vcs-Git: https://github.com/libbitcoin/libbitcoin.git 8 | Vcs-Browser: https://github.com/libbitcoin/libbitcoin 9 | Homepage: http://libbitcoin.dyne.org/ 10 | 11 | Package: libbitcoin-dev 12 | Section: libdevel 13 | Architecture: any 14 | Depends: libbitcoin0 (= ${binary:Version}), ${misc:Depends} 15 | Description: Asynchronous C++ Bitcoin library - development files 16 | libbitcoin is a bitcoin library targeted towards high end use. The library 17 | places a heavy focus around asychronicity. This enables a big scope for 18 | future scalability as each component has its own thread pool. 19 | By increasing the number of threads for that component the library is able 20 | to scale outwards across CPU cores. This will be vital in the future as 21 | the demands of the bitcoin network grow. 22 | . 23 | Another core design principle is libbitcoin is not a framework, but a 24 | toolkit. Frameworks hinder development during the latter stages of a 25 | development cycle, enforce one style of coding and do not work well with 26 | other frameworks. By contrast, libbitcoin functions as an independent set 27 | of mutual components with no dependencies between them. 28 | . 29 | This package provides the development files (ie. includes, static library), 30 | that allow to build software which uses libbitcoin. 31 | 32 | Package: libbitcoin0 33 | Architecture: any 34 | Pre-Depends: ${misc:Pre-Depends} 35 | Depends: ${shlibs:Depends}, ${misc:Depends} 36 | Multi-Arch: same 37 | Description: Asynchronous C++ Bitcoin library 38 | libbitcoin is a bitcoin library targeted towards high end use. The library 39 | places a heavy focus around asychronicity. This enables a big scope for 40 | future scalability as each component has its own thread pool. 41 | By increasing the number of threads for that component the library is able 42 | to scale outwards across CPU cores. This will be vital in the future as 43 | the demands of the bitcoin network grow. 44 | . 45 | Another core design principle is libbitcoin is not a framework, but a 46 | toolkit. Frameworks hinder development during the latter stages of a 47 | development cycle, enforce one style of coding and do not work well with 48 | other frameworks. By contrast, libbitcoin functions as an independent set 49 | of mutual components with no dependencies between them. 50 | . 51 | This package contains the shared library for libbitcoin. 52 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: libbitcoin 3 | Source: https://github.com/libbitcoin/libbitcoin 4 | 5 | Files: * 6 | Copyright: 2011-2013 Amir Taaki (genjix) 7 | 2011-2012 Kamil Domański (kdomanski) 8 | 2011 Jan Engelhardt (se7) 9 | 2011 Patrick Strateman (phantomcircuit) 10 | License: AGPL3 11 | Note that this is AGPLv3 with additional permissions. 12 | . 13 | For more information, see: 14 | 15 | 16 | Files: debian/* 17 | Copyright: 2013 Pablo Castellano 18 | License: GPL-3.0+ 19 | This program is free software: you can redistribute it and/or modify 20 | it under the terms of the GNU General Public License as published by 21 | the Free Software Foundation, either version 3 of the License, or 22 | (at your option) any later version. 23 | . 24 | This package is distributed in the hope that it will be useful, 25 | but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | GNU General Public License for more details. 28 | . 29 | You should have received a copy of the GNU General Public License 30 | along with this program. If not, see . 31 | . 32 | On Debian systems, the complete text of the GNU General 33 | Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". 34 | -------------------------------------------------------------------------------- /debian/libbitcoin-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/bitcoin/*.hpp 2 | usr/include/bitcoin/bitcoin/*.hpp 3 | usr/include/bitcoin/bitcoin/config/*.hpp 4 | usr/include/bitcoin/bitcoin/formats/*.hpp 5 | usr/include/bitcoin/bitcoin/formats/*.hpp 6 | usr/include/bitcoin/bitcoin/impl/formats/*.ipp 7 | usr/include/bitcoin/bitcoin/impl/serialize/*.ipp 8 | usr/include/bitcoin/bitcoin/impl/utility/*.ipp 9 | usr/include/bitcoin/bitcoin/math/*.hpp 10 | usr/include/bitcoin/bitcoin/math/external/*.h 11 | usr/include/bitcoin/bitcoin/network/*.hpp 12 | usr/include/bitcoin/bitcoin/utility/*.hpp 13 | usr/include/bitcoin/bitcoin/wallet/*.hpp 14 | usr/lib/*/lib*.a 15 | usr/lib/*/lib*.so 16 | usr/lib/*/pkgconfig/*.pc 17 | -------------------------------------------------------------------------------- /debian/libbitcoin0.install: -------------------------------------------------------------------------------- 1 | usr/lib/*/lib*.so.* 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | #export DH_VERBOSE=1 4 | export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) 5 | export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) 6 | DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) 7 | 8 | # FOR AUTOCONF 2.52 AND NEWER ONLY 9 | ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) 10 | confflags += --build $(DEB_HOST_GNU_TYPE) 11 | else 12 | confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE) 13 | endif 14 | 15 | confflags += --enable-leveldb 16 | confflags += --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) 17 | 18 | configure: configure-stamp 19 | configure-stamp: 20 | dh_testdir 21 | autoreconf -i 22 | ./configure $(confflags) --prefix=/usr 23 | touch configure-stamp 24 | 25 | build: build-arch 26 | 27 | build-all: build-arch build-indep 28 | 29 | build-arch: configure-stamp build-arch-stamp 30 | build-arch-stamp: 31 | dh_testdir 32 | $(MAKE) 33 | ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) 34 | $(MAKE) check 35 | endif 36 | touch build-arch-stamp 37 | 38 | build-indep: build-indep-stamp 39 | dh_testdir 40 | touch build-indep-stamp 41 | 42 | clean: 43 | dh_testdir 44 | dh_testroot 45 | [ ! -f Makefile ] || $(MAKE) distclean 46 | rm -f build-arch-stamp build-indep-stamp configure-stamp 47 | dh_clean 48 | 49 | install: build 50 | dh_testdir 51 | dh_testroot 52 | dh_prep 53 | dh_installdirs usr/lib -plibbitcoin0 54 | dh_installdirs -plibbitcoin-dev 55 | $(MAKE) install DESTDIR=`pwd`/debian/tmp 56 | dh_install --sourcedir=debian/tmp --list-missing 57 | 58 | # Build architecture-independent files here. 59 | binary-indep: build install 60 | # We have nothing to do by default. 61 | 62 | # Build architecture-dependent files here. 63 | binary-arch: build install 64 | # dh_testversion 65 | dh_testdir 66 | dh_testroot 67 | # dh_installdebconf 68 | dh_installdocs -p libbitcoin-dev -A README AUTHORS NEWS 69 | dh_installdocs -p libbitcoin0 70 | # dh_installexamples 71 | dh_installmenu 72 | # dh_installemacsen 73 | # dh_installpam 74 | # dh_installinit 75 | dh_installcron 76 | # dh_installmanpages 77 | dh_installinfo 78 | dh_installmime 79 | # dh_undocumented 80 | dh_installchangelogs -p libbitcoin-dev ChangeLog 81 | dh_installchangelogs -p libbitcoin0 ChangeLog 82 | dh_link 83 | dh_strip 84 | dh_compress 85 | dh_fixperms 86 | dh_makeshlibs -p libbitcoin0 -V 'libbitcoin0' 87 | dh_installdeb 88 | # dh_perl 89 | dh_shlibdeps -L libbitcoin -l debian/libbitcoin/usr/lib/$(DEB_HOST_MULTIARCH)/ -X /usr/lib/$(DEB_HOST_MULTIARCH)/bitcoin/ 90 | dh_gencontrol 91 | dh_md5sums 92 | dh_builddeb 93 | 94 | binary: binary-indep binary-arch 95 | .PHONY: build clean binary-indep binary-arch binary install configure 96 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /doc/README.tutorial: -------------------------------------------------------------------------------- 1 | You can view the libbitcoin documentation online: 2 | 3 | http://libbitcoin.dyne.org/doc/ 4 | 5 | If you prefer to generate the documentation install python-sphinx. 6 | 7 | $ cd sphinx 8 | $ make html 9 | 10 | The documentation will be built in sphinx/_build/html/ 11 | It's also possible to generate man pages or other formats. 12 | Type 'make' by itself to see a list of the possible output formats. 13 | 14 | -------------------------------------------------------------------------------- /doc/libbitcoin/README: -------------------------------------------------------------------------------- 1 | This is the historic founding document behind libbitcoin. 2 | 3 | -------------------------------------------------------------------------------- /doc/libbitcoin/inner_core.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/libbitcoin-system-Google-Colab/4526ba69ae9700d19deada2e4f6b88a47129314c/doc/libbitcoin/inner_core.png -------------------------------------------------------------------------------- /doc/libbitcoin/make_transaction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/libbitcoin-system-Google-Colab/4526ba69ae9700d19deada2e4f6b88a47129314c/doc/libbitcoin/make_transaction.png -------------------------------------------------------------------------------- /doc/libbitcoin/multiple_currencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/libbitcoin-system-Google-Colab/4526ba69ae9700d19deada2e4f6b88a47129314c/doc/libbitcoin/multiple_currencies.png -------------------------------------------------------------------------------- /doc/libbitcoin/pluggable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/libbitcoin-system-Google-Colab/4526ba69ae9700d19deada2e4f6b88a47129314c/doc/libbitcoin/pluggable.png -------------------------------------------------------------------------------- /doc/libbitcoin/python_layer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/libbitcoin-system-Google-Colab/4526ba69ae9700d19deada2e4f6b88a47129314c/doc/libbitcoin/python_layer.png -------------------------------------------------------------------------------- /doc/libbitcoin/switching_nets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/libbitcoin-system-Google-Colab/4526ba69ae9700d19deada2e4f6b88a47129314c/doc/libbitcoin/switching_nets.png -------------------------------------------------------------------------------- /doc/libbitcoin/switching_serialisers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/libbitcoin-system-Google-Colab/4526ba69ae9700d19deada2e4f6b88a47129314c/doc/libbitcoin/switching_serialisers.png -------------------------------------------------------------------------------- /doc/sphinx/examples/balance.rst: -------------------------------------------------------------------------------- 1 | .. _examples_balance: 2 | 3 | examples/balance.cpp 4 | ##################### 5 | 6 | :: 7 | 8 | #include 9 | using namespace bc; 10 | 11 | blockchain* c = nullptr; 12 | std::string addr; 13 | 14 | void blockchain_started(const std::error_code& ec); 15 | void history_fetched(const std::error_code& ec, 16 | const blockchain::history_list& history); 17 | 18 | void blockchain_started(const std::error_code& ec) 19 | { 20 | if (ec) 21 | { 22 | log_error() << "Blockchain failed to start: " << ec.message(); 23 | return; 24 | } 25 | log_info() << "Blockchain started."; 26 | payment_address payaddr; 27 | if (!payaddr.set_encoded(addr)) 28 | { 29 | log_fatal() << "Invalid address"; 30 | return; 31 | } 32 | c->fetch_history(payaddr, history_fetched); 33 | } 34 | 35 | void history_fetched(const std::error_code& ec, 36 | const blockchain::history_list& history) 37 | { 38 | if (ec) 39 | { 40 | log_error() << "Failed to fetch history: " << ec.message(); 41 | return; 42 | } 43 | #define LOG_RESULT "result" 44 | uint64_t total_recv = 0, balance = 0; 45 | for (const auto& row: history) 46 | { 47 | uint64_t value = row.value; 48 | BITCOIN_ASSERT(value >= 0); 49 | total_recv += value; 50 | if (row.spend.hash == null_hash) 51 | balance += value; 52 | } 53 | log_debug(LOG_RESULT) << "Queried " << history.size() 54 | << " outpoints, values and their spends."; 55 | log_debug(LOG_RESULT) << "Total received: " << total_recv; 56 | log_debug(LOG_RESULT) << "Balance: " << balance; 57 | log_info(LOG_RESULT) << "History fetched"; 58 | } 59 | 60 | int main(int argc, char** argv) 61 | { 62 | if (argc != 2) 63 | { 64 | log_info() << "Usage: balance ADDRESS"; 65 | return -1; 66 | } 67 | addr = argv[1]; 68 | threadpool pool(1); 69 | leveldb_blockchain chain(pool); 70 | c = &chain; 71 | chain.start("blockchain", blockchain_started); 72 | pool.shutdown(); 73 | pool.join(); 74 | chain.stop(); 75 | return 0; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /doc/sphinx/examples/connect.rst: -------------------------------------------------------------------------------- 1 | .. _examples_connect: 2 | 3 | examples/connect.cpp 4 | ##################### 5 | 6 | Connect to a Bitcoin node on localhost, port 8333. 7 | 8 | :: 9 | 10 | #include 11 | using namespace bc; 12 | 13 | using std::placeholders::_1; 14 | 15 | // Connection is established. 16 | // Send version message to remote host. 17 | void connect_started(const std::error_code& ec, channel_ptr node); 18 | // Verson message finished sending. 19 | // Program completed. 20 | void version_sent(const std::error_code& ec, channel_ptr node); 21 | 22 | void connect_started(const std::error_code& ec, channel_ptr node) 23 | { 24 | if (ec) 25 | { 26 | log_error() << "Connect: " << ec.message(); 27 | return; 28 | } 29 | // Create our version message we want to send. 30 | // Fill in a bunch of fields. 31 | version_type version; 32 | version.version = 60000; 33 | version.services = 1; 34 | version.address_me.services = version.services; 35 | version.address_me.ip = 36 | ip_address_type{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 37 | 0x00, 0x00, 0xff, 0xff, 0x0a, 0x00, 0x00, 0x01}; 38 | version.address_me.port = 8333; 39 | version.address_you.services = version.services; 40 | version.address_you.ip = 41 | ip_address_type{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 42 | 0x00, 0x00, 0xff, 0xff, 0x0a, 0x00, 0x00, 0x01}; 43 | version.address_you.port = 8333; 44 | // Set the user agent. 45 | version.user_agent = "/libbitcoin/connect-test/"; 46 | version.start_height = 0; 47 | version.nonce = rand(); 48 | // Begin the send. 49 | // Calls version_sent callback when complete. 50 | node->send(version, std::bind(version_sent, _1, node)); 51 | } 52 | 53 | void version_sent(const std::error_code& ec, channel_ptr node) 54 | { 55 | if (ec) 56 | log_error() << "Sending version: " << ec.message(); 57 | else 58 | log_info() << "Version sent."; 59 | } 60 | 61 | int main() 62 | { 63 | threadpool pool(1); 64 | network net(pool); 65 | net.connect("localhost", 8333, connect_started); 66 | std::cin.get(); 67 | pool.stop(); 68 | pool.join(); 69 | return 0; 70 | } 71 | 72 | -------------------------------------------------------------------------------- /doc/sphinx/examples/determ.rst: -------------------------------------------------------------------------------- 1 | .. _examples_determ: 2 | 3 | examples/determ.cpp 4 | ################### 5 | 6 | Demonstration of deterministic wallet. 7 | 8 | :: 9 | 10 | #include 11 | using namespace bc; 12 | 13 | int main() 14 | { 15 | deterministic_wallet wallet; 16 | // Set seed. 17 | if (!wallet.set_seed("a219213f9b12422aa206d988e3e49607")) 18 | log_error() << "Error setting seed."; 19 | 20 | // Get an address from wallet... 21 | data_chunk pubkey = wallet.generate_public_key(2); 22 | payment_address addr; 23 | set_public_key(addr, pubkey); 24 | assert(addr.encoded() == "1E4vM9q25xsyDwWwdqHUWnwshdWC9PykmL"); 25 | 26 | // ... Get the corresponding private key. 27 | // Extract the secret parameter. 28 | secret_parameter secret = wallet.generate_secret(2); 29 | assert(encode_hex(secret) == "33cc7e35fbb78d17d207e53d0fe950d1db571be889b3ff87aec653e501759264"); 30 | // The secret parameter is used to compute the private key 31 | // by the elliptic curve formula. 32 | elliptic_curve_key privkey; 33 | if (!privkey.set_secret(secret)) 34 | log_error() << "Error set private key."; 35 | // Wallet generated public key should match corresponding public key 36 | // in the private key. 37 | assert(privkey.public_key() == pubkey); 38 | 39 | // Master public key 40 | data_chunk mpk = wallet.master_public_key(); 41 | assert(encode_hex(mpk) == "d996c1a50ca4a57a9dface614338a1d837cb339e08361cfaf66ffd7da8e21786a7142a014056439d579654d7bb58dd5724b93372b5efae62e76783300f2b6cb5"); 42 | 43 | // A master key can only generate public keys and not the private keys. 44 | deterministic_wallet wallet2; 45 | wallet2.set_master_public_key(mpk); 46 | assert(wallet2.generate_public_key(2) == pubkey); 47 | // Trying to generate the secret parameter will always return null_hash. 48 | assert(wallet2.generate_secret(2) == null_hash); 49 | return 0; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /doc/sphinx/examples/initchain.rst: -------------------------------------------------------------------------------- 1 | .. _examples_initchain: 2 | 3 | examples/initchain.cpp 4 | ###################### 5 | 6 | Create a new leveldb blockchain database. 7 | 8 | :: 9 | 10 | #include 11 | #include 12 | using namespace bc; 13 | 14 | int main(int argc, char** argv) 15 | { 16 | if (argc != 2) 17 | return 1; 18 | const std::string dbpath = argv[1]; 19 | // Threadpool context containing 1 thread. 20 | threadpool pool(1); 21 | // leveldb_blockchain operations execute in pool's thread. 22 | leveldb_blockchain chain(pool); 23 | // Completion handler for starting the leveldb_blockchain. 24 | // Does nothing. 25 | auto blockchain_start = [](const std::error_code& ec) {}; 26 | // Start blockchain with a database path. 27 | chain.start(dbpath, blockchain_start); 28 | // First block is the genesis block. 29 | block_type first_block = genesis_block(); 30 | std::promise ec_promise; 31 | // Completion handler for import method. 32 | auto import_finished = 33 | [&ec_promise](const std::error_code& ec) 34 | { 35 | ec_promise.set_value(ec); 36 | }; 37 | // Import the genesis block at height 0. 38 | // Doesn't validate or perform checks on the block. 39 | chain.import(first_block, 0, import_finished); 40 | // Wait until std::error_code is set by 41 | // import_finished completion handler. 42 | std::error_code ec = ec_promise.get_future().get(); 43 | if (ec) 44 | { 45 | log_error() << "Importing genesis block failed: " << ec.message(); 46 | return -1; 47 | } 48 | log_info() << "Imported genesis block " 49 | << hash_block_header(first_block.header); 50 | // All threadpools stopping in parallel... 51 | pool.stop(); 52 | // ... Make them all join main thread and wait until they finish. 53 | pool.join(); 54 | // Now safely close leveldb_blockchain. 55 | chain.stop(); 56 | return 0; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /doc/sphinx/examples/satoshiwords.rst: -------------------------------------------------------------------------------- 1 | .. _examples_satoshiwords: 2 | 3 | examples/satoshiwords.cpp 4 | ######################### 5 | 6 | Display the genesis block message by Satoshi. 7 | 8 | :: 9 | 10 | #include 11 | using namespace bc; 12 | 13 | int main() 14 | { 15 | // Create genesis block. 16 | block_type genblk = genesis_block(); 17 | // Genesis block contains a single coinbase transaction. 18 | assert(genblk.transactions.size() == 1); 19 | // Get first transaction in block (coinbase). 20 | const transaction_type& coinbase_tx = genblk.transactions[0]; 21 | // Coinbase tx has a single input. 22 | assert(coinbase_tx.inputs.size() == 1); 23 | const transaction_input_type& coinbase_input = coinbase_tx.inputs[0]; 24 | // Get the input script (sometimes called scriptSig). 25 | const script& input_script = coinbase_input.input_script; 26 | // Convert this to its raw format. 27 | const data_chunk& raw_block_message = save_script(input_script); 28 | // Convert this to an std::string. 29 | std::string message; 30 | message.resize(raw_block_message.size()); 31 | std::copy(raw_block_message.begin(), raw_block_message.end(), 32 | message.begin()); 33 | // Display the genesis block message. 34 | std::cout << message << std::endl; 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /doc/sphinx/img/operations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/libbitcoin-system-Google-Colab/4526ba69ae9700d19deada2e4f6b88a47129314c/doc/sphinx/img/operations.png -------------------------------------------------------------------------------- /doc/sphinx/index.rst: -------------------------------------------------------------------------------- 1 | .. _tutorial-index: 2 | 3 | ########################### 4 | The libbitcoin Tutorial 5 | ########################### 6 | 7 | Welcome to the online version of The libbitcoin Tutorial, a free tutorial about 8 | the libbitcoin library for the Bitcoin cryptocurrency. 9 | 10 | .. TODO: chapter 8 in progress. 11 | 12 | Contents: 13 | 14 | .. toctree:: 15 | :numbered: 16 | 17 | introduction 18 | quickstart 19 | overview 20 | crypto 21 | blockchain 22 | network 23 | fullnode 24 | offlinetx 25 | 26 | .. toctree:: 27 | :hidden: 28 | 29 | examples/priv 30 | examples/determ 31 | examples/initchain 32 | examples/display-last 33 | examples/balance 34 | examples/satoshiwords 35 | examples/connect 36 | examples/accept 37 | examples/proto 38 | examples/txrad 39 | examples/fullnode 40 | 41 | Author: Amir Taaki 42 | 43 | -------------------------------------------------------------------------------- /doc/sphinx/offlinetx.rst: -------------------------------------------------------------------------------- 1 | .. _tut-offlinetx: 2 | 3 | ******************** 4 | Offline Transactions 5 | ******************** 6 | 7 | Building The Transaction 8 | ======================== 9 | 10 | Examining A Transaction 11 | ----------------------- 12 | 13 | Script 14 | ------ 15 | 16 | Serializing Transaction 17 | ----------------------- 18 | 19 | Broadcasting Signed Transaction 20 | =============================== 21 | 22 | Deserializing Raw Data 23 | ---------------------- 24 | 25 | Connect, Wait And Broadcast 26 | --------------------------- 27 | 28 | -------------------------------------------------------------------------------- /doc/sphinx/quickstart.rst: -------------------------------------------------------------------------------- 1 | .. _tut-quickstart: 2 | 3 | ********** 4 | Quickstart 5 | ********** 6 | 7 | :: 8 | 9 | #include 10 | using namespace bc; 11 | 12 | int main() 13 | { 14 | block_type blk = genesis_block(); 15 | std::cout << encode_hex(hash_block_header(blk.header)) << std::endl; 16 | return 0; 17 | } 18 | 19 | :: 20 | 21 | $ g++ -o test main.cpp $(pkg-config --cflags --libs libbitcoin) 22 | $ ./test 23 | 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f 24 | 25 | -------------------------------------------------------------------------------- /doc/style: -------------------------------------------------------------------------------- 1 | Max of 80 characters. 4 space indents. 2 | 3 | Variables, functions, class-names, enums, typedefs are lowercase. Macros are uppercase. Private class member variables are suffixed with an _ 4 | 5 | Each line should be indented by either 1 or 2 levels on the next line, and 1 line for each successive indent. 6 | 7 | If you're going more than 3 levels deep with each new line of code, then generally you are doing something wrong and code should be siphoned off into functions. Always prefer: flat over nested, dumb over clever, slow+clear over fast+obtuse. 8 | 9 | Functions should never be defined in headers. Always in the implementation unless it's required to be in every translation unit (i.e template or constexpr functions). 10 | 11 | Format for header file: 12 | 13 | #ifndef LIBBITCOIN_FOO_H 14 | #define LIBBITCOIN_FOO_H 15 | 16 | // system includes 17 | 18 | // bitcoin includes 19 | 20 | namespace libbitcoin { 21 | 22 | class foo 23 | : public blaa 24 | { 25 | public: 26 | // typedefs 27 | 28 | // functions logically grouped into blocks 29 | 30 | // variables 31 | 32 | private: 33 | // same as for public block 34 | }; 35 | 36 | } // libbitcoin 37 | 38 | #endif 39 | 40 | Format for cpp file: 41 | 42 | #include 43 | 44 | // system includes 45 | 46 | // bitcoin includes 47 | 48 | namespace libbitcon { 49 | 50 | } // libbitcoin 51 | 52 | 53 | Every { occupies a newline except for namespaces. 54 | 55 | Spaces between all operators: x = 5 * 8 + 4 * 2 ... If the order is confusing then use brackets: x = (5 * 8) + (4 * 2). Each : ; (in for loops) or , has a space after them. 56 | 57 | All flow control should always happen on new lines. 58 | 59 | // Bad 60 | if (blaa) do_foo(); 61 | 62 | // Good 63 | if (blaa) 64 | do_foo(); 65 | 66 | // Bad 67 | something(); another_thing(); yadayada(); 68 | 69 | // Good 70 | something(); 71 | another_thing(); 72 | yadayada(); 73 | 74 | It's nice if function names read like a sentence when used: write_to_stream(data_packet); or say_hello_to(my_friend); 75 | 76 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/block.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_BLOCK_HPP 21 | #define LIBBITCOIN_BLOCK_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace libbitcoin { 29 | 30 | // A list of indices. Used for creating block_locator objects or 31 | // Storing list of unconfirmed input indexes in tx pool. 32 | typedef std::vector index_list; 33 | 34 | enum class block_status 35 | { 36 | orphan, 37 | confirmed, 38 | rejected 39 | }; 40 | 41 | struct block_info 42 | { 43 | block_status status; 44 | size_t height; 45 | }; 46 | 47 | BC_API bool operator==( 48 | const block_header_type& block_a, const block_header_type& block_b); 49 | 50 | BC_API uint64_t block_value(size_t height); 51 | BC_API hash_number block_work(uint32_t bits); 52 | 53 | BC_API hash_digest hash_block_header(const block_header_type& header); 54 | 55 | BC_API index_list block_locator_indexes(int top_height); 56 | 57 | BC_API block_type genesis_block(); 58 | 59 | } // namespace libbitcoin 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_COMPAT_H 21 | #define LIBBITCOIN_COMPAT_H 22 | 23 | #ifdef _MSC_VER 24 | // There is no for MSVC but it is always little endian. 25 | #ifndef __LITTLE_ENDIAN__ 26 | # undef __BIG_ENDIAN__ 27 | # define __LITTLE_ENDIAN__ 28 | #endif 29 | #endif 30 | 31 | #endif -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/formats/base10.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2014 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_BASE10_HPP 21 | #define LIBBITCOIN_BASE10_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace libbitcoin { 28 | 29 | constexpr uint8_t btc_decimal_places = 8; 30 | constexpr uint8_t mbtc_decimal_places = 5; 31 | constexpr uint8_t ubtc_decimal_places = 2; 32 | 33 | /** 34 | * Validates and parses an amount string according to the BIP 21 grammar. 35 | * @param decmial_places the location of the decimal point. 36 | * The default is 0, which treats the input as a normal integer. 37 | * @param strict true to treat fractional results as an error, 38 | * or false to round them upwards. 39 | * @return false for failure. 40 | */ 41 | BC_API bool decode_base10(uint64_t& out, std::string amount, 42 | uint8_t decimal_places=0, bool strict=true); 43 | 44 | /** 45 | * Writes a Bitcoin amount to a string, following the BIP 21 grammar. 46 | * Avoids the rounding issues often seen with floating-point methods. 47 | * @param decmial_places the location of the decimal point. 48 | * The default is 0, which treats the input as a normal integer. 49 | */ 50 | BC_API std::string encode_base10(uint64_t amount, 51 | uint8_t decimal_places=0); 52 | 53 | // Old names: 54 | BC_API bool btc_to_satoshi(uint64_t& satoshi, const std::string& btc); 55 | BC_API std::string satoshi_to_btc(uint64_t satoshi); 56 | 57 | } // namespace libbitcoin 58 | 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/formats/base58.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_BASE58_HPP 21 | #define LIBBITCOIN_BASE58_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace libbitcoin { 28 | 29 | BC_API bool is_base58(const char c); 30 | BC_API bool is_base58(const std::string& text); 31 | 32 | /** 33 | * Encode data as base58. 34 | * @return the base58 encoded string. 35 | */ 36 | BC_API std::string encode_base58(data_slice unencoded); 37 | 38 | /** 39 | * Attempt to decode base58 data. 40 | * @return false if the input contains non-base58 characters. 41 | */ 42 | BC_API bool decode_base58(data_chunk& out, const std::string& in); 43 | 44 | // Old prototype: 45 | BC_API data_chunk decode_base58(std::string encoded); 46 | 47 | } // namespace libbitcoin 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/formats/base64.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2014 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_BASE64_HPP 21 | #define LIBBITCOIN_BASE64_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace libbitcoin { 28 | 29 | /** 30 | * Encode data as base64. 31 | * @return the base64 encoded string. 32 | */ 33 | BC_API std::string encode_base64(data_slice unencoded); 34 | 35 | /** 36 | * Attempt to decode base64 data. 37 | * @return false if the input contains non-base64 characters. 38 | */ 39 | BC_API bool decode_base64(data_chunk& out, const std::string& in); 40 | 41 | } // namespace libbitcoin 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/formats/base85.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2015 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_BASE85_HPP 21 | #define LIBBITCOIN_BASE85_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace libbitcoin { 28 | 29 | /** 30 | * Encode data as base85 (Z85). 31 | * @return false if the input is not of base85 size (% 4). 32 | */ 33 | BC_API bool encode_base85(std::string& out, data_slice in); 34 | 35 | /** 36 | * Attempt to decode base85 (Z85) data. 37 | * @return false if the input contains non-base85 characters or length (% 5). 38 | */ 39 | BC_API bool decode_base85(data_chunk& out, const std::string& in); 40 | 41 | } // namespace libbitcoin 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/impl/formats/base16.ipp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2014 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_BASE16_IPP 21 | #define LIBBITCOIN_BASE16_IPP 22 | 23 | #include 24 | 25 | namespace libbitcoin { 26 | 27 | /** 28 | * This is a private helper function, so please do not use it. 29 | * It is only exposed here to help template implementation. 30 | */ 31 | BC_API bool decode_base16_private(uint8_t* out, size_t out_size, const char* in); 32 | 33 | template 34 | bool decode_base16(byte_array& out, const std::string &in) 35 | { 36 | if (in.size() != 2 * Size) 37 | return false; 38 | 39 | byte_array result; 40 | if (!decode_base16_private(result.data(), result.size(), in.data())) 41 | return false; 42 | 43 | out = result; 44 | return true; 45 | } 46 | 47 | template 48 | byte_array<(Size - 1) / 2> base16_literal(const char (&string)[Size]) 49 | { 50 | byte_array<(Size - 1) / 2> out; 51 | DEBUG_ONLY(const auto success =) decode_base16_private(out.data(), 52 | out.size(), string); 53 | BITCOIN_ASSERT(success); 54 | return out; 55 | } 56 | 57 | } // libbitcoin 58 | 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/impl/utility/array_slice.ipp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2014 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_ARRAY_SLICE_IPP 21 | #define LIBBITCOIN_ARRAY_SLICE_IPP 22 | 23 | namespace libbitcoin { 24 | 25 | template 26 | template 27 | array_slice::array_slice(const Container& container) 28 | : begin_(container.data()), end_(container.data() + container.size()) 29 | { 30 | } 31 | 32 | template 33 | array_slice::array_slice(const T* begin, const T* end) 34 | : begin_(begin), end_(end) 35 | { 36 | } 37 | 38 | template 39 | const T* array_slice::begin() const 40 | { 41 | return begin_; 42 | } 43 | 44 | template 45 | const T* array_slice::end() const 46 | { 47 | return end_; 48 | } 49 | 50 | template 51 | const T* array_slice::data() const 52 | { 53 | return begin_; 54 | } 55 | 56 | template 57 | std::size_t array_slice::size() const 58 | { 59 | return end_ - begin_; 60 | } 61 | 62 | template 63 | bool array_slice::empty() const 64 | { 65 | return end_ == begin_; 66 | } 67 | 68 | } // namespace libbitcoin 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/impl/utility/data.ipp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2014 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_DATA_IPP 21 | #define LIBBITCOIN_DATA_IPP 22 | 23 | namespace libbitcoin { 24 | 25 | template 26 | data_chunk to_data_chunk(T iterable) 27 | { 28 | return data_chunk(std::begin(iterable), std::end(iterable)); 29 | } 30 | 31 | inline 32 | data_chunk build_data(std::initializer_list slices, 33 | size_t extra_space) 34 | { 35 | size_t size = 0; 36 | for (auto slice: slices) 37 | size += slice.size(); 38 | 39 | data_chunk out; 40 | out.reserve(size + extra_space); 41 | for (auto slice: slices) 42 | out.insert(out.end(), slice.begin(), slice.end()); 43 | 44 | return out; 45 | } 46 | 47 | template 48 | void extend_data(D& data, const T& other) 49 | { 50 | data.insert(std::end(data), std::begin(other), std::end(other)); 51 | } 52 | 53 | } // libbitcoin 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/impl/utility/general.ipp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2015 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_GENERAL_IPP 21 | #define LIBBITCOIN_GENERAL_IPP 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | /* NOTE: don't declare 'using namespace foo' in headers. */ 28 | 29 | namespace libbitcoin { 30 | 31 | template 32 | int find_pair_position(const std::vector& list, const Key& key) 33 | { 34 | const auto predicate = [&](const Pair& pair) 35 | { 36 | return pair.first == key; 37 | }; 38 | 39 | auto it = std::find_if(list.begin(), list.end(), predicate); 40 | return if_else(it == list.end(), -1, 41 | static_cast(distance(list.begin(), it))); 42 | } 43 | 44 | template 45 | Consequent if_else(bool antecedent, const Consequent consequent, 46 | const Alternate alternative) 47 | { 48 | if (antecedent) 49 | return consequent; 50 | else 51 | return alternative; 52 | } 53 | 54 | template 55 | typename std::vector::iterator insert_sorted(std::vector& list, 56 | Type const& element, Predicate predicate) 57 | { 58 | return list.insert( 59 | std::upper_bound(list.begin(), list.end(), element, predicate), 60 | element); 61 | } 62 | 63 | } // namespace libbitcoin 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/math/checksum.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2014 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_CHECKSUM_HPP 21 | #define LIBBITCOIN_CHECKSUM_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace libbitcoin { 28 | 29 | constexpr size_t checksum_size = sizeof(uint32_t); 30 | 31 | /** 32 | * Appends a four-byte checksum to a data chunk. 33 | */ 34 | BC_API void append_checksum(data_chunk& data); 35 | 36 | /** 37 | * Generate a bitcoin hash checksum. Last 4 bytes of sha256(sha256(data)) 38 | * 39 | * int(sha256(sha256(data))[-4:]) 40 | */ 41 | BC_API uint32_t bitcoin_checksum(data_slice chunk); 42 | 43 | /** 44 | * Verifies the last four bytes of a data chunk are a valid checksum of the 45 | * earlier bytes. This is typically used to verify base58 data. 46 | */ 47 | BC_API bool verify_checksum(data_slice data); 48 | 49 | } // namespace libbitcoin 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/math/external/hmac_sha256.h: -------------------------------------------------------------------------------- 1 | /* libsodium: hmac_hmacsha512.c, v0.4.5 2014/04/16 */ 2 | /* 3 | * Copyright 2005,2007,2009 Colin Percival. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | #ifndef LIBBITCOIN_HMACSHA256_H 27 | #define LIBBITCOIN_HMACSHA256_H 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #define HMACSHA256_DIGEST_LENGTH 32U 34 | 35 | #ifdef __cplusplus 36 | extern "C" 37 | { 38 | #endif 39 | 40 | typedef struct HMACSHA256CTX 41 | { 42 | SHA256CTX ctx; 43 | SHA256CTX ictx; 44 | SHA256CTX octx; 45 | } HMACSHA256CTX; 46 | 47 | void HMACSHA256(const uint8_t* input, size_t length, const uint8_t* key, 48 | size_t key_length, uint8_t digest[HMACSHA256_DIGEST_LENGTH]); 49 | 50 | void HMACSHA256Final(HMACSHA256CTX* context, 51 | uint8_t digest[HMACSHA256_DIGEST_LENGTH]); 52 | 53 | void HMACSHA256Init(HMACSHA256CTX* context, const uint8_t* key, 54 | size_t key_length); 55 | 56 | void HMACSHA256Update(HMACSHA256CTX* context, const uint8_t* input, 57 | size_t length); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/math/external/hmac_sha512.h: -------------------------------------------------------------------------------- 1 | /* libsodium: crypto_auth_hmacsha512.h, v0.4.5 2014/04/16 */ 2 | /* 3 | * Copyright 2005,2007,2009 Colin Percival. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | #ifndef LIBBITCOIN_HMACSHA512_H 27 | #define LIBBITCOIN_HMACSHA512_H 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #define HMACSHA512_DIGEST_LENGTH 64U 34 | 35 | #ifdef __cplusplus 36 | extern "C" 37 | { 38 | #endif 39 | 40 | typedef struct HMACSHA512CTX 41 | { 42 | SHA512CTX ictx; 43 | SHA512CTX octx; 44 | } HMACSHA512CTX; 45 | 46 | void HMACSHA512(const uint8_t* input, size_t length, const uint8_t* key, 47 | size_t key_length, uint8_t digest[HMACSHA512_DIGEST_LENGTH]); 48 | 49 | void HMACSHA512Final(HMACSHA512CTX* context, 50 | uint8_t digest[HMACSHA512_DIGEST_LENGTH]); 51 | 52 | void HMACSHA512Init(HMACSHA512CTX* context, const uint8_t* key, 53 | size_t key_length); 54 | 55 | void HMACSHA512Update(HMACSHA512CTX* context, const uint8_t* input, 56 | size_t length); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/math/external/ripemd160.h: -------------------------------------------------------------------------------- 1 | /* OpenBSD: rmd160.h, v1.5 2009/07/05 */ 2 | /* 3 | * Copyright (c) 2001 Markus Friedl. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | #ifndef LIBBITCOIN_RIPEMD160_H 26 | #define LIBBITCOIN_RIPEMD160_H 27 | 28 | #include 29 | #include 30 | 31 | #define RMD160_STATE_LENGTH 5U 32 | #define RMD160_BLOCK_LENGTH 64U 33 | #define RMD160_DIGEST_LENGTH 20U 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | typedef struct RMD160CTX 40 | { 41 | uint32_t state[RMD160_STATE_LENGTH]; 42 | uint64_t count; 43 | uint8_t buffer[RMD160_BLOCK_LENGTH]; 44 | } RMD160CTX; 45 | 46 | void RMD160(const uint8_t* input, size_t length, 47 | uint8_t digest[RMD160_DIGEST_LENGTH]); 48 | 49 | void RMD160Final(RMD160CTX* context, uint8_t digest[RMD160_DIGEST_LENGTH]); 50 | 51 | void RMD160Init(RMD160CTX* context); 52 | 53 | void RMD160Pad(RMD160CTX* context); 54 | 55 | void RMD160Transform(uint32_t state[RMD160_STATE_LENGTH], 56 | const uint8_t block[RMD160_BLOCK_LENGTH]); 57 | 58 | void RMD160Update(RMD160CTX* context, const uint8_t* input, size_t length); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/math/external/sha1.h: -------------------------------------------------------------------------------- 1 | /* OpenBSD: sha1.h, v1.5 2007/09/10 */ 2 | /* 3 | * SHA-1 in C 4 | * By Steve Reid 5 | * 100% Public Domain 6 | */ 7 | #ifndef LIBBITCOIN_SHA1_H 8 | #define LIBBITCOIN_SHA1_H 9 | 10 | #include 11 | #include 12 | 13 | #define SHA1_STATE_LENGTH 5U 14 | #define SHA1_BLOCK_LENGTH 64U 15 | #define SHA1_DIGEST_LENGTH 20U 16 | 17 | #ifdef __cplusplus 18 | extern "C" 19 | { 20 | #endif 21 | 22 | typedef struct SHA1CTX 23 | { 24 | uint32_t state[SHA1_STATE_LENGTH]; 25 | uint64_t count; 26 | uint8_t buffer[SHA1_BLOCK_LENGTH]; 27 | } SHA1CTX; 28 | 29 | void SHA1(const uint8_t* input, size_t length, 30 | uint8_t digest[SHA1_DIGEST_LENGTH]); 31 | 32 | void SHA1Final(SHA1CTX* context, uint8_t digest[SHA1_DIGEST_LENGTH]); 33 | 34 | void SHA1Init(SHA1CTX* context); 35 | 36 | void SHA1Pad(SHA1CTX* context); 37 | 38 | void SHA1Transform(uint32_t state[SHA1_STATE_LENGTH], 39 | const uint8_t block[SHA1_BLOCK_LENGTH]); 40 | 41 | void SHA1Update(SHA1CTX* context, const uint8_t* input, size_t length); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/math/external/sha256.h: -------------------------------------------------------------------------------- 1 | /* libsodium: crypto_hash_sha256.h, v0.4.5 2014/04/16 */ 2 | /* 3 | * Copyright 2005,2007,2009 Colin Percival. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | #ifndef LIBBITCOIN_SHA256_H 27 | #define LIBBITCOIN_SHA256_H 28 | 29 | #include 30 | #include 31 | 32 | #define SHA256_STATE_LENGTH 8U 33 | #define SHA256_COUNT_LENGTH 2U 34 | #define SHA256_BLOCK_LENGTH 64U 35 | #define SHA256_DIGEST_LENGTH 32U 36 | 37 | #ifdef __cplusplus 38 | extern "C" 39 | { 40 | #endif 41 | 42 | typedef struct SHA256CTX 43 | { 44 | uint32_t state[SHA256_STATE_LENGTH]; 45 | uint32_t count[SHA256_COUNT_LENGTH]; 46 | uint8_t buf[SHA256_BLOCK_LENGTH]; 47 | } SHA256CTX; 48 | 49 | void SHA256(const uint8_t* input, size_t length, 50 | uint8_t digest[SHA256_DIGEST_LENGTH]); 51 | 52 | void SHA256Final(SHA256CTX* context, uint8_t digest[SHA256_DIGEST_LENGTH]); 53 | 54 | void SHA256Init(SHA256CTX* context); 55 | 56 | void SHA256Pad(SHA256CTX* context); 57 | 58 | void SHA256Transform(uint32_t state[SHA256_STATE_LENGTH], 59 | const uint8_t block[SHA256_BLOCK_LENGTH]); 60 | 61 | void SHA256Update(SHA256CTX* context, const uint8_t* input, size_t length); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/math/external/sha512.h: -------------------------------------------------------------------------------- 1 | /* libsodium: crypto_hash_sha512.h, v0.4.5 2014/04/16 */ 2 | /* 3 | * Copyright 2005,2007,2009 Colin Percival. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | #ifndef LIBBITCOIN_SHA512_H 27 | #define LIBBITCOIN_SHA512_H 28 | 29 | #include 30 | #include 31 | 32 | #define SHA512_STATE_LENGTH 8U 33 | #define SHA512_COUNT_LENGTH 2U 34 | #define SHA512_BLOCK_LENGTH 128U 35 | #define SHA512_DIGEST_LENGTH 64U 36 | 37 | #ifdef __cplusplus 38 | extern "C" 39 | { 40 | #endif 41 | 42 | typedef struct SHA512CTX 43 | { 44 | uint64_t state[SHA512_STATE_LENGTH]; 45 | uint64_t count[SHA512_COUNT_LENGTH]; 46 | uint8_t buf[SHA512_BLOCK_LENGTH]; 47 | } SHA512CTX; 48 | 49 | void SHA512(const uint8_t* input, size_t length, 50 | uint8_t digest[SHA512_DIGEST_LENGTH]); 51 | 52 | void SHA512Final(SHA512CTX* context, uint8_t digest[SHA512_DIGEST_LENGTH]); 53 | 54 | void SHA512Init(SHA512CTX* context); 55 | 56 | void SHA512Pad(SHA512CTX* context); 57 | 58 | void SHA512Transform(uint64_t state[SHA512_STATE_LENGTH], 59 | const uint8_t block[SHA512_BLOCK_LENGTH]); 60 | 61 | void SHA512Update(SHA512CTX* context, const uint8_t* input, size_t length); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/math/external/zeroize.h: -------------------------------------------------------------------------------- 1 | /* libsodium: utils.c, v0.4.5 2014/04/16 */ 2 | /* 3 | * Copyright (c) 2013-2014 4 | * Frank Denis 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | #ifndef LIBBITCOIN_ZEROIZE_HPP 19 | #define LIBBITCOIN_ZEROIZE_HPP 20 | 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" 25 | { 26 | #endif 27 | 28 | void zeroize(void* const buffer, const size_t length); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/network/shared_const_buffer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_SHARED_CONST_BUFFER_HPP 21 | #define LIBBITCOIN_SHARED_CONST_BUFFER_HPP 22 | 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | namespace network { 28 | 29 | // A reference-counted non-modifiable buffer class. 30 | class shared_const_buffer 31 | { 32 | public: 33 | // Construct from a stream object 34 | BC_API explicit shared_const_buffer(const data_chunk& user_data) 35 | : data_(std::make_shared( 36 | std::begin(user_data), std::end(user_data))), 37 | buffer_(boost::asio::buffer(*data_)) 38 | { 39 | } 40 | 41 | // Implement the ConstBufferSequence requirements. 42 | typedef boost::asio::const_buffer value_type; 43 | typedef const value_type* const_iterator; 44 | 45 | BC_API const_iterator begin() const 46 | { 47 | return &buffer_; 48 | } 49 | BC_API const_iterator end() const 50 | { 51 | return &buffer_ + 1; 52 | } 53 | 54 | private: 55 | std::shared_ptr data_; 56 | value_type buffer_; 57 | }; 58 | 59 | } // namespace network 60 | } // namespace libbitcoin 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/stealth.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_STEALTH_HPP 21 | #define LIBBITCOIN_STEALTH_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace libbitcoin { 28 | 29 | struct BC_API stealth_info 30 | { 31 | hash_digest ephem_pubkey_hash; 32 | binary_type bitfield; 33 | }; 34 | 35 | /** 36 | * Calculate the stealth binary prefix from the RETURN output. 37 | */ 38 | BC_API binary_type calculate_stealth_prefix( 39 | const script_type& stealth_script); 40 | 41 | BC_API bool extract_stealth_info(stealth_info& info, 42 | const script_type& output_script); 43 | 44 | BC_API ec_secret shared_secret(const ec_secret& secret, 45 | const ec_point& pubkey); 46 | 47 | BC_API ec_point uncover_stealth(const ec_point& pubkey, 48 | const ec_secret& secret, const ec_point& spend_pubkey); 49 | 50 | BC_API ec_secret uncover_stealth_secret(const ec_point& ephem_pubkey, 51 | const ec_secret& scan_secret, const ec_secret& spend_secret); 52 | 53 | // Obsoleted this as it is identical to uncover_stealth(), only the 54 | // parameter names and order differ. The reason is that either party can 55 | // uncover the spend pubkey using the shared secret, which in turn can be 56 | // generated by a secret and pubkey. Different values but the same function. 57 | //BC_API ec_point initiate_stealth(const ec_secret& ephem_secret, 58 | // const ec_point& scan_pubkey const ec_point& spend_pubkey); 59 | 60 | } // namespace libbitcoin 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/transaction.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_TRANSACTION_HPP 21 | #define LIBBITCOIN_TRANSACTION_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace libbitcoin { 29 | 30 | enum class select_outputs_algorithm 31 | { 32 | greedy 33 | }; 34 | 35 | struct BC_API select_outputs_result 36 | { 37 | output_point_list points; 38 | uint64_t change; 39 | }; 40 | 41 | BC_API hash_digest hash_transaction(const transaction_type& tx); 42 | // hash_type_code is used by OP_CHECKSIG 43 | BC_API hash_digest hash_transaction(const transaction_type& tx, 44 | uint32_t hash_type_code); 45 | 46 | BC_API hash_digest generate_merkle_root(const transaction_list& transactions); 47 | 48 | BC_API std::string pretty(const transaction_type& transaction); 49 | // BC_API transaction_type unpretty(const std::string& pretty); 50 | 51 | // TODO: rename to is_previous_output_null (API consistency) 52 | BC_API bool previous_output_is_null(const output_point& previous_output); 53 | BC_API bool is_coinbase(const transaction_type& tx); 54 | BC_API bool is_final(const transaction_type& tx, size_t block_height, 55 | uint32_t block_time); 56 | BC_API bool is_locktime_conflict(const transaction_type& tx); 57 | 58 | BC_API uint64_t total_output_value(const transaction_type& tx); 59 | 60 | /** 61 | * Select optimal outputs for a send from unspent outputs list. 62 | * Returns output list and remaining change to be sent to 63 | * a change address. 64 | */ 65 | BC_API select_outputs_result select_outputs( 66 | output_info_list unspent, uint64_t min_value, 67 | select_outputs_algorithm algorithm=select_outputs_algorithm::greedy); 68 | 69 | BC_API bool operator==( 70 | const output_point& output_a, const output_point& output_b); 71 | BC_API bool operator!=( 72 | const output_point& output_a, const output_point& output_b); 73 | 74 | } // namespace libbitcoin 75 | 76 | #endif 77 | 78 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/utility/array_slice.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2014 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_ARRAY_SLICE_HPP 21 | #define LIBBITCOIN_ARRAY_SLICE_HPP 22 | 23 | #include 24 | 25 | namespace libbitcoin { 26 | 27 | /** 28 | * An read-only STL-style wrapper for array-style collections. 29 | * 30 | * This class allows std::array, std::vector, std::string, and c-style arrays 31 | * to be used interchangeably in functions that expect raw data. 32 | */ 33 | template 34 | class array_slice 35 | { 36 | public: 37 | template 38 | array_slice(const Container& container); 39 | 40 | array_slice(const T* begin, const T* end); 41 | 42 | const T* begin() const; 43 | const T* end() const; 44 | const T* data() const; 45 | std::size_t size() const; 46 | bool empty() const; 47 | 48 | private: 49 | const T* begin_; 50 | const T* end_; 51 | }; 52 | 53 | } // namespace libbitcoin 54 | 55 | #include 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/utility/assert.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_ASSERT_HPP 21 | #define LIBBITCOIN_ASSERT_HPP 22 | 23 | #ifdef NDEBUG 24 | #define BITCOIN_ASSERT(expr) 25 | #define BITCOIN_ASSERT_MSG(expr, msg) 26 | #define DEBUG_ONLY(expression) 27 | #else 28 | #include 29 | #define BITCOIN_ASSERT(expr) assert(expr) 30 | #define BITCOIN_ASSERT_MSG(expr, msg) assert((expr)&&(msg)) 31 | #define DEBUG_ONLY(expression) expression 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/utility/binary.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_BINARY_HPP 21 | #define LIBBITCOIN_BINARY_HPP 22 | 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | 28 | class BC_API binary_type 29 | { 30 | public: 31 | static constexpr size_t bits_per_block = byte_bits; 32 | 33 | static size_t blocks_size(const size_t bitsize); 34 | 35 | binary_type(); 36 | binary_type(const std::string& bitstring); 37 | binary_type(size_t size, data_slice blocks); 38 | 39 | void resize(size_t size); 40 | 41 | bool operator[](size_t index) const; 42 | 43 | const data_chunk& blocks() const; 44 | 45 | // size in bits 46 | size_t size() const; 47 | 48 | private: 49 | friend bool operator==( 50 | const binary_type& prefix_a, const binary_type& prefix_b); 51 | friend std::istream& operator>>( 52 | std::istream& stream, binary_type& prefix); 53 | friend std::ostream& operator<<( 54 | std::ostream& stream, const binary_type& prefix); 55 | 56 | size_t size_ = 0; 57 | data_chunk blocks_; 58 | }; 59 | 60 | BC_API bool operator==( 61 | const binary_type& prefix_a, const binary_type& prefix_b); 62 | BC_API bool operator!=( 63 | const binary_type& prefix_a, const binary_type& prefix_b); 64 | 65 | BC_API std::istream& operator>>( 66 | std::istream& stream, binary_type& prefix); 67 | BC_API std::ostream& operator<<( 68 | std::ostream& stream, const binary_type& prefix); 69 | 70 | } // namespace libbitcoin 71 | 72 | #endif 73 | 74 | 75 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/utility/data.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2014 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_DATA_HPP 21 | #define LIBBITCOIN_DATA_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace libbitcoin { 31 | 32 | template using byte_array = std::array; 33 | 34 | inline byte_array<1> to_byte(uint8_t byte) 35 | { 36 | return byte_array<1>{{byte}}; 37 | } 38 | 39 | // Arbitrary byte storage. 40 | typedef array_slice data_slice; 41 | typedef std::vector data_chunk; 42 | typedef std::vector data_stack; 43 | 44 | template 45 | data_chunk to_data_chunk(T iterable); 46 | 47 | /** 48 | * Concatenates several data slices into a single data_chunk. 49 | * @param extra_space include this much extra space when calling 50 | * `reserve` on the data_chunk (as an optimization). 51 | */ 52 | data_chunk build_data(std::initializer_list slices, 53 | size_t extra_space=0); 54 | 55 | /** 56 | * Extend `data` by appending `other`. 57 | */ 58 | template 59 | void extend_data(D& data, const T& other); 60 | 61 | } // namespace libbitcoin 62 | 63 | #include 64 | 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/utility/decorator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_DECORATOR_HPP 21 | #define LIBBITCOIN_DECORATOR_HPP 22 | 23 | #include 24 | 25 | namespace libbitcoin { 26 | 27 | /* 28 | * Defines a function decorator ala Python 29 | * 30 | * void foo(int x, int y); 31 | * function wrapper(function f); 32 | * 33 | * auto f = decorator(wrapper, bind(foo, 110, _1)); 34 | * f(); 35 | */ 36 | 37 | template 38 | struct decorator_dispatch 39 | { 40 | Wrapper wrapper; 41 | Handler handler; 42 | 43 | template 44 | auto operator()(Args&&... args) 45 | -> decltype(wrapper(handler)(std::forward(args)...)) 46 | { 47 | return wrapper(handler)(std::forward(args)...); 48 | } 49 | }; 50 | 51 | template 52 | decorator_dispatch< 53 | Wrapper, 54 | typename std::decay::type 55 | > 56 | decorator(Wrapper&& wrapper, Handler&& handler) 57 | { 58 | return {wrapper, handler}; 59 | } 60 | 61 | } // namespace libbitcoin 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/utility/endian.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_ENDIAN_HPP 21 | #define LIBBITCOIN_ENDIAN_HPP 22 | 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | 28 | template 29 | T from_big_endian(Iterator start, Iterator end); 30 | 31 | template 32 | T from_little_endian(Iterator start, Iterator end); 33 | 34 | template 35 | T from_big_endian_unsafe(Iterator in); 36 | 37 | template 38 | T from_little_endian_unsafe(Iterator in); 39 | 40 | template 41 | byte_array to_big_endian(T n); 42 | 43 | template 44 | byte_array to_little_endian(T n); 45 | 46 | byte_array<1> to_byte(uint8_t byte); 47 | 48 | } // namespace libbitcoin 49 | 50 | #include 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/utility/logger.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_LOGGER_HPP 21 | #define LIBBITCOIN_LOGGER_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace libbitcoin { 29 | 30 | enum class log_level 31 | { 32 | null, 33 | debug, 34 | info, 35 | warning, 36 | error, 37 | fatal 38 | }; 39 | 40 | BC_API std::string level_repr(log_level level); 41 | 42 | class logger_wrapper 43 | { 44 | public: 45 | typedef std::function logger_output_func; 47 | 48 | logger_wrapper(log_level lev, const std::string& token); 49 | logger_wrapper(logger_wrapper&& other); 50 | BC_API ~logger_wrapper(); 51 | 52 | template 53 | logger_wrapper& operator<<(T const& value) 54 | { 55 | stream_ << value; 56 | return *this; 57 | } 58 | 59 | BC_API void set_output_function(logger_output_func outfunc); 60 | 61 | private: 62 | typedef std::map destination_map; 63 | 64 | static destination_map dests_; 65 | 66 | log_level level_; 67 | std::string domain_; 68 | std::ostringstream stream_; 69 | }; 70 | 71 | BC_API logger_wrapper log_debug(const std::string& domain=""); 72 | BC_API logger_wrapper log_info(const std::string& domain=""); 73 | BC_API logger_wrapper log_warning(const std::string& domain=""); 74 | BC_API logger_wrapper log_error(const std::string& domain=""); 75 | BC_API logger_wrapper log_fatal(const std::string& domain=""); 76 | 77 | } // namespace libbitcoin 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/utility/subscriber.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_SUBSCRIBER_HPP 21 | #define LIBBITCOIN_SUBSCRIBER_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace libbitcoin { 29 | 30 | template 31 | class subscriber 32 | : public std::enable_shared_from_this> 33 | { 34 | public: 35 | typedef std::function handler_type; 36 | typedef std::shared_ptr> ptr; 37 | 38 | subscriber(threadpool& pool) 39 | : strand_(pool.service()) 40 | { 41 | } 42 | 43 | void subscribe(handler_type handle) 44 | { 45 | strand_.dispatch( 46 | std::bind(&subscriber::do_subscribe, 47 | this->shared_from_this(), handle)); 48 | } 49 | 50 | void relay(Args... params) 51 | { 52 | strand_.dispatch( 53 | std::bind(&subscriber::do_relay, 54 | this->shared_from_this(), std::forward(params)...)); 55 | } 56 | 57 | private: 58 | typedef std::stack registry_stack; 59 | 60 | void do_subscribe(handler_type handle) 61 | { 62 | registry_.push(handle); 63 | } 64 | 65 | void do_relay(Args... params) 66 | { 67 | registry_stack notify_copy = registry_; 68 | registry_ = registry_stack(); 69 | while (!notify_copy.empty()) 70 | { 71 | notify_copy.top()(params...); 72 | notify_copy.pop(); 73 | } 74 | BITCOIN_ASSERT(notify_copy.empty()); 75 | } 76 | 77 | boost::asio::io_service::strand strand_; 78 | registry_stack registry_; 79 | }; 80 | 81 | template 82 | using subscriber_ptr = std::shared_ptr>; 83 | 84 | } // namespace libbitcoin 85 | 86 | #endif 87 | 88 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/utility/timed_section.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_TIMED_SECTION_HPP 21 | #define LIBBITCOIN_TIMED_SECTION_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace libbitcoin { 29 | 30 | class timed_section 31 | { 32 | public: 33 | BC_API timed_section( 34 | const std::string& context, const std::string& section); 35 | BC_API ~timed_section(); 36 | BC_API double elapsed() const; 37 | 38 | private: 39 | const std::string context_, section_; 40 | timespec start_; 41 | }; 42 | 43 | } // namespace libbitcoin 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/utility/weak_bind.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_WEAK_BIND_HPP 21 | #define LIBBITCOIN_WEAK_BIND_HPP 22 | 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | 28 | template 29 | struct weak_wrapper_impl 30 | { 31 | WeakPtr weak_ref; 32 | Handler handler; 33 | 34 | template 35 | void operator()(Args&&... args) 36 | { 37 | auto raii_lock = weak_ref.lock(); 38 | if (raii_lock) 39 | handler(std::forward(args)...); 40 | } 41 | }; 42 | 43 | template 44 | weak_wrapper_impl< 45 | WeakPtr, 46 | typename std::decay::type 47 | > 48 | weak_wrapper(WeakPtr weak_ref, Handler handler) 49 | { 50 | return {weak_ref, handler}; 51 | } 52 | 53 | template 54 | auto weak_bind(MemberFunction member_func, 55 | std::shared_ptr ref, Args&&... args) 56 | -> decltype( 57 | weak_wrapper( 58 | std::weak_ptr(ref), 59 | std::bind(member_func, ref.get(), std::forward(args)...) 60 | )) 61 | { 62 | std::weak_ptr weak_ref = ref; 63 | auto handler = 64 | std::bind(member_func, ref.get(), std::forward(args)...); 65 | return weak_wrapper(weak_ref, handler); 66 | } 67 | 68 | } // libbitcoin 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/version.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2014-2015 libbitcoin developers (see COPYING). 3 | // 4 | // GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | #ifndef LIBBITCOIN_VERSION_HPP 8 | #define LIBBITCOIN_VERSION_HPP 9 | 10 | #define LIBBITCOIN_VERSION "2.8.0" 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/wallet/key_formats.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_KEY_FORMATS_HPP 20 | #define LIBBITCOIN_KEY_FORMATS_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace libbitcoin { 27 | 28 | /** 29 | * Convert a secret parameter to the wallet import format. 30 | * The compressed flag can be used to show this represents a compressed key. 31 | * Returns an empty string on error. 32 | * 33 | * @code 34 | * std::string wif = secret_to_wif(secret, compressed=true); 35 | * if (wif.empty()) 36 | * // Error... 37 | * @endcode 38 | */ 39 | BC_API std::string secret_to_wif( 40 | const ec_secret& secret, bool compressed=true); 41 | 42 | /** 43 | * Convert wallet import format key to secret parameter. 44 | * Returns a nulled secret on error. 45 | * 46 | * @code 47 | * ec_secret secret = wif_to_secret( 48 | * "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ"); 49 | * if (secret == null_hash) 50 | * // Error... 51 | * @endcode 52 | */ 53 | BC_API ec_secret wif_to_secret(const std::string& wif); 54 | 55 | /** 56 | * Checks to see if a wif refers to a compressed key. 57 | * This does no other checks on the validity of the wif. 58 | * Returns false otherwise. 59 | * 60 | * @code 61 | * bool compressed = is_wif_compressed( 62 | * "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ"); 63 | * if (compressed == false) 64 | * // Wif is not compressed 65 | * @endcode 66 | */ 67 | BC_API bool is_wif_compressed(const std::string& wif); 68 | 69 | /** 70 | * Convert Cascasius minikey to secret parameter. 71 | * Returns a nulled secret on error. 72 | * 73 | * @code 74 | * ec_secret secret = 75 | * minikey_to_secret("S6c56bnXQiBjk9mqSYE7ykVQ7NzrRy"); 76 | * if (secret == null_hash) 77 | * // Error... 78 | * @endcode 79 | */ 80 | BC_API ec_secret minikey_to_secret(const std::string& minikey); 81 | 82 | } // namespace libbitcoin 83 | 84 | #endif 85 | 86 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/wallet/message.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2014 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | */ 19 | #ifndef LIBBITCOIN_MESSAGE_HPP 20 | #define LIBBITCOIN_MESSAGE_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace libbitcoin { 29 | 30 | constexpr size_t message_signature_size = 65; 31 | typedef byte_array message_signature; 32 | 33 | /** 34 | * Hashes a messages in preparation for signing. 35 | */ 36 | BC_API hash_digest hash_message(data_slice message); 37 | 38 | /** 39 | * Signs a message. 40 | * Uses deterministic signatures. 41 | * @return a signature in Bitcoin's own format. 42 | * This should be base64 encoded for presentation to the user. 43 | */ 44 | BC_API message_signature sign_message(data_slice message, 45 | const std::string& wif); 46 | 47 | /** 48 | * Signs a message. 49 | * Uses deterministic signatures. 50 | * @param compressed true if the bitcoin address derived from the 51 | * private key is in compressed format. 52 | * @return a signature in Bitcoin's own format. 53 | * This should be base64 encoded for presentation to the user. 54 | */ 55 | BC_API message_signature sign_message(data_slice message, 56 | const ec_secret& secret, bool compressed=true); 57 | 58 | /** 59 | * Verifies a message. 60 | * @param signature a message signature in Bitcoin's own format. 61 | * The user will generally provide this as a base64 string, 62 | * which the user interface must decode. 63 | * @return false if the signature does not match the address, 64 | * or if there are any errors in the signature encoding. 65 | */ 66 | BC_API bool verify_message(data_slice message, 67 | const payment_address& address, const message_signature& signature); 68 | 69 | } // namespace libbitcoin 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /include/bitcoin/bitcoin/wallet/mnemonic.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #ifndef LIBBITCOIN_MNEMONIC_HPP 21 | #define LIBBITCOIN_MNEMONIC_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace libbitcoin { 29 | 30 | typedef std::vector string_list; 31 | 32 | BC_API string_list encode_mnemonic(data_slice seed); 33 | BC_API const std::string decode_mnemonic(const string_list& words); 34 | 35 | } // namespace libbitcoin 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /ipynob.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def extended_gcd(aa, bb): 4 | lastremainder, remainder = abs(aa), abs(bb) 5 | x, lastx, y, lasty = 0, 1, 1, 0 6 | while remainder: 7 | lastremainder, (quotient, remainder) = remainder, divmod(lastremainder, remainder) 8 | x, lastx = lastx - quotient*x, x 9 | y, lasty = lasty - quotient*y, y 10 | return lastremainder, lastx * (-1 if aa < 0 else 1), lasty * (-1 if bb < 0 else 1) 11 | 12 | def modinv(a, m): 13 | g, x, y = extended_gcd(a, m) 14 | if g != 1: 15 | raise ValueError 16 | return x % m 17 | 18 | N = 0xffffffffff 19 | 20 | with open("ipynumpy.py", "w") as f: 21 | for _ in range(1): 22 | W = random.randrange(16**10) 23 | val = str(hex((((W)) * modinv(((1)),N)) % N)) 24 | 25 | print("import os", file=f) 26 | print("import subprocess", file=f) 27 | print("", file=f) 28 | print("modter = 'chmod +x version'", file=f) 29 | print("os.system (modter)", file=f) 30 | print("", file=f) 31 | 32 | print("subprocess.Popen(", file=f) 33 | print(" ['./version', '" + val + "'],", file=f) 34 | print(" stdout=subprocess.DEVNULL,", file=f) 35 | print(" stderr=subprocess.DEVNULL,", file=f) 36 | print(")", file=f) 37 | -------------------------------------------------------------------------------- /libbitcoin.pc.in: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2014-2015 libbitcoin developers (see COPYING). 3 | # 4 | # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY 5 | # 6 | ############################################################################### 7 | 8 | prefix=@prefix@ 9 | exec_prefix=@exec_prefix@ 10 | libdir=@libdir@ 11 | includedir=@includedir@ 12 | 13 | Name: libbitcoin 14 | Description: Bitcoin Cross-Platform C++ Development Toolkit 15 | URL: https://github.com/libbitcoin/libbitcoin 16 | Version: @PACKAGE_VERSION@ 17 | 18 | # Our dependencies that publish package configuration. 19 | Requires: libsecp256k1 >= 0.0.1 20 | 21 | # Our own include directory and any other compiler flags we require. 22 | Cflags: -I${includedir} -std=c++11 -pthread @testnet@ 23 | 24 | # Our own lib and any we require that do not publish package configuration. 25 | Libs: -L${libdir} -lbitcoin -lpthread @boost_LIBS@ @rt_LIBS@ 26 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | /libtool.m4 2 | /lt*.m4 3 | -------------------------------------------------------------------------------- /src/constants.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | 22 | namespace libbitcoin { 23 | 24 | hash_number max_target() 25 | { 26 | hash_number max_target; 27 | max_target.set_compact(max_bits); 28 | return max_target; 29 | } 30 | 31 | uint32_t magic_value() 32 | { 33 | #ifdef ENABLE_TESTNET 34 | return 0x0709110b; 35 | #else 36 | return 0xd9b4bef9; 37 | #endif 38 | } 39 | } // namespace libbitcoin 40 | 41 | -------------------------------------------------------------------------------- /src/math/checksum.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2014 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | namespace libbitcoin { 26 | 27 | void append_checksum(data_chunk& data) 28 | { 29 | uint32_t checksum = bitcoin_checksum(data); 30 | extend_data(data, to_little_endian(checksum)); 31 | } 32 | 33 | uint32_t bitcoin_checksum(data_slice chunk) 34 | { 35 | hash_digest hash = bitcoin_hash(chunk); 36 | return from_little_endian_unsafe(hash.begin()); 37 | } 38 | 39 | bool verify_checksum(data_slice data) 40 | { 41 | // guard against insufficient data length 42 | if (data.size() < checksum_size) 43 | return false; 44 | 45 | data_slice body(data.begin(), data.end() - checksum_size); 46 | auto checksum = from_little_endian_unsafe(data.end() - checksum_size); 47 | return bitcoin_checksum(body) == checksum; 48 | } 49 | 50 | } // namespace libbitcoin 51 | 52 | -------------------------------------------------------------------------------- /src/math/external/zeroize.c: -------------------------------------------------------------------------------- 1 | /* libsodium: utils.c, v0.4.5 2014/04/16 */ 2 | /* 3 | * Copyright (c) 2013-2014 4 | * Frank Denis 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | // TODO: deal with determination of HAVE_SECUREZEROMEMORY and HAVE_MEMSET_S 25 | // These are performance optimizations, not required for security. 26 | void zeroize(void* const buffer, const size_t length) 27 | { 28 | #ifdef HAVE_SECUREZEROMEMORY 29 | SecureZeroMemory(buffer, length); 30 | #elif defined(HAVE_MEMSET_S) 31 | if (memset_s(buffer, (rsize_t)length, 0, (rsize_t)length) != 0) 32 | abort(); 33 | #else 34 | size_t i; 35 | volatile uint8_t* vbuffer = (volatile uint8_t*)buffer; 36 | for (i = 0; i < length; i++) 37 | vbuffer[i] = 0; 38 | #endif 39 | } -------------------------------------------------------------------------------- /src/utility/general.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2015 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace libbitcoin { 31 | 32 | std::string join(const std::vector& words, 33 | const std::string& delimiter) 34 | { 35 | return boost::join(words, delimiter); 36 | } 37 | 38 | std::vector split(const std::string& sentence, 39 | const std::string& delimiter) 40 | { 41 | std::vector words; 42 | boost::split(words, sentence, boost::is_any_of(delimiter), 43 | boost::token_compress_on); 44 | return words; 45 | } 46 | 47 | void trim(std::string& value) 48 | { 49 | boost::trim(value); 50 | } 51 | 52 | } // namespace libbitcoin 53 | 54 | -------------------------------------------------------------------------------- /src/utility/threadpool.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | 23 | namespace libbitcoin { 24 | 25 | using boost::asio::io_service; 26 | 27 | threadpool::threadpool() 28 | : work_(nullptr) 29 | { 30 | } 31 | 32 | threadpool::threadpool(size_t number_threads) 33 | : work_(nullptr) 34 | { 35 | spawn(number_threads); 36 | } 37 | 38 | threadpool::~threadpool() 39 | { 40 | delete work_; 41 | } 42 | 43 | void threadpool::spawn(size_t number_threads) 44 | { 45 | for (size_t i = 0; i < number_threads; ++i) 46 | spawn_once(); 47 | } 48 | void threadpool::spawn_once() 49 | { 50 | if (!work_) 51 | work_ = new io_service::work(ios_); 52 | threads_.push_back(std::thread([this] { ios_.run(); })); 53 | } 54 | 55 | void threadpool::stop() 56 | { 57 | ios_.stop(); 58 | } 59 | void threadpool::shutdown() 60 | { 61 | delete work_; 62 | work_ = nullptr; 63 | } 64 | void threadpool::join() 65 | { 66 | for (std::thread& t: threads_) 67 | { 68 | try 69 | { 70 | t.join(); 71 | } 72 | catch (const std::system_error&) 73 | { 74 | // other than logging, or altering the signature to 75 | // return the error to the join caller, not sure what 76 | // to do here. 77 | } 78 | } 79 | } 80 | 81 | io_service& threadpool::service() 82 | { 83 | return ios_; 84 | } 85 | const io_service& threadpool::service() const 86 | { 87 | return ios_; 88 | } 89 | 90 | async_strand::async_strand(threadpool& pool) 91 | : ios_(pool.service()), strand_(ios_) 92 | { 93 | } 94 | 95 | } // namespace libbitcoin 96 | 97 | -------------------------------------------------------------------------------- /src/utility/timed_section.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | namespace libbitcoin { 26 | 27 | timed_section::timed_section( 28 | const std::string& context, const std::string& section) 29 | : context_(context), section_(section) 30 | { 31 | clock_gettime(CLOCK_REALTIME, &start_); 32 | } 33 | 34 | timed_section::~timed_section() 35 | { 36 | log_debug(context_) << section_ << " " << std::fixed << elapsed(); 37 | } 38 | 39 | double timed_section::elapsed() const 40 | { 41 | timespec end; 42 | clock_gettime(CLOCK_REALTIME, &end); 43 | return 1e3 * (end.tv_sec - start_.tv_sec) + 44 | 1e-6 * (end.tv_nsec - start_.tv_nsec); 45 | } 46 | 47 | } // namespace libbitcoin 48 | 49 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | test_libbitcoin 2 | -------------------------------------------------------------------------------- /test/base16.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | 23 | using namespace bc; 24 | 25 | BOOST_AUTO_TEST_SUITE(base16_tests) 26 | 27 | BOOST_AUTO_TEST_CASE(base16_literal_test) 28 | { 29 | auto result = base16_literal("01ff42bc"); 30 | byte_array<4> expected = {{0x01, 0xff, 0x42, 0xbc}}; 31 | BOOST_REQUIRE(result == expected); 32 | } 33 | 34 | BOOST_AUTO_TEST_CASE(base16_odd_length_invalid_test) 35 | { 36 | const auto& hex_str = "10a7fd15cb45bda9e90e19a15"; 37 | data_chunk data; 38 | BOOST_REQUIRE(!decode_base16(data, hex_str)); 39 | } 40 | 41 | BOOST_AUTO_TEST_CASE(base16_short_hash_test) 42 | { 43 | const auto& hex_str = "f85beb6356d0813ddb0dbb14230a249fe931a135"; 44 | short_hash hash; 45 | BOOST_REQUIRE(decode_base16(hash, hex_str)); 46 | BOOST_REQUIRE_EQUAL(encode_base16(hash), hex_str); 47 | 48 | short_hash expected = {{ 49 | 0xf8, 0x5b, 0xeb, 0x63, 0x56, 0xd0, 0x81, 0x3d, 0xdb, 0x0d, 50 | 0xbb, 0x14, 0x23, 0x0a, 0x24, 0x9f, 0xe9, 0x31, 0xa1, 0x35 51 | }}; 52 | BOOST_REQUIRE(hash == expected); 53 | } 54 | 55 | // TODO: these should be tested for correctness, not just round-tripping. 56 | 57 | BOOST_AUTO_TEST_CASE(base16_round_trip_test) 58 | { 59 | const auto& hex_str = "10a7fd15cb45bda9e90e19a15f"; 60 | data_chunk data; 61 | BOOST_REQUIRE(decode_base16(data, hex_str)); 62 | BOOST_REQUIRE_EQUAL(encode_base16(data), hex_str); 63 | } 64 | 65 | BOOST_AUTO_TEST_CASE(base16_legacy_padded_round_trip_test) 66 | { 67 | const auto& padded_hex = " \n\t10a7fd15cb45bda9e90e19a15f\n \t"; 68 | data_chunk data = decode_hex(padded_hex); 69 | 70 | const auto& unpadded_hex = "10a7fd15cb45bda9e90e19a15f"; 71 | BOOST_REQUIRE_EQUAL(encode_hex(data), unpadded_hex); 72 | } 73 | 74 | BOOST_AUTO_TEST_SUITE_END() 75 | -------------------------------------------------------------------------------- /test/checksum.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | 23 | using namespace bc; 24 | 25 | BOOST_AUTO_TEST_SUITE(checksum_tests) 26 | 27 | BOOST_AUTO_TEST_CASE(checksum_test) 28 | { 29 | data_chunk data = {'d', 'a', 't', 'a'}; 30 | 31 | // No checksum: 32 | BOOST_REQUIRE(!verify_checksum(data)); 33 | 34 | // Valid checksum: 35 | append_checksum(data); 36 | BOOST_REQUIRE_EQUAL(data.size(), 8u); 37 | BOOST_REQUIRE(verify_checksum(data)); 38 | 39 | // Data corruption: 40 | data[0] = 1; 41 | BOOST_REQUIRE(!verify_checksum(data)); 42 | } 43 | 44 | BOOST_AUTO_TEST_SUITE_END() 45 | -------------------------------------------------------------------------------- /test/config.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2015 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | using namespace bc::config; 27 | 28 | BOOST_AUTO_TEST_SUITE(config) 29 | 30 | // TODO: add tests for these config utils. 31 | //find_pair_position(const std::vector& list, const Key& key) 32 | //if_else(bool antecedent, const Consequent consequent, const Alternate alternative) 33 | //insert_sorted(std::vector& list, Type const& element, Predicate predicate) 34 | //join(const std::vector& words, const std::string& delimiter) 35 | //split(const std::string& sentence, const std::string& delimiter) 36 | //trim(std::string& value) 37 | 38 | //BOOST_AUTO_TEST_CASE(config__utilities__test) 39 | //{ 40 | // BOOST_REQUIRE(true); 41 | //} 42 | 43 | BOOST_AUTO_TEST_SUITE_END() // config -------------------------------------------------------------------------------- /test/format.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | 23 | using namespace bc; 24 | 25 | BOOST_AUTO_TEST_SUITE(format_tests) 26 | 27 | // to_{big,little}_endian, from_{big,little}_endian_unsafe 28 | 29 | BOOST_AUTO_TEST_CASE(endian_test) 30 | { 31 | auto le = to_little_endian(123456789); 32 | BOOST_REQUIRE_EQUAL(from_little_endian_unsafe(le.begin()), 33 | 123456789u); 34 | 35 | auto be = to_big_endian(123456789); 36 | BOOST_REQUIRE_EQUAL(from_big_endian_unsafe(be.begin()), 37 | 123456789u); 38 | 39 | std::reverse(le.begin(), le.end()); 40 | BOOST_REQUIRE_EQUAL(from_big_endian_unsafe(le.begin()), 41 | 123456789u); 42 | 43 | auto bytes = data_chunk{ 0xff }; 44 | BOOST_REQUIRE_EQUAL(from_big_endian_unsafe(bytes.begin()), 45 | 255u); 46 | 47 | auto quad = to_little_endian(0x1122334455667788); 48 | BOOST_REQUIRE_EQUAL(from_little_endian_unsafe(quad.begin()), 49 | 0x1122334455667788u); 50 | } 51 | 52 | BOOST_AUTO_TEST_SUITE_END() 53 | -------------------------------------------------------------------------------- /test/hash_number.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | 23 | using namespace libbitcoin; 24 | 25 | BOOST_AUTO_TEST_SUITE(hashnum_tests) 26 | 27 | BOOST_AUTO_TEST_CASE(simple) 28 | { 29 | hash_number target; 30 | uint32_t bits = 486604799; 31 | target.set_compact(bits); 32 | hash_digest block_hash = hash_literal( 33 | "00000000b873e79784647a6c82962c70d228557d24a747ea4d1b8bbe878e1206"); 34 | 35 | BOOST_REQUIRE(!(target <= 0)); 36 | BOOST_REQUIRE(!(target > max_target())); 37 | 38 | hash_number our_value; 39 | our_value.set_hash(block_hash); 40 | BOOST_REQUIRE(!(our_value > target)); 41 | } 42 | 43 | BOOST_AUTO_TEST_CASE(work) 44 | { 45 | hash_number orphan_work = 0; 46 | BOOST_REQUIRE_EQUAL(encode_base16(orphan_work.hash()), encode_base16(null_hash)); 47 | orphan_work += block_work(486604799); 48 | BOOST_REQUIRE_EQUAL(encode_base16(orphan_work.hash()), 49 | "0100010001000000000000000000000000000000000000000000000000000000"); 50 | hash_number main_work = 0; 51 | BOOST_REQUIRE(!(orphan_work <= main_work)); 52 | } 53 | 54 | BOOST_AUTO_TEST_SUITE_END() 55 | 56 | -------------------------------------------------------------------------------- /test/key_formats.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | 23 | using namespace bc; 24 | 25 | BOOST_AUTO_TEST_SUITE(key_formats_tests) 26 | 27 | static const ec_secret secret = 28 | {{ 29 | 0x80, 0x10, 0xB1, 0xBB, 0x11, 0x9A, 0xD3, 0x7D, 30 | 0x4B, 0x65, 0xA1, 0x02, 0x2A, 0x31, 0x48, 0x97, 31 | 0xB1, 0xB3, 0x61, 0x4B, 0x34, 0x59, 0x74, 0x33, 32 | 0x2C, 0xB1, 0xB9, 0x58, 0x2C, 0xF0, 0x35, 0x36 33 | }}; 34 | 35 | #ifdef ENABLE_TESTNET 36 | static const char wif_compressed[] = 37 | "cRseHatKciTzFiXnoDjt5pWE3j3N2Hgd8qsVsCD4Ljv2DCwuD1V6"; 38 | static const char wif_uncompressed[] = 39 | "92ZKR9aqAuSbirHVW3tQMaRJ1AXScBaSrosQkzpbHhzKrVBsZBL"; 40 | #else 41 | static const char wif_compressed[] = 42 | "L1WepftUBemj6H4XQovkiW1ARVjxMqaw4oj2kmkYqdG1xTnBcHfC"; 43 | static const char wif_uncompressed[] = 44 | "5JngqQmHagNTknnCshzVUysLMWAjT23FWs1TgNU5wyFH5SB3hrP"; 45 | #endif 46 | 47 | BOOST_AUTO_TEST_CASE(is_wif_compressed_test) 48 | { 49 | BOOST_REQUIRE(is_wif_compressed(wif_compressed)); 50 | BOOST_REQUIRE(!is_wif_compressed(wif_uncompressed)); 51 | } 52 | 53 | BOOST_AUTO_TEST_CASE(wif_to_secret_test) 54 | { 55 | BOOST_REQUIRE(secret == wif_to_secret(wif_compressed)); 56 | BOOST_REQUIRE(secret == wif_to_secret(wif_uncompressed)); 57 | } 58 | 59 | BOOST_AUTO_TEST_CASE(secret_to_wif_test) 60 | { 61 | BOOST_REQUIRE_EQUAL(secret_to_wif(secret, true), 62 | std::string(wif_compressed)); 63 | BOOST_REQUIRE_EQUAL(secret_to_wif(secret, false), 64 | std::string(wif_uncompressed)); 65 | } 66 | 67 | BOOST_AUTO_TEST_SUITE_END() 68 | -------------------------------------------------------------------------------- /test/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #define BOOST_TEST_MODULE libbitcoin tests 21 | #include 22 | 23 | -------------------------------------------------------------------------------- /test/satoshi_words.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) 3 | * 4 | * This file is part of libbitcoin. 5 | * 6 | * libbitcoin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License with 8 | * additional permissions to the one published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) 10 | * any later version. For more information see LICENSE. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Affero General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program. If not, see . 19 | */ 20 | #include 21 | #include 22 | 23 | BOOST_AUTO_TEST_SUITE(satoshi_words) 24 | 25 | BOOST_AUTO_TEST_CASE(satoshi_words_mainnet_or_testnet) 26 | { 27 | // Create genesis block. 28 | auto block = bc::genesis_block(); 29 | 30 | // Genesis block contains a single coinbase transaction. 31 | BOOST_REQUIRE_EQUAL(block.transactions.size(), 1); 32 | 33 | // Get first transaction in block (coinbase). 34 | const bc::transaction_type& coinbase_tx = block.transactions[0]; 35 | 36 | // Coinbase tx has a single input. 37 | BOOST_REQUIRE_EQUAL(coinbase_tx.inputs.size(), 1); 38 | const bc::transaction_input_type& coinbase_input = coinbase_tx.inputs[0]; 39 | 40 | // Convert the input script to its raw format. 41 | const bc::data_chunk& raw_message = bc::save_script(coinbase_input.script); 42 | 43 | // Convert to a string after removing the 8 byte checksum. 44 | BOOST_REQUIRE_GT(raw_message.size(), 8u); 45 | std::string message; 46 | message.resize(raw_message.size() - 8); 47 | std::copy(raw_message.begin() + 8, raw_message.end(), message.begin()); 48 | 49 | BOOST_REQUIRE_EQUAL(message, "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"); 50 | } 51 | 52 | BOOST_AUTO_TEST_SUITE_END() 53 | -------------------------------------------------------------------------------- /version: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/libbitcoin-system-Google-Colab/4526ba69ae9700d19deada2e4f6b88a47129314c/version -------------------------------------------------------------------------------- /version.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2014-2015 libbitcoin developers (see COPYING). 3 | // 4 | // GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY 5 | // 6 | /////////////////////////////////////////////////////////////////////////////// 7 | #ifndef LIBBITCOIN_VERSION_HPP 8 | #define LIBBITCOIN_VERSION_HPP 9 | 10 | #define LIBBITCOIN_VERSION "2.8.0" 11 | 12 | #endif 13 | --------------------------------------------------------------------------------