libcoin Michael Gronager, PhD Director, Ceptacle [email protected]

Bitcoin2012 Convention San Antonio, Bitcoin Convention San2012 Antonio, TX TX March 17 2012

libcoin - intro ●

It is not another crypto currency



It is not a rewrite of bitcoin



It is not yet another client

Bitcoin Convention 2012 San Antonio, TX March 17 2012

2

libcoin - intro ●

It is not another crypto currency



It is not a rewrite of bitcoin



It is not another client



● ●

It is the refactorization of bitcoin into a modular library It is chain agnostic You can build bitcoind, and bitcoin-Qt on libcoin

Bitcoin Convention 2012 San Antonio, TX March 17 2012

3

libcoin - motivation ●

Building thin clients in C++



Faster / More predictable http interface



● ●

Support ideas from other chains / crypto currencies (e.g. freicoin) and consolidate efforts. Separate client(s) from core functionality Facilitate education, research and innovation

Bitcoin Convention 2012 San Antonio, TX March 17 2012

4

libcoin - paradigm ●

No globals



High level of Concurrency



Clean classes with interfaces



Keep as much as possible of the original code



Keep bitcoind functional at all times!



Faster chain download

Bitcoin Convention 2012 San Antonio, TX March 17 2012

5

libcoin - license ●

It is a library – so LGPL3!



Why move away from MIT?





libcoin is include and reuse as opposed to copy and compete



Aims at being a basic library for several crypto currencies

Open for other arguments...

Bitcoin Convention 2012 San Antonio, TX March 17 2012

6

libcoin - structure

Bitcoin Convention 2012 San Antonio, TX March 17 2012

7

libcoin - structure ●

Basic library: coin –

Depends only on boost



Keys, Scripts, Coins, Transactions and Blocks



E.g. for thin clients

Bitcoin Convention 2012 San Antonio, TX March 17 2012

8

libcoin - structure ●

Basic library: coin



HTTP library: coinHTTP –

An Async HTTP server



Support for JSON RPC (POST)



Cached HTTP GET



HTTP Client



BasicAuth, TLS/SSL



Depends only on boost



Main interface class: Server

Bitcoin Convention 2012 San Antonio, TX March 17 2012

9

libcoin - structure ●

Basic library: coin



HTTP library: coinHTTP



P2P library: coinChain –

Async P2P client



Maintains the block chain



Chain agnostic via Chain class



Ads dependency on BDB



Main interface class: Node

Bitcoin Convention 2012 San Antonio, TX March 17 2012

10

libcoin - structure ●

Basic library: coin



HTTP library: coinHTTP



P2P library: coinChain



Wallet library: coinWallet –

“the bitcoin wallet”

Bitcoin Convention 2012 San Antonio, TX March 17 2012

11

libcoin - structure ●

Basic library: coin



HTTP library: coinHTTP



P2P library: coinChain



Wallet library: coinWallet



Mining library: coinMine –

Pluggable mining



Fully Async

Bitcoin Convention 2012 San Antonio, TX March 17 2012

12

libcoin - structure ●

Basic library: coin



HTTP library: coinHTTP



P2P library: coinChain



Wallet library: coinWallet



Mining library: coinMine



NAT services: coinNAT –

UPnP/IDG Port mapping



NAT-PMP Port mapping (for e.g. AirPort)

Bitcoin Convention 2012 San Antonio, TX March 17 2012

13

libcoin - structure ●

Basic library: coin



HTTP library: coinHTTP



P2P library: coinChain



Stat library: coinStat –

Build your own block explorer



PubKeyHash->Transaction mapping



ScriptHash->Transaction mapping

Bitcoin Convention 2012 San Antonio, TX March 17 2012

14

libcoin - examples ●

20 lines client: simple client



Coin agnostic: create a new currency



Modular: An extra wallet



Statistics: coin explorer

Bitcoin Convention 2012 San Antonio, TX March 17 2012

15

libcoin – simple client ●

Write a bitcoin client in 20 lines



Includes:

#include #include #include #include #include using namespace std; using namespace boost;

Bitcoin Convention 2012 San Antonio, TX March 17 2012

16

libcoin – simple client ●

Write a bitcoin client in 20 lines



Setup node and wallet – Start the Node:

int main(int argc, char* argv[]) { logfile = CDB::dataDir(bitcoin.dataDirSuffix()) + "/debug.log"; Node node; // deafult chain is bitcoin Wallet wallet(node); // add the wallet thread nodeThread(&Node::run, &node); // run this as a background thread

Bitcoin Convention 2012 San Antonio, TX March 17 2012

17

libcoin – simple client ●

Write a bitcoin client in 20 lines



Setup Server and register methods: Server server; server.registerMethod(method_ptr(new Stop(server))); server.registerMethod(method_ptr(new GetBlockCount(node))); server.registerMethod(method_ptr(new GetConnectionCount(node))); server.registerMethod(method_ptr(new GetDifficulty(node))); server.registerMethod(method_ptr(new GetInfo(node))); // Register Wallet methods. server.registerMethod(method_ptr(new GetBalance(wallet))); server.registerMethod(method_ptr(new SendToAddress(wallet)), Auth("username","password"));

Bitcoin Convention 2012 San Antonio, TX March 17 2012

18

libcoin – simple client ●

Write a bitcoin client in 20 lines



Start Server and clean up: server.run(); node.shutdown(); nodeThread.join();

}

return 0;

Bitcoin Convention 2012 San Antonio, TX March 17 2012

19

libcoin – a new currency ●

libcoin is chain agnostic – lets create a new currency: Ponzicoin!

class PonziChain : public Chain { public: PonziChain(); virtual const Block& genesisBlock() const ; virtual const uint256& genesisHash() const { return _genesis; } virtual const int64 subsidy(unsigned int height) const ; virtual bool isStandard(const Transaction& tx) const ; virtual const CBigNum proofOfWorkLimit() const { return CBigNum(~uint256(0) >> 20); } virtual unsigned int nextWorkRequired(const CBlockIndex* pindexLast) const ; virtual bool checkPoints(const unsigned int height, const uint256& hash) const { return true; } virtual unsigned int totalBlocksEstimate() const { return 0; }

Bitcoin Convention 2012 San Antonio, TX March 17 2012

20

libcoin – a new currency ●

libcoin is chain agnostic – lets create a new currency: Ponzicoin!

...

virtual const std::string dataDirSuffix() const { return "ponzicoin"; } virtual ChainAddress getAddress(PubKeyHash hash) const { return ChainAddress(0xff, hash); } virtual ChainAddress getAddress(ScriptHash hash) const { return ChainAddress(); } virtual ChainAddress getAddress(std::string str) const { ChainAddress addr(str); if(addr.version() == 0xff) addr.setType(ChainAddress::PUBKEYHASH); return addr; } virtual const MessageStart& messageStart() const { return _messageStart; }; virtual short defaultPort() const { return 5247; } virtual std::string ircChannel() const { return "ponzicoin"; } virtual unsigned int ircChannels() const { return 1; } // number of groups to try

Bitcoin Convention 2012 San Antonio, TX March 17 2012

21

libcoin – a new currency ●

Define subsidy and nextWorkRequired:

const int64 PonziChain::subsidy(unsigned int height) const { int64 s = 50 * COIN; // Subsidy is cut in half every week s >>= (height / 10080);

} ...

return s;

Bitcoin Convention 2012 San Antonio, TX March 17 2012

22

libcoin – a new currency ●

Define the node Node node(ponzicoin);





This is all we need! Note: Some currencies have further subtleties: –

freicoin: demurrage (coins get old)



namecoin: extended protocol



...

Bitcoin Convention 2012 San Antonio, TX March 17 2012

23

libcoin - an extra wallet? … define node stuff... Wallet wallet(node, "wallet.dat"); // add the wallet Wallet extra_wallet(node, "extra_wallet.dat"); // add the extra wallet // Register Wallet methods. - note that we don't have any auth, so anyone (on localhost) can read your balance! server.registerMethod(method_ptr(new GetBalance(wallet))); server.registerMethod(method_ptr(new SendToAddress(wallet)), Auth("username","password")); GetBalance* extragetbalance = new GetBalance(extra_wallet); extragetbalance->setName("extragetbalance"); server.registerMethod(method_ptr(extragetbalance)); SendToAddress* extrasendtoaddress = new SendToAddress(extra_wallet); extrasendtoaddress->setName("extrasendtoaddress"); server.registerMethod(method_ptr(extrasendtoaddress), Auth("username","password"));

Bitcoin Convention 2012 San Antonio, TX March 17 2012

24

libcoin - coin explorer Node node(chain); Explorer explorer(node); // this will register notifications for new blocks and transactions thread nodeThread(&Node::run, &node); // run this as a background thread string search_page = "libcoin - Coin Explorer" "

" "" "

" "
"; Server server(rpc_bind, search_page)); // Register Node methods. server.registerMethod(method_ptr(new GetBlockCount(node))); server.registerMethod(method_ptr(new GetConnectionCount(node))); server.registerMethod(method_ptr(new GetDifficulty(node))); server.registerMethod(method_ptr(new GetInfo(node)));

Bitcoin Convention 2012 San Antonio, TX March 17 2012

25

libcoin - coin explorer ●

Register methods: –

Getdebit, credit, coins, addrbalance, search

// Node methods relevant for coin explorer server.registerMethod(method_ptr(new GetBlock(node))); server.registerMethod(method_ptr(new GetBlockHash(node))); server.registerMethod(method_ptr(new GetTransaction(node))); // Register Explorer methods. server.registerMethod(method_ptr(new GetDebit(explorer))); server.registerMethod(method_ptr(new GetCredit(explorer))); server.registerMethod(method_ptr(new GetCoins(explorer))); server.registerMethod(method_ptr(new GetAddressBalance(explorer))); server.registerMethod(method_ptr(new Search(explorer)));

Bitcoin Convention 2012 San Antonio, TX March 17 2012

26

libcoin – future ●

coin: remove dependency of openssl/libcrypto



coinHTTP: methods as plugins



coinChain: header only, BDB->SQLite/memory



coinMine: reuse puddinpop miners as plugins



Update everything to 0.6 incl libcoin/Bitcoin-Qt

Bitcoin Convention 2012 San Antonio, TX March 17 2012

27

libcoin – try it – use it! ●

Wiki: –



Github: –



github.com/ceptacle/libcoin

Twitter: –



github.com/ceptacle/libcoin/wiki

follow libcoin

Mailinglists: –

Bitcoin-dev / forums

Bitcoin Convention 2012 San Antonio, TX March 17 2012

28

March 17 2012 Bitcoin Convention 2012 San Antonio, TX 17 ... - GitHub

Mar 17, 2012 - Page 1 ... It is chain agnostic. ○ You can build bitcoind, and bitcoin-Qt on libcoin ... Stat library: coinStat. – Build your own block explorer.

6MB Sizes 0 Downloads 146 Views

Recommend Documents

06 17 12 Newsletter June 17 2012.pdf
She remembers Count John McCormack singing at the big. mass in the Phoenix Park. Fr. Louis Ryan was the Parish Priest of Saggart at this time and he is the ...

September 17, 2012 Minutes.pdf
We also need to replace and move some of the football field lights. and are having a ... Indianapolis, Indiana in October. Ayes-Groth ... The board scheduled the next work session for October 22, 2012 beginning at 6:00 P.M. in the. Mac Lab.

August 17, 2012 Chautauqua
A2 The Chautauqua. Friday, August 17, 2012. Alix, Bashaw, Clive, Delburne, Donalda, Elnora, Erskine, Forestburg, Haynes, Lousana, Mirror, Pine Lake, Tees & Trochu. By the time ..... All of the clocks in the movie "Pulp Fiction" are stuck on 4:20. •

Minutes February 17, 2012.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Minutes ...

EME - 17-12-2012 -
become; your churning of the ocean of knowledge will continue and you will be able to imbibe jewels well. Question: What are the signs of souls who don't have ...

17 - GitHub
of analytical tools allows to create more and more sophisticated computing systems. In ... JIM made possible the initial data preparation and, at the later analytic stage, ...... http://www.ii.uj.edu.pl/%7Epodolak/pub/sn1/sn1foils-perceptron.pdf 26.

AT1 March 2012 (Past Examination)
Mar 1, 2012 - 3) A risk-averse manager will undertake earnings management activities. ... is a big positive [for the argument] that convergence can be done.” Required. 4 ..... price variability can be estimated from historical share price data.

March 2012 Message.pdf
enchiladas, tamales, posole, beans, bread and dessert. Tax and gratuities are included. $5 Continental Breakfast (7/21) at Velarde _____Number attending _____Amount due. _____Number attending who would like to ride in the McCurdy bus. $5 Continental

March 2012 Message.pdf
Could United Breth- ren Missionary and Deaconess Mellie Perkins, who started the mission school in. Velarde, New Mexico in 1912, have dreamed her work would continue into the. next century? Could she have imagined how many lives would be affected by.

12-17-2012 Council Agenda w Supporting doc.pdf
15. Resolution establishing the 2013 regular meetings of the Jamestown City Council. 16. Resolution designating the Post-Journal as the official newspaper for publications for. the Period January 1, 2013 – December 31, 2013. 17. Resolution granting

march 17 high.pdf
Grilled Cheese. Sweet potatoes. Blackeye peas. Apple Peaches. Milk. Wheat Doughnut. Applesauce juice Milk. Garden Salad w/ Herb Chicken. or. Teriyaki Beef ...

6/17/2012 Prof. K. Pushpa,SVECW, Bhimavaram -
EC (Echo Canceller): Used on the PSTN side of the MSC for all voice circuits. XC (Transcoder): Usually installs in each BTS. But for the cost reason, it can be installed in BSC ... GGSN (Gateway GPRS Support Node): The point of interface with externa

NLUO Placement Brochure -2012-17.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item.

Safety-Protocol-Letter-December-17-2012.pdf
Page 1 of 2. Ralph C. Mahar Regional School District. 507 South Main Street. P.O. Box 680. Orange, Massachusetts 01364. Telephone: 978/544-2920 Fax: ...

17 March-April.pdf
Page 1 of 27. SHRINERS INTERNATIONAL. KENA SHRINERS. DESERT OF VIRGINIA. OASIS OF FAIRFAX. Volume LXIV MARCH — APRIL 2017 Number 2. KENAGRAM. Noble Larry Parks. & Lady Tami. Noble Peter Klei. & Lady Rosemarie. Noble Geoffrey Lyster. & Lady Theresa.

San Antonio Rosters.pdf
33 Harold Myart III 2019 6-0 Austin Marcus Hill 2020 6'3 Round Rock. Page 1 of 17 ... 13 Kameron Ross 2019 5'8 Robert E Lee 9 Tyler Wright 2022 6-0 Boerne Champion ... 5 Jarius Hicklen 2019 6'3 Desoto 14 Trey Robinson 2023 St. Annes.

Coroutines in C++17 - GitHub
http://isocpp.org/files/papers/N4403.pdf ... to a function call overhead) ... coroutines call. Allocate frame, pass parameters. Allocate frame, pass parameters return.

Brooklyn Community District 17 - GitHub
Transportation/Utility. Public/Institutional. Open Space. Parking. Vacant. Other. 11,941. 3,743. 138. 1,098. 305. 197. 64. 259. 15. 233. 202. 65. U tica. A v ... Farragut, Flatbush, Northeast Flatbush, Remsen Village, Rugby, Erasmus. Top 3 pressing i

40500078 Marco Antonio Martin Jesus Gutti Saba 2012.pdf ...
Page 1 of 1. 40500078 Marco Antonio Martin Jesus Gutti Saba 2012.pdf. 40500078 Marco Antonio Martin Jesus Gutti Saba 2012.pdf. Open. Extract. Open with.

VMM Newsletter March 2012.pdf
Download. Connect more apps... Try one of the apps below to open or edit this item. VMM Newsletter March 2012.pdf. VMM Newsletter March 2012.pdf. Open.

Minutes March 2, 2012.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Minutes March 2 ...

march 31st · 2012 march31.net
europe is in a continuous state of upheaval. for months now, its credit– and sovereign debt crises have been escalating. a number of hectic european union ( eu ) summits have introduced emergency measures to rescue capitalism. should the se measure

Aguilar TX CCA 9-20-17.pdf
1 day ago - The habeas judge again. recommended we grant Aguilar relief. Page 3 of 23. Aguilar TX CCA 9-20-17.pdf. Aguilar TX CCA 9-20-17.pdf. Open.

tsp_tax notice_printed March 2012.pdf
(IRS), and to you, on IRS Form 1099-R, Dis- tributions From Pensions, Annuities, Retire- ment or Profit-Sharing Plans, IRAs, Insurance. Contracts, etc. Distributions from beneficiary. participant accounts will be reported as death. payments on IRS Fo