Upload
swansontec
View
214
Download
0
Tags:
Embed Size (px)
Citation preview
libbitcoin
Typical Bitcoin Company
ApplicationCentralized
APIProvider
Gem, Chain,Blockchain.info,
Coinbase,BlockCypher, ...
Shopping, Escrow,Smart contracts,
Tipping, etc...
libbitcoin is a Blockchain API
Applicationlibbitcoin-
server
Open Source,Decentralized
Shopping, Escrow,Smart contracts,
Tipping, etc...
libbitcoin is a Power-user CLI Tool
libbitcoin-explorer
(BX)
libbitcoin-server
Scripting, Research,Exploration, ...
$ bx fetch-height345896
libbitcoin is a Blockchain Toolkit
libbitcoin
libbitcoin-blockchain libbitcoin-client
libbitcoin-node
libbitcoin-server
libbitcoin-explorer
Server Stack Client Stack
Why does this matter?
● Right now, most of the network runs a single piece of software (the Satoshi node)
● The Bitcoin Foundation controls this software
● Monocultures are bad!
● libbitcoin is a complete third-party Bitcoin Blockchain implementation
libbitcoin Users
● DarkWallet
● OpenBazaar
● AirBitz
libbitcoin Tour
libbitcoin
libbitcoin-blockchain libbitcoin-client
libbitcoin-node
libbitcoin-server
libbitcoin-explorer
Server Stack Client Stack
libbitcoin
● Modern C++11 codebase.
● Designed as a collection of simple, decoupled classes
● You can use as much or as little funtionality as you like
libbitcoin
● Basic blockchain types– Blocks, Transactions, Scripts, Crypto primitives, ...
● Wallet types– Base58, Addresses, URLs, HD keys, Message signing, …
● P2P Protocol
libbitcoin Tour
libbitcoin
libbitcoin-blockchain libbitcoin-client
libbitcoin-node
libbitcoin-server
libbitcoin-explorer
Server Stack Client Stack
libbitcoin-blockchain
● High-performance blockchain database
● Custom-designed on-disk hash table
● Rich indexes for high-speed queries– Transactions
– Addresses
– Stealth
libbitcoin Tour
libbitcoin
libbitcoin-blockchain libbitcoin-client
libbitcoin-node
libbitcoin-server
libbitcoin-explorer
Server Stack Client Stack
libbitcoin-server
● Formerly known as “obelisk”
● Provides a low-level Blockchain API
● Uses ZeroMQ
libbitcoin-server
● fetch_history
● fetch_transaction
● fetch_last_height
● fetch_block_header
● fetch_transaction_index
● fetch_stealth
● broadcast_transaction
● subscribe
libbitcoin Tour
libbitcoin
libbitcoin-blockchain libbitcoin-client
libbitcoin-node
libbitcoin-server
libbitcoin-explorer
Server Stack Client Stack
libbitcoin-client
● C++ wrapper around the libbitcoin-server RPC interface
● Server API calls are as easy as calling a C++ function
darkwallet/python-obelisk
● For those who want to use libbitcoin-server from python
darkwallet/gateway
● Bridges libbitcoin-server to Websockets
● For those who want to use libbitcoin-server from Javascript
libbitcoin Tour
libbitcoin
libbitcoin-blockchain libbitcoin-client
libbitcoin-node
libbitcoin-server
libbitcoin-explorer
Server Stack Client Stack
libbitcoin-explorer
● Short name is “bx”
● Replaces an earlier project called “sx”
● Command-line interface to lots of Bitcoin goodies
libbitcoin-explorer
● Server Commands– fetch-balance, fetch-header, fetch-height, fetch-history, fetch-public-key, fetch-stealth, fetch-tx, fetch-tx-index, fetch-utxo
● Wallet– input-set, input-sign, input-validate, message-sign, message-validate, send-tx, send-tx-node, send-tx-p2p, tx-decode, tx-encode, tx-sign
libbitcoin-explorer
● HD Keys– hd-new, hd-private, hd-public, hd-to-address, hd-to-ec, hd-to-public, hd-to-wif
● EC Math– ec-add, ec-add-secrets, ec-lock, ec-multiply, ec-multiply-secrets, ec-new, ec-to-address, ec-to-public, ec-to-wif, ec-unlock
● Hashes– bitcoin160, bitcoin256, sha160, sha256, sha512, ripemd160
libbitcoin-explorer
● Format conversions– address-decode, address-encode– base16-decode, base16-encode– base58-decode, base58-encode– base64-decode, base64-encode– btc-to-satoshi, satoshi-to-btc– wif-to-ec, wif-to-public
● And lots more…
Installing bx
● Available as a single-file pre-compiled binary:– https://github.com/libbitcoin/libbitcoin-
explorer/wiki/Download-BX
– Linux, OS X, and Windows!
● Or you can compile it yourself:– https://github.com/libbitcoin/libbitcoin-explorer
– Use the install.sh script for an hands-off compile, including dependencies
– Or follow the manual build instructions
Installing libbitcoin-server
● Stable binaries are not yet available– Hopefully soon!
● Source code is here:– https://github.com/libbitcoin/libbitcoin-server
● To run:$ initchain$ bitcoin_server
libbitcoin-server Servers
● https://wiki.unsystem.net/en/index.php/Obelisk/Servers
● The BX default is tcp://obelisk.airbitz.co:9091
● Feel free to use the AirBitz servers!
– If you install your own servers,please let us use them too
Installing libbitcoin
● Source code is here:– https://github.com/libbitcoin/libbitcoin
libbitcoin Example#include <bitcoin/bitcoin.hpp>#include <iostream>#include <string.h>
int main(){ char line[256]; std::cout << "Please enter a secret phrase: "; std::cin.getline(line, 256); bc::data_chunk seed(line, line + strlen(line));
bc::hash_digest hash = bc::sha256_hash(seed); std::cout << "Hash: " << bc::encode_base16(hash) << std::endl; std::cout << "Private key: " << bc::secret_to_wif(hash) << std::endl;
bc::payment_address address; bc::set_public_key_hash(address, bc::bitcoin_short_hash(bc::secret_to_public_key(hash))); std::cout << "Address: " << address.encoded() << std::endl; return 0;}
libbitcoin Example - Header
#include <bitcoin/bitcoin.hpp>
libbitcoin Example – Grab some text
char line[256];
std::cout << "Please enter a secret phrase: ";
std::cin.getline(line, 256);
bc::data_chunk seed(line, line + strlen(line));
libbitcoin Example – Hashing
bc::hash_digest hash = bc::sha256_hash(seed);
std::cout << "Hash: " <<
bc::encode_base16(hash) << std::endl;
std::cout << "Private key: " <<
bc::secret_to_wif(hash) << std::endl;
libbitcoin Example – Addresses
bc::payment_address address;
bc::set_public_key_hash(address,
bc::bitcoin_short_hash(
bc::secret_to_public_key(hash)));
std::cout << "Address: " <<
address.encoded() << std::endl;
libbitcoin Example – Makefile
CXXFLAGS = $(shell pkg-config --cflags libbitcoin)
LIBS = $(shell pkg-config --libs libbitcoin)
test: test.o
$(CXX) -o test test.o $(LIBS)
test.o: test.cpp
$(CXX) -c -o test.o test.cpp $(CXXFLAGS)
Future Plans
● New libbitcoin-server protocol– We want a full query language
– libbitcoin-protocol
● SPV client library– libitcoin-server is fast, so we don't want to lose that
– The client uses block headers to verify server responses
Slides
● Slides are here:– http://www.slideshare.net/swansontec/libbitcoin-
slides