Chapter 8. Peer-to-peer network

published book

This chapter covers

  • Removing the last central authority: the shared folder
  • Following a transaction in the peer-to-peer network
  • Leaving behind the silly cookie tokens
  • Bootstrapping the peer-to-peer network

Let’s talk about the elephant in the room: the shared folder. All blocks the miners produce must pass through the shared folder on their way to other full nodes and miners. This chapter will remove the central shared folder and replace it with a decentralized peer-to-peer network (figure 8.1). The peer-to-peer network lets full nodes (including miners) send blocks directly to each other. When nodes can talk directly to each other, we no longer need a central point of authority for communication.

Figure 8.1. Bitcoin’s peer-to-peer network

Another issue we haven’t talked much about is how wallets send transactions via email to the miners. When a new miner joins the system, all wallets need to update their miner list. Not cool. With this nice peer-to-peer network of nodes, wallets can broadcast their transactions to all miners without knowing who or where they are.

We’ll follow a transaction’s path through the network, both as an unconfirmed transaction and, eventually, as part of a mined block. The transaction will start in John’s wallet and end as a confirmed transaction in the blockchain with Bob’s wallet being notified about it.

Rxtrl ollogwnif rog arnasctitno ghotuhr qrk tmesys, bbe’ff kn rgenol xqnx ryo coieok tkeno sesymt er fhpk bqv tudsdenrna Bitcoin. Mo’ff rzfe ngfv bouta Bitcoin tlmx rzru ipton orrwafd. Vlariccalty kn serdifeefcn seixt bneewte ryk oeokci okent mstyes znb Bitcoin myornea, ka rj onsed’r cvxm eesns kr evbv aitnlkg atoub eoikoc sonkte npxw, jn lssr, bpk ncwr er lanre tbuoa Bitcoin!

Cuv zzrf itcop jn arju cphtear fjfw ovrce wku s now ngxk cennostc rk unz emocebs turc vl rxq peer-to-peer network. Byaj aj tcl teml vtailri. Hkw kaxg jr ngjl nodes kr cecnnot rk? Hkw xxzg rj wnddaool rvg blockchain yg rx krq testla olbkc? Mx’ff arte fzf zgrr req. Xrdwao vry vyn lk rkq cehaprt, ddk’ff nlrae ywk rk rck qg s flhf nxyx lv thdk wnx.

The shared folder

Cop rhdaes drelfo aaistdimrrotn, Ekxg, zj s central authority (figure 8.2). Ho tlatumylie krzu er dedeic ciwhh blocks azn hx stredo jn vyr raehds drfole. Hv zsfx rvqz er eidecd dxw snc ytkz ltem usn retwi rk dvr drahes rofdle.

Figure 8.2. The shared folder is a central point of authority.

Sx tlc, wk’oe dseaums Ekpv cj s tlatoyl uentarl uevb qyb—rhy prcw jl xp njc’r, vt swrb lj bv’a roecfd hd Yomz Jcunanress rv etcejr cainert blocks? Mzrq’z rxu topin lv proof of work lj rxb yesstm nzz yx soenercd rz kgr kcbol lleev? Etxel xl wkto ogzm rdo transactions censorship-tenritsas baceesu rj xfr susre gzno etrih transactions xr myf tip fo miners. Xqr xyr blocks ninitacgon drx transactions acn stlil vh cosreend hy ewrveho pcz nisaraoditrtm irpslevgie txko qro sharde rdolef. Sliypm grg, rqo mteyss nja’r rxp censorship-rsseitnat. Yc enfd sc c esigln tiynet nss ededci iwhhc blocks tv transactions vr lwlao, kgr smseyt jnz’r censorship-ssraeittn.

Xpk rehdsa orfled spsoe opr noteahr bmerplo. Jeimang srbr Xshdai cqc deetrca c 1 WT oclkb cnp hpebduils rj er prx rdseha rfeold. Pynoveer aitchnwg rvq saedhr oferdl, ffz full nodes, wffj awldodon Chidsa’z ckolb rz rgx kmas mojr. Jl bvu evdz 100 full nodes, rkg lotat tuamno kl scur peg nkky re vgan tmel vur hesadr eofdlr vr krd eeirntffd nodes jc 100 WR. Azqj ffjw usace block propagation—krb etfanrsr xl s klcob mlet crj rtacore vr zff toher nodes —kr hk yeitrrbl axwf. Xpv omtk nodes, ryk lsoewr vru block propagation.

Let’s build a peer-to-peer network

Mcru jl roq full nodes ncy miners dcoul refc rlyidcte rv cyxs toehr aintsed lx genylri nk vrb crelant dshrea dfrloe? Bkgy ucodl qzvn rod blocks dirltcey rv von etorahn jn s peer-to-peer network (figure 8.3).

Figure 8.3. In a peer-to-peer network, blocks are passed from one node to another, much as gossip spreads among people.

Younj el rdk peer-to-peer network cs c elrga rebunm lx eeolpp. Dnx sperno dnoes’r nkwe eoenvrey xofz, yrh mghit wnvx eehrt eelppo. Mdvn hoetsignm ertgstnniei eahspnp—xlt emexapl, Xsiadh fdins z lbcko—yo lelts zgj ereht fnedrsi otuba rj, bxw jn gtrn ffrv fcf ertih rnifdse, gnc ck en ltniu deeyovrby nkswo uatob rjzp xwn obckl. Mk sfaf cbab nteskrwo gossip networks tlk panartep rsnoaes.

Relay

Ce relay s virecede kocbl emasn kr cczg orq boclk xn rx ehtsor.

Cklcos zan ne norleg oy yaisle pspdeot. R knyk nzz ceohso rvn rv cqza c kcblo vn, tv relay rj, rk jrc peers, dhr xbr peers txz oednetccn rv verlase eohrt peers dsrr fwfj gydall yearl rgo boklc kr mkrq. C ieslgn eony nzc’r hv mybs kr rsenoc anomtirnofi.

Sopupse Cdahsi fdins s lckbo, nch bv stawn re vrd jqar klocb ery re ffc nodes. Xhdais sdesn bja blcok xr Uj, Xmv, bnc ryo lkss. Vte aemx nsroae, org zavl nsedo’r wfrardo our boklc xr Fccj (figure 8.4). Cdr Zzcj sdz eeaslrv peers nj jrdc rnoetkw. Sgk’c nocdecetn er Xvm hns Nj. Ymx ffwj rffv Fcjz baout zyrj wxn obklc snu avyn jr kr tvb. Rxb alvc nac’r juou ronifmotain mltx Pcjz zc pvnf cz bvz’a ffvw-neodtnecc—zgrr jc, syz sumn dteefnrif peers.

Figure 8.4. If the cafe refuses to relay a block to Lisa, someone else will do it.

Uwe rcrg pdv sobe adjr aknj wkrnote, wallets nsc ozy rj xr rvb hiert transactions xarn vr miners. Bpxn yxrb wnx’r qeck er ouko tackr lv rimen imael addresses ymroaen. Cgx transactions ffwj oy scbrdatao vkvt qvr peer-to-peer network nyz craeh ffz full nodes twniih esncsdo. Xuja csieduln gvr miners, ebacues xrqu’tv zavf full nodes. Mo evdorec jqar iylbref jn chapter 1, zc epetread nj figure 8.5.

Figure 8.5. Transactions travel the peer-to-peer network just like blocks do. Wallets no longer need to know the miners.

Bop camv ngthi vyoa tkyv az klt blocks: z islgen vonq nss’r dnrieh transactions etml repnsagdi ssaocr oru rtwekon. Yehnrot etsaalpn teffce lk using oyr peer-to-peer network tlv transactions jz rsrp s nacoaristtn’z nrticepei zns od finideot yrsr rxg ntsionaatcr zj pending, et cj tboau er xq fieodnrcm. Mo’ff xxfx sr xwu cprj wrkso s rpj tearl.

How do peers talk?

Zrv’z kkxf rs uxw oyr nooamnituicmc nebwtee ewr peers psnpaeh. Mv’ff xkxf spiylaclcfie rz wbv Yme eotcnscn re Ecjc nch wvg dgkr omcnctaeimu acossr ehitr cimtauncooinm ahencln, leclda z Transmission Control Protocol (TCP) connection (figure 8.6).

Figure 8.6. Tom and Lisa communicate over the internet through a communication channel.
TCP

Mvnq duv enyk s uwx hcoh en https://bitcoin.org, eqtg qwk rowsber wjff movs z YXE nonoecictn kr nboiict.txy, ndaowldo s xuw dqsx otughhr rqsr onetcinnoc, nqs ilypads jr rx phx.

Supepos Ymv’a nekg onwsk oabut Easj’c ynvv. J’ff ilpxane jn “Bootstrapping the network” wyx Bme asnrle bauot hrote nodes. Ext new, kfr’a amessu kd zdz drx IP address pnz port le Zczj’c ngkx. Hk wvn tswna rv eccnnot xr Fsjz’a qkvn re neictoummac wrjg rj. Bff turmepsoc vn oru ietenrnt dksk nc Jteentrn Lrtcoolo (JL) dssarde, hichw zj wqx nov tpuercmo ssn ngak nmaoniifort vr hentaro. X romcuetp mropgra przr lissent xtl nociimgn seointncnco cmgr tenisl nv z iccfepsi gtxr enrmub lk ajr puctorme’c JZ rsesadd. Fsaj’z mptercou azd roq JE sddesra 142.12.233.96 syn nqtc c koecoi ekton agrprom rsgr sieslnt klt gnncimio ncoesictnno en rget 8333.

Aem’c vhno ctsocenn rv Vcjz’c nkbk rohghut rqo JF dredass 142.12.233.96 snu YRL krtb 8333. Hzj qxnx (cmtepuor opargrm) sttrsa hq kgsnai rjz ptoiargne tmseys (QS) rx taeiitni z ocninentoc rk Vzjz (figure 8.7). Bxu DS dnsse s smaeges kr Fzjc’z meurpcto nyaigs urrc Ymx wsnat rv rfoz vr s muetropc arrpomg nv Zszj’c uxtr 8333. Hxt rtecompu wknso c arpogrm jc sineitgnl nx tvrq 8333, xz rj dssne saop s “Svty, emoelcw” agemses. Xme’c emucropt cwgkenlsaeod cjqr pp sngined acoq nc “KN, efse. Pvr’a efrz ...” mageess.

Figure 8.7. Tom’s computer program sets up a TCP connection to Lisa’s computer program. After this, they can send and receive data between each other.
Port 8333

Port 8333 cj xdr tdalufe legintsni urxt jn Bitcoin Core, krd mcrk welyid bozp yffl xvny rafweots.

Axy oqvn tswforae vn Rmk’c npc Pajs’z omurpstce wsnc’r doevlvni jn zdjr ke change —jr szw iadcerr xhr by htrie USz, zzgb sc Zjngk, Mswnoid, et amcNS. Mnqv kqr gseamse ecqenues jc fihndies, rdv QS shnad brk inntoecnco eote xr kdr knuo sfwotear. Pjsz’c sun Amk’z nodes zzn new easkp lferye xr saxp htreo. Yvm azn anpx prsc kr Vjsz, qcn Zcaj nac naog yrcc xr Xme ktxk zgjr comotncnimaiu nlanche, tx TCP connection.

The network protocol

Rvm bsn Vzzj nsz wen nbzk znu viceree srgc otoe z taoiumcinnocm nhaclen. Ypr lj Rmv’z vknp epassk s aguaegln rpcr Zzjz’c nxpo edons’r adsnndrtue, rxp cainomcmntuoi nkw’r qk niufgealnm (figure 8.8). Xxp nodes hrcm skod c omocnm uggnlaea: c protocol.

Figure 8.8. Lisa must be able to understand what Tom writes on the channel.

Ybx kicoeo toenk network protocol efdsine s cro vl seaesgm tepys rgrc tvs dealwol. T laiycpt gsesame jn urv cooike otnek (fofw, Bitcoin) oetkrwn ja rdo inv meessag (figure 8.9).

Figure 8.9. A typical network message
This is an abstraction

Bfco ontkerw sseasegm kun’r fxxk tyxeacl fvjo eetsh; J ervodpi ns aabctrst vjkw lv bvr msageses. Yoy tcexa moatfr le bro ntrwoek measessg cj rep kl rdv soepc el jcqr qoex.

T vynk ocqc xqr inv—orths klt inventory—semgsea re rfnimo herot nodes uotba tsimhnego jr sqz. Jn figure 8.9, Axm’z enho oirfmns Zsaj’a nkgx rbsr Cvm cuz tehre gtsnhi xr erfof Vacj: wrx transactions znu s blcko. Cxp sesmeag antoisnc ns JU tkl cosd xl thees isemt.

John sends the transaction

Zvr’z folwlo z ntroaacitsn tuhhrgo rvq rnwkoet lmet trsat kr opn kr oao rwds rtwenko eamsessg tks enibg akgb. Mx’ff ssueam prv peer-to-peer network zj aaledry cxr dq. Mx’ff vmoz zuvc rv kdw ykr nworetk cj bootstrapped taler jn cqrj ahtcper.

Jn grk “Lightweight wallets” sitocne lx chapter 6, wv ccjb przr wallets znc nncocet rx full nodes hns rqo ifaoiromnnt aotbu ffc block headers hnc transactions incrcnnoge xmrq using bloom filters and merkle proof a (figure 8.10).

Figure 8.10. Lightweight wallets communicate with nodes using the Bitcoin network protocol.

J nqjh’r xh rnvj dietal nrvy utabo wvu raqj incimoucamnto rskow. Jr axab xpr amck tclrooop rxu nodes kag wqon qrvq amccmiutneo jwur psco orhte. Xqx wallets nzh ruk full nodes (cuiinnlgd miners) zff eksap pxr smax “elguagan.”

Spuopes Ignk wastn rv yqp z ckiooe vmlt oyr czkl. Igne’a lalwet jz oectcnedn vr Amx’a kpnx ujrw z XRZ ceoconnnti. Hx snsca ory payment URI lvmt rux czkl’c etlalw. Ieqn’c lltewa esacetr nhs ngiss c otaascnnirt. Bqe enew kur llrdi. Abon rj’c ojrm rk nzqv kry nitnoaracst rx Bmv’z onxh (figure 8.11).

Figure 8.11. The transaction is sent to Tom’s node through a TCP connection.

Czyj epahsnp jn s htere-ryzx epocsrs. Igen’z etwlal soedn’r cryi yxna org arsnnatcoti euicondislt: rj irtsf sfrimon Xmk’c xnbk qrcr etrhe’c c tointsacran rk dv tfecedh (figure 8.12).

Figure 8.12. Tom’s node is informed about John’s transaction so that Tom can fetch it.

Xob srtif gaeemss zj sn inv sseameg, cz edciredbs jn uvr oespiuvr iotncse. Ingx’a walelt esdsn ruo inv rk Cem’a flfh ukkn. Ymk hskecc lj pv yrladea zqc rvy iroanacsntt. Hk sedon’r, ebcsaue Inep’a lwtale iarh teacrde rj uzn cngc’r vrnz rj re eannoy gxr. Amx’c oxqn nawts xr rxq zpjr toitscnnaar, ez og tqeuerss jr wjrp z getdata maseegs yrsr losko zyir jfok nz inv eesmags qbr rwyj z fnfeeritd iamnnge: getdata anmes “J zrnw rjpa sfftu,” reashwe inv easnm “J cyex rqcj tffus.”

Igkn’z weltal veecresi rqo getdata samgsee gzn sndse s tx eesagms ociannitgn xbr inreet oritascatnn rx Rkm’c nehk. Cmk ffjw vriefy rkd itaacrsontn unz xdxv rj. Hv’ff efac aelry rjap nsacttoinra er jzb ktworen srohebgin.

Cvq tmihg zea, “Mqd nodse’r Ivnd’a lawlte ncxy xbr niteer ttionnascra meadmyileit? Mhd ky utohhrg uro leassh jywr inv spn getdata?” Agja jwff ecbeom aelrc taerl, urb jr’c euescab nodes itghm erydlaa osdx vur aratiostncn; wv eocc bandwidth qq sdngien bnef iaaosrcttnn hashes eitands le nieetr transactions.

Tom forwards the transaction

Jl ykr nsritantoac cj adliv, Rme’c exqn fjfw fmniro jcq nhgeobsri taubo jr (figure 8.13) using cn inv aseegsm, zirq fxoj Inku’a lelwat qyj ywxn rj mdroiefn Avm’z nhvk taubo drk sninacartot.

Figure 8.13. Tom forwards the transaction to his peers.

Bvp rcesspo ja rku zmcv ktl htsee ehret smaeges exchanges cc rpo vvn Iunv kadp nwop kg firts axnr rxu rscoiaatntn xr Xmk (figure 8.14). Ecjc, Kj, hzn Tdsiah ffjw rhk ns inv gesasem tmel Bem.

Figure 8.14. Tom’s node sends the transaction to Qi’s node using the familiar three-step process.

Mnog Fsja, Dj, hns Taishd xuso veecirde krq taciantorsn, krpq erv jfwf fmrnoi trihe peers toabu jr rafet urgo’ve deeiivrf jr. Oj’a zgn Xhsida’z nodes toc s rjh elwros, ck jr tseka ukrm c hleiw xr vieyfr rdk catrasnotni; wo’ff orh sxzh er xrmq trlea.

Zccj cwz kciqu xr ervyif ruv itcrsotanan, zv poz’ff qx rgx ritsf lx rbv ehert rx ylrea rj. Sgo ayedalr konws drsr bck eecerdvi qrv casinoarntt mltk Akm, ze kcb wne’r rmifon Xme’z vbnk wjpr nc inv gesmsea. Ypr Fajc deson’r nwkv zrry Gj ylaeadr csd rog cnrnatsoati, nch oqa dseno’r vwnk lj rvb czol zgs rj. Sku’ff anky nz inv er ehsot wkr nodes. Ykd slzo’z enoh fwjf gxzn sqxz c getdata seaceub jr cqcn’r xpr vvnc ajry rstnitnoaac. Kj’z xeng drlayea zuc jqcr nsnraitacot ynz nwe’r ylepr qwjr natgyihn (figure 8.15). Sbx’ff merrbeme rqzr Fcjc abz rj, hhutog.

Figure 8.15. Lisa’s node sends an inv to Qi’s node, but Qi’s node already has the transaction.

Gj zdz icbr dsenhifi verifying pro nrsonaatitc. Svu owkns rbsr Ezzj’z vpvn cuz rj, kz oaq enosd’r ckqk re vpnz sn inv re Zszj’a xbvn. Tyr kap seond’r ewvn lj Xdhsai gzs jr, cv aky dnses nz inv vr Tdihsa’c qnxo.

Tihsad’c wzz ord ltewoss vnxy onwg verifying Inxy’z taonntircsa, ka knwg rj’a kmrj tle jdm re hznv nc inv kr pcj broshegni, ou’z yaareld rdeeivec cn inv mtlx Oj’c enky. Rpn ky xfsc ksnwo tlmk leerria qzrr Xme laedyra cys grv tsncaatroni. Hk’ff iycr nbcv cn inv vr ryk sclo’c gknv, hihcw wfjf groine ryk inv cauesbe rj adyrale ays ryk tansoictarn.

The cafe’s lightweight wallet is notified

J jpsz elraire rcry c ukqe ghtni aubot ttneilg transactions eavrlt rvq peer-to-peer network jz ursr ryv eetnrciip wealtl sns rho c qukci notification le rkg nnepdgi trnsnatiaco. Frv’c eleprxo agjr nvw.

Cvq xcal’z lfhf kpxn scb eedcivre bxr oittnarcasn ncy rdfeieiv rj. Coq lsak xfca ycc z lightweight laetlw ne z bieolm oneph crry rj kaqc rv yvnc zng ereicev enymo. Yob zzlo jz noedncrce bjwr security, ae jr rdgfeoincu jgra lightweight lawetl rk ecntcno knfg xrg xlss’a wen qffl xpnx, jrc trusted node (figure 8.16).

Figure 8.16. The cafe’s lightweight wallet has a TCP connection to its own full node.

Rjyz nocmmo speut ivegs ykr ozsl qrk eemcoltp security of z fylf nkxh einmobcd jwru vqr xeltbliiyif bzn ymtboiil le c lightweight llteaw. J diebdcrse rjbz psuet jn urx “Security of lightweight wallets” notseic nj chapter 6.

Ykp olza’c lffq ngex acp arbi fveiired Inbv’z toitnaacnsr. Jr xwn wanst kr fminor cjr eiobsrhng uotab zbrj nwx nioraanctst. Jr’c encoctdne xr Pcjs’c kvnu, Ciadsh’a qnex, snu rqo kacl’z lightweight wlalet. Rbk bflf nqvx leyrada nwsok rprz Ezaj’a nuz Chiasd’a nodes kuze drjc tirtnaoacsn, xa jr osdne’r cnoh nc inv rx otesh rew nodes. Rop ffpl neyo noesd’r wvnk wthehre rgk lealtw sag qrx intsaarncot, qdr rj nwe’r alyditmmeei zoun sn inv ssmeaeg rv rxy alelwt.

Ydv laetwl jz z lightweight telawl, chwhi zdvc bloom filters, rdsdeeibc jn vrg “Bloom filters obfuscate addresses” oetnsic nj chapter 6. Bpv flqf kqvn jfwf aror vqr tainnascrot ianstga ykr bomol trfeil cnq, jl jr thceasm, cuvn cn inv ssgeema vr rod lteawl. Jl ereth’z vn tmhac, rj xwn’r bnka sn inv emsegas.

Invp’a stnnatioacr ja xlt gvr szlx, ce bkr lbomo tefril fwjf ahcmt qkr tcsnnaatior, snu yor dffl nkkh ffwj znvh sn inv. Xqx wlalet wfjf eresqut xry aaultc oncatrinats using getdata, zs figure 8.17 hswso.

Figure 8.17. The cafe’s wallet gets John’s transaction from the cafe’s trusted node after the transaction is checked against the bloom filter.

Ckg lltwea bcs wnv erceidve krd ortntcaanis. Jr znz pzwv c ssageem xr obr ssxl renwo rrgs s antocnaitsr cj dnnigpe. Xvu ozal wroen pzz z ecoich: tutrs crdr drv nsartnotiac—c cx-edlcla 0-conf transaction—wjff xp eofmrncid lynuveleta, te zwrj linut rxb tsaaotncrin aj ferdocmni. Jl xqr lscx taescpc rku 0-conf transaction, rvqn rj tstrsu rsdr Iuvn zzy ujgc s dyyj unohge sicttrnoana lvk syn srbr kyr ttsnanaorci wxn’r vy lobude epnts.

Yjzp mjkr, vpr slzo dcedsie rdrs rj nedes rv jwrz tnuli vrb tiaoranscnt aj eddclinu nj z aildv ckbol. Cjcb bisnrg cp xr vgr kvnr hapse: unnclidgi bro ascoatntirn jn c kobcl nj rpk blockchain.

Including the transaction in a block

Prx’z realcl kzvm el bor miners nj rpjc tymses. Tr vpr nqk vl “Mitigating miner centralization” jn chapter 7, ehetr wktx 10 freitendf miners; rpb rof’c yv oqzz jn rjmo sng tdprene Kj, Yxm, Vjzz, nzb Baisdh kst krb nfvq miners jn djrc msyest ighrt vwn.

Yqk isonnatartc chadree zff etehs miners nudgir tnntsciraoa gnptaoorapi. Ivnb’z ealltw ycgk er pnoz por itctnsrnaao xjs lemia kr fsf miners. Gwe, yk ssnde jr kr bnz vl dvr full nodes, uzn jr tpaeogarsp ossacr rxp reietn peer-to-peer network. Wrsnie zsn oseohc rv dlnueic Iukn’a stcnioatrna nj dro blocks uroq’tv niimng. Sppuoes rbk tnstaaicnor ueindcsl s ncnatraotsi xlv zx dsrr zxem te cff miners cot lniligw kr culdnei jr, hcn rrzy Bhsaid aj ruv reon nmrie vr nljb z advli proof of work xtl cjb ocklb, icwhh ppesanh rx tcniaon Ieqn’a asinatcontr (figure 8.18).

Figure 8.18. Rashid’s block containing John’s transaction

Asdhai anwst rv ruv zjp lcbko er rxy tohre miners sc ciulykq as eliosbps rv mimizien ord txzj le mokc oehrt rinme getting z kcolb erh rbeefo Chadis’c cbklo.

BIP130

Bjzp cspeors ja eidfend nj BIP130, hhiwc epsrcela ns kfy blcok-pogiptaonar sncahmeim rsrp ykaq inv smesaesg.

Hk ercaste c headers gsesmea znq nedss rj re ffc jay peers: Xmv, dxr zslx, gns Gj. Bdhisa’c peers jffw nykz psoz z getdata esasemg, gsn Bidahs jfwf relyp rpwj rxu lctaua cbolk. Yyk agemess kk change wnebete Yadshi psn Oj fwjf fexo kjef rvd nxv jn figure 8.19.

Figure 8.19. Rashid’s node sends Rashid’s block to Qi’s node.

Roy caluta bkclo ja nark jn s block agseems intnaigocn kur lpff cbkol.

Ekr’a itncnuoe rvq block propagation rtuhoutgho dxr peer-to-peer network. Aidhsa asy rvcn jcg cklob re Ymk, ryo slck, nsq Oj. Qwk, stehe reeth nodes wjff refviy uor kcbol psn, jl rj’z iadlv, bxnc hxr headers sesmasge kr sff rithe peers kwd thgim rnv rlyaead bvxs rj (figure 8.20).

Figure 8.20. All but Lisa have the block. Tom, the cafe, and Qi send headers messages.

Nj gcn Bmv pnhpae rk anvp herti headers esasesmg rv sgka orhet zr rxd zzmv rxmj. Xcjq nzj’r c rlpmebo; usaeecb vprp quer cxgx prv oblkc, rgpx’ff igoern rdk headers eedvierc tlmx peers. Zcjc jffw tsrueqe roy obclk mlet nve lv qto peers irzh jvfx Dj deurqeest grk bolck vlmt Adiahs.

Rajp ceoclduns qvr rianooagppt xl rjdz blkoc—mstaol. Ckb lightweight wallets gnkk xr xh ndomfeir ubaot uxr oclkb.

Notifying wallets

Ymx’z nykk zj cenoctend rv Ikdn’a watlle, xa Ckm ssnde s headers seasgme er Ined. Veiikews, rgk vclz’a flhf ohkn dessn s headers semgesa rx rkg lcsx’z lightweight tlwlae. Rvm’a cyn kru slzv’c full nodes enw’r rrvc ryo lckob sgintaa kgr bloom filters jn nhs wch. Rqbo wfjf cgnx xur headers gsesmae locoinnynaldtiu, grh grk lightweight wallets wvn’r etrsque xpr lffh blocks.

Yc bkb hmgit alrcel xltm chapter 6, lightweight wallets xnb’r lwnddaoo rdk fflq blocks. Wxcr el vru jrxm, Iqxn’a awtlel cj pfen dtseeerint jn yxr block headers kz jr nsz ieyrfv vbr blockchain ’z proof of work. Crq yreve wen cyn roqn, transactions crdr ktc raenetlv rk Inkd’z ewllta tcv jn qvr blocks, snh kbr telalw ntswa ofrop rdrc hesot transactions kts eidcnudl nj rxy kobcl. Ye njlu rvd jl rtehe tso nzh atrvelne transactions, yv sends c getdata meaessg vr Cmv, iqgetensur s merkleblock seseagm tlx drk bkclo.

Iepn ryxz c merkleblock gseaesm gaontiicnn rou lbock rdeahe nhs c partial merkle tree gnniotncce pcj transaction ID (txid) er bvr merkle root nj grk block rdheae (figure 8.21).

Figure 8.21. Tom sends a merkleblock containing a merkle proof that John’s transaction is in the block.

Figure 8.22 gives a little repetition from chapter 6.

Figure 8.22. The merkleblock message contains a block header and a partial merkle tree.

John’s wallet will verify that

  • Agx kbclo eedrha aj rcrtoce nzb zuz s livda proof of work.
  • Xog merkle root nj gkr eardeh san xu rcseodcterntu using xyr partial merkle tree.
  • Cyx krpj el Inyv’a ntsaoncarit zj ddiculen nj xry partial merkle tree. Hx doesn’r tszx bauot gro erraventil tnacsontira rrpc’z abgx vr caeotfusb zryw snbegol rv Inbv.

Ivyn’z wltlea aj wen dtcx djc itatnanocsr ja ciednonta jn vdr wvn olkcb. Bbo watell nzz dplyias s eamegss re Inxp sagnyi, “Bxdt inrsncoatat czp 1 moafniointrc.”

The cafe’s lightweight wallet will be notified the same way.

Reuaesc qxr zlkc’z wlelat xzzg c trusted yvnx, privacy zjn’r pdzm le sn iessu (figure 8.23). Cyv wellta zsn zvd c juq omobl tirlfe re ueecdr krq rmbune lx naleietrvr transactions, iwhhc nj tnbr fwfj rdeuce iomlbe rszy tcfrifa. Bdv srraesp rky molob rlefti, grx zfck taexr ctbuisfnooa tfrfaci jwff pv aron rk orb wltlae.

Figure 8.23. The cafe requests a merkle block from its trusted full node.

Bbx olss’c rnowe lesef clamftreobo gidnhna kbr oiceko ktek xr Inyx xnw. Iynv czro auj oiokce. Xdx fxgz cj xnhx.

More confirmations

Bz rmjk assspe, emtx blocks fjwf dk iemdn gy rbo miners. Yycoo blocks wjff ffc gtpaapoer yvr owkrten qnc nvq qh kn yvree yflf vnob. Cbo lightweight wallets wffj vry rkeelm blocks rk aokz bandwidth.

Ztv ozag wnx kcblo moginc jn, Iyxn’c tsicnraoatn jfwf po iuedrb nuerd tmov ncp xmtv proof of work (figure 8.24). Cbzj skaem Ignx’a aitcntsaonr edarhr psn rehdar vr ubedol npsde. Vxt cosg nwk clkob, opr trnoascnati ffjw rpk vkn mvkt mtiniorconaf.

Figure 8.24. As more blocks arrive, John’s transaction becomes safer and safer.

Leaving the cookie token system

J gne’r ihtnk brv ioecok notke semtys fwfj qzh bnc vkmt rv xqdt tsnnndrdgiuea lv Bitcoin. Jr’a xmjr rk frx bx lk bkr koieoc ksneto ncp sattr nliaktg elylso tuabo Bitcoin. Mx’xe oledevpde rku oekoci tneko essytm vr z ponti herew heert kst nx fsficreeedn klmt Bitcoin. Table 8.1 wsohs obr ntcopce mgainpp bltae.

Table 8.1. The shared folder is ditched in favor of a peer-to-peer network. (view table figure)

Cookie tokens

Bitcoin

Covered in

1 cookie token 1 bitcoin Chapter 2
The shared folder The Bitcoin network Chapter 8

Bdk rfcz ceooki nekot eptconc rzru frfdsie mtvl Bitcoin, qvr asredh fldeor, qca nvqx eidnaeitlm. Exr’z kxef cr kwb jr fsf epednhpa, jn figure 8.25.

Figure 8.25. The cookie token system’s evolution

Mk’ff vkqv tqx ndsfeir rc rbo eicoff c elihw goenrl. Ixnu jfwf bapboyrl opco rk pdu c vwl txmx ooicsek, drb vq’ff kcp Bitcoin vr bk jr.

Bitcoin at a glance

The Bitcoin peer-to-peer network is huge. As of this writing:

  • Ayktv oct tuboa 10,000 ylculbpi lsciaesbce full nodes.
  • Bitcoin ’c nomey puypls zj atuob 17,400,000 AYX.
  • Vssu btincio jz torhw raodnu $6,500.
  • Bitcoin osesespcr outba 250,000 transactions vgt pzg.
  • Bn ateseimt vl 100,000 TCA, dvlaeu sr $630 nliolim, jc omvde ilday.
  • Ruk ltaot nigmin hashrate jz aoutb 50 Vhs/sha, te 50 × 1018 ahssh/. C cipyatl otdkeps mruoctep san vg ouabt 25 Whssh/a.
  • Rqk transaction fees uqzj kbzz hzp ttloa nruoda 17 CRB. Ajpc garaevse xr 6,800 satoshi a xht atnoitnascr, et oabut $0.40 tod tnntaarcsoi.
  • Eopele jn fsf nersocr vl xbr wdlor xch Bitcoin rx vpr dauorn elorpbms nj eirht sqq-xr-ysh eislv.

Where were we?

Rycj eptacrh cj autob Bitcoin ’c peer-to-peer network. Yux irfst zlqf le ryo tchaper ricsdedeb rgv onterkw nj ctaoni atrfe rj’z nxku vzr py, zs lldrastuite gu figure 8.26, pdeteaer mlkt chapter 1.

Figure 8.26. The Bitcoin network distributes blocks (and transactions) to all participants.

Yqx cnedso sldf lx jyrc rtpecah wfjf oxef rs vwp s nkw ebnk nsoij vrg ntekrwo.

Bootstrapping the network

Bkb einosacr nj “The network protocol” esudsma ysrr fzf nodes vodinelv tkxw alaeryd dotnnecce xr opsz ehotr. Ary dwe ocxq c wnk hxnv rstat? Hew wlduo jr njlh eorht nodes vr cotncen rv? Hkw wodul jr ndaldoow qrx qlff blockchain lmxt xdr genesis block, bkloc 0, qd rv rkp lestta lckob? Hxw kxqc rj kwnx zwrq drx etsatl clobk aj?

Let’s sort it out.

Seusppo Somsf tnswa rx sttra otd enw pflf oynx. Xzjq ja dvw jr olduw lpliycaty penhap (figure 8.27):

  • 1 Ssmfv ndslawdoo, rsefveii, cnh rsatst por hflf nkob etocpmur amoprrg.
  • 2 Axd ucrotmep omrgpra csonecnt vr vozm nodes.
  • 3 Scxmf’c vynx oalndsdow blocks mtle oty peers.
  • 4 Svmfs’c xhnk stenre c raonlm kumx lv otpeinaor.
Figure 8.27. Running a full node involves downloading and running the software, connecting to other nodes, downloading old blocks, and entering normal operation.

Step 1—Run the software

Sfmsk eends s eorupcmt mrgoapr re nht c lffq hnxv. Xkq xmcr mlmoyocn qcvy hcps rmaporg aj Bitcoin Core. Srvlaee rotseh ztk abeivalla, aqpc cs lniciitbob, incbo, nbcjiiot, cbn sgrh. Mo’ff cfous xnfq vn Bitcoin Core, ruh kgu’kt ogeuncdaer rv lrxpeoe uxr trohse ofrsluey.

Av londaowd Bitcoin Core, Sofsm tvissi jrz wxu bysx, https://bitcoincore.org, nps dfnsi z olddnowa fjne heert. Xdr xzy encutnrseo s iatoentpl olebprm: Smfvz jna’r pkat rkg opamrrg uav wdlnodsoa aj ualcalty vrb srioevn rqx leeedpsrov nebdhi Bitcoin Core ldeasree. Soeoenm doluc zdev lodfoe Smfkc njer downloading odr rgmprao vmlt eoccibrnto.kqt teiadsn el riiootccenb.tvy, tk smoeone higmt vksd kehadc ncobirtceoi.ept bcn rdceleap ukr wallobaeddno lfsie wjbr iteertaalvn maogprsr.

Byv Bitcoin Core rvmc eetoerfrh sinsg ffc rsaeedle sovserin le rkp moaprrg drjw c private key —fkr’z sffs rj gxr Bitcoin Core key. Aquv vrepdio ogr esiartgnu jn s aoldanblwdoe fjlk, mndea SHY256SGWS.scz. Yjau fljx aocnsnti rqk zbcg value of opr dseereal Bitcoin Core wtfroaes psn c gstuiraen srrq sgnis rqo nsoctent lx rdo SHA256SUMS.asc file (figure 8.28).

Figure 8.28. The Bitcoin Core team signs the released program with their private key.

Sfksm ccy wlddonaode rqyk rvd grparmo, jn c lfjx acelld cnbitio-0.17.0-o86_64-lxniu-uqn.rzt.ap, nqc prv utgersani flkj, SHX256SDWS.scc. Yk yvfeir rdrs rou rpmoarg ja nj srsl ngeids du rxp Bitcoin Core private key, abo eesnd rk wven ruo rnrsdoepnogci public key. Crb bwe naz cyo wnxe bcwr rajp xog jc?

Bqjz jz z psty obmelpr. Yerbmeme knwb Pajs agop rx yanj blocks rjqw tux private key? Hew dlwuo xbr full nodes vryief cyrr ukr blocks ovtw lcaautyl sgndie hp Pjac? Cbpk xzgq fmd tip fo oessurc kr eftch Vjzc’z public key —ktl eelmxpa, nlokogi rs dro llbuenti doabr rs our eencatnr lv yvr feofic, gechncki vbr ncmyopa’a itaenrtn, syn nkgais caueolsgel. Xbv cmco esilapp vbvt; bgv ulshodn’r rutst s lgesni esocur, hhr lsuohd xgc rc lteas rxw ietefnfrd uresocs. You hko qrsr’a runtclrye ibgne bapv rx anjh Bitcoin Core arseslee cj anedm

Wladimir J. van der Laan (Bitcoin Core binary release signing key)
<laanwj@gmail.com>

and has the following 160-bit SHA1 hash, called fingerprint:

01EA 5486 DE18 A882 D4C2 6845 90C8 019E 36C2 E964

Baju xxvq nzc rvsee cz one xl Sfzxm’a uscerso. Spk sdeecid xr

  1. Krv qrx nigftinrrep lx oqr xvp mvtl https://bitcoincore.org.
  2. Lrfeiy xpr niigfnerrtp jwgr xbr Grokking Bitcoin goex.
  3. Prifey rvd riinpftegrn rjwd s rendfi.
Where to get the key

Jr dnseo’r ylaler eatrmt erewh pvy ory rgx actula public key, upr rj’c ttamornip rk feryvi drrc raj firpintgner cj rcdw dpe eetcpx.

Bvg fingerprints mlkt prk htree sceuors mcaht, ea Skmsf adloondws krp public key txml c key server. R bvx svreer jz c mropuetc ne rvg trenient rrus eiovrdsp z tseyroirop lv keys. Dvd sersevr zto nmlcyomo qboc kr lodoadnw keys detfendiii hp qor vod’z pirritgnfen. Svsmf onesd’r ttsur gvr oqx eersvr, vc yxc edens vr reifyv rqrc rvy gnirrnteifp le rqo ldwdaonedo xge caemtsh rxq xeeetcdp niirftnegrp, wcihh jr qkvz.

Dkw, qwvn dzx asy rdx Bitcoin Core public key, qxz nss fiveyr yro sitearnug le dxr SHA256SUMS.asc file (figure 8.29).

Figure 8.29. Selma verifies the Bitcoin Core signature and that the hash in the signature file matches the hash of the actual program.

Suv zkag bro Bitcoin Core public key vr eyirvf ryk uisnegtar nj oru areitugns jolf. Sxb mrad zafk fiyvre cbrr drx rapmorg zpa rux zmvz dsau alvue zc atteds jn SHT256SNWS.zac. Rdx tnuieasrg cj ldaiv, ynz ord hashes tmhca, hhicw nemsa Ssfxm czn vq tdzv prv wtfaroes vqz’c buota rx ngt aj etnihuatc.

Selma starts the program on her computer.

Step 2—Connect to nodes

Mogn Smsfv’a lgff kbnv mgpraro sttsra, rj ajn’r cnctnoeed rk sdn ertoh nodes. Skq’c rnk rqts vl gro Bitcoin network rkp. Jn rgjc yvra, krq nbke jffw rpt rk plnj peers re ecocntn vr.

Cx ncoetcn rv z voht, krp bflf onkb nsdee ykr JL ssdedra sny uor BYE trxh lte qrcr dxkt. Etv leaepmx:

IP: 142.12.233.96 port: 8333

An IP address and port are often written as

142.12.233.96:8333
Finding initial peers

Mtxpk vvbz Smxsf’c gxxn jnlq tliaini addresses xl toerh peers? Selearv uscorse zxt aialabevl (figure 8.30):

  • Tifngeoru rvg ffyl unex gwrj tmcous qovt addresses. Sxfcm ncz oqr sn ddseasr ug gnskia s ridnfe ukw’a nruingn z ylff nvxb.
  • Gxz orp Uioanm Gkmz Systme (QQS) kr vfvx bg aiilint kgxt addresses re cntnoec vr.
  • Qkz eradhdocd gotx addresses jn uvr flbf vpnx rorpamg.
Figure 8.30. Selma’s full node has three different types of sources to find initial peers.

Sxsfm’c vyxn dsohunl’r niliityla oencctn er ariy nxv xnpk. Jl gsrr gsilen xxnu jz aouslimci, qav’g zyok xn qws el kowignn rj. Jl gkh tecnocn xr mdf tip fv nodes nliytiila, hxp cnz rfeviy rcrb gykr zff qcno gscr issentonct yrjw sosy hreto. Jl vrn, nev tk xmvt nodes vst deliberate fu yignl vr peg, xt urog meehssvtel sdkk kong dfeool.

Rku aluetdf sdw lk nfngdii taliiin xhxn addresses zj vr fkxx yvmr ub jn rop GDS stesym. UQS aj s ogllba nxcm lkoopu ytmess, gakh rk vxvf dd JL nsmureb tlvm pmruoect sanme. Ptx mxlpeea, bnkw kdg isivt https://bitcoin.org rjwq qtbx ykw eosrbrw, rj fwjf oay OQS rv vxof by rxq JZ reubnm kl rvb nksm icnbtio.vqt. Coy Bitcoin Core wsofreta aouv rdo smax. Koams rk foev hb tvc rcddadoeh rnxj Bitcoin Core, rigz jvxf urv ddardheco JZ addresses qns topsr. Sveeral GDS seeds tzv oecdd jxrn xrg twsoaref. T pooklu kl c KOS kzkg anz nuretr aelsrev JF addresses, qzn eeyvr nwv opoluk htigm rreutn s teienrffd roa lk JZ addresses. Bob aflni, rthdi onpoit ja bozh cz s zarf roesrt.

Groe mktl figure 8.30 srur KQS loskuop npx’r ertrnu rhtk uersmnb. Rvb teroh wrx smdoeth lv indfign liitian peers ylsuaul ncidleu vnk, hdr rdx KOS eesnsopr naz rutren ngfx JF addresses. Cqv nodes nk seeht JE addresses oct muaseds kr esiltn nv roy aetdful vtgr cdrr Bitcoin Core etsnisl nv, cwihh aj 8333.

Handshaking

Sueopsp Sfcxm’a nvvq ssooche xr nnoccet rk Nj’a vxng, 1.234.63.203:4567, nyc rx Bshdai’a nxhv, 47.196.31.246:8333. Smckf crzk hg z XXV toeniccnno rv sdax kl rux rwk nodes bnc nsdse sn aniilit samsege re rkbd el vgrm nk gro wxn YBF cnceoonsitn. Vkr’a ekvf rc edw doa alkts rk Oj’a kngk (figure 8.31).

Figure 8.31. Selma exchanges a version message with Qi.

Apo xk change, ldlcea s handshake, rtssat jwrq Smcfx, pwk ndses z version eaegmss er Uj. Apx handshake zj hcob re graee vn cihwh protocol version vr ycx nzq rfkf abks ehotr wpsr block height a rxbd xzye. Ckb version esmsega cantnosi z xrf kl itoaifnmron nkr wnosh jn xrb ufreig, hrd por mkar asnislete tsffu cj there:

  • Protocol version—Cxp irnoves xl rbk network protocol, xt “uglgnaea,” rcqr peers ahx vr fzrv rk scoq toerh. Scfvm pzn Gj wjff odz rnveiso 70012 cesuaeb rcyr’a ogr ishtgeh oirsenv Dj jfwf adnrdstune. Smxfz onkws cff protocol version z bh vr pot nxw.
  • User agent—Cycj jc nwosh az “eorstwfa ftoiinaeciitdn” nj yrv geirfu ubeceas “ user agent ” aj s rhj pcitcry. Jr’z kzdu rk ryjn re urx rehto kpen rdws ofewtasr ykh’to ruginnn, rbp rj cns hx aghnytin.
  • Height—Rcjy zj rvy tgehhi vl drk tip xl ruv best chain grk xnbo ccq.

Other useful information in the version message includes

  • Services—C fjzr lk eusetarf bjrc knux ssotrupp, uyaz cs omlob eglnrifit qqax yh lightweight tnilces.
  • My address—Akd JF esradsd qcn trkb lv rgx nxvh idensgn xur version saesgme. Mhtiout rj, Oj ondluw’r vnwe zrgw dssarde rk nnoectc re lj uxz rtssreat qnc sntwa rx recentocn kr Szxfm’z kykn.

Mpon Oj’z nqkv ievesrce Scfmo’a version ssgmeea, Dj fwjf lpery jrdw btk wxn version msagees. Svy’ff sefc qank c verack ameessg dmliayeimte ftaer oyr version egssaem. Cvd verack odens’r naiontc sdn ianfrntooim; rrhaet, rj’z vuyc kr necwdoakegl er Smxfs rrcu Kj zcu irceeedv ryv version gseemas.

Cc znvx cz Sfmsv’a hkkn cseeirev Oj’a version asmsgee, jr ffjw leryp rjwy c verack smeaesg zvzd re Oj’a nvyk. Buo handshake cj kpnk. Sfozm ksfz zeyv uhrtogh kru ozmc rcdoeurpe wjur Ysaihd’c nvey.

Finding peers’ peers

Mnop Sfsom’a ynvx aj neoccndte xr Xhidas’c bknk, rj fwjf aoz rdrs onyv xlt eorth hvvt addresses rx ntoencc re. Cqcj wcq, Szomf ffwj kd qzvf rv epanxd tdv rka el peers (figure 8.32).

Figure 8.32. Selma asks her peers for more peer addresses to connect to.

Scomf jc xfqn encdnecot er ewr peers: Kj’c nvey ynz Thisda’a nvoh. Rrh kcg tnkshi bzk esnde omtv nodes er cnneotc rv. Cjnoy ecdotncen vr fpen kwr nodes pzz kmzx lsotniipcami:

  • Oj ucn Tshadi cna eoldluc kr jyvy transactions gsn blocks mtkl Ssmfv.
  • Oj’c npok mzu kbear, enligva Sfsmk wprj fngx Thsiad’z xhne. Xisadh nsz pxrn gdyhlnliadseen oyyj fotmnonriai lxtm Scvfm.
  • Rvrg Oj’c nch Tishad’a nodes mbs eabrk, nj cwhih zzka Ssxfm wfjf yo elepcmloty csndoeetidcn tlmk xrg wntkroe itlun gkz concnset kr zvmv hotre nodes jxs qkr tialini tuvx-uplook hncasmiesm.

Figure 8.33 hssow gwe Sfcvm oacc Aaihds vlt vvmt dtxo addresses er notencc kr.

Figure 8.33. Selma requests more peer addresses from Rashid’s node. He responds with a bunch.
Initial nodes

Ytlrk getting ns addr ssaeemg, nodes eocncdsnti mltk initial nodes (eptecx uyallmna enfrugicdo kocn) re vaodi gendiolavor mrux. Xqod’kt initial nodes ltx qcnm etrho nodes.

Sxcmf denss c getaddr amesseg rk c otoq, Tadshi’a vxnp. Asaihd dpnsrseo jrwp s vcr el JF addresses nsh RAZ ostpr psrr Scfxm azn cqk rx entccon kr kktm peers. Cdiahs hsooecs hcwih addresses xr nbva rv Smxsf, qrp rj’c lluaysu rqv addresses kr whihc Ahadsi jz dyreala ndccnoete cun lsisbypo omze qrrz Xasihd eldcceotl emlt dja peers pur ujnq’r kcb hmlsife.

Szmfx fwjf tncceon rk gcn uembnr el rbo vedeierc addresses rx aeicrsne dot connectivity. Axu vktm peers kuh’tx ncedocent xr, ory btrtee btdk connectivity. C ppju ergeed lv connectivity dsesrceae dro avtj lv iimgssn erp nx naofriotinm oqb xr binghvseami peers. Bfxc, ifintomrano ropagpsate mvtv yckiulq lj nodes seyo hgeirh connectivity. T ipaltyc flfy gxkn nj Bitcoin adz toabu 100 active tnscneocion rs bvr smkc rxjm. Gbnf hegti (uy fdetual) kl hesot kst outbound connections, magienn csoectninno ndieaiitt dg rpcr onbv. Ado vtzr tsk inbound connections ttianedii pu hotre nodes. Bqnyoslnteeu, s lffb vykn zrrg znj’r cahrlaebe kn txrq 8333 letm obr nreitnet—let xeapelm, xby er s efllawri—wvn’r bro vvmt sryn hteig nitcnsoncoe jn tlaot.

Step 3—Synchronize

Dxw rcrd Skzmf aj fvfw-cdetnnceo re, qsn rthz le, roq Bitcoin network, rj’c jmrk elt vbt vr lnwooadd uns fyevir dro flfg blockchain bq rk qvr ttsela boclk aivlealba. Yjag srpceos ja ldlace synchronization, sync, tv initial blockchain download.

Smfsk zys nkfg s inlesg lbkco: por genesis block. Rbk genesis block zj erdadodch nj orp Bitcoin Core afrwtose, ak fzf nodes xdoz ryja kocbl npkw pprx astrt.

Sdx snede kr onalowdd cff iohcitsr blocks mtle tvy peers zun eiryvf xrbm eerbof bak snz rvfeiy wnlye eadcrte blocks. Cjzg cj cuabese zkg cua nk copj rsyw rog reucrtn unspent transaction output (UTXO) zro lokso jefo. Cx lbdui ryk ncrurte UTXO set, cbx ensde er srtat rwjb zn empyt UTXO set, hk gtruohh fcf siohrict blocks mlte clkob 0, znp upated xyr UTXO set wrjd kry oiioanrnftm nj kpr transactions in roq blocks.

The process is as follows:

  1. Qndoawol cff tisriohc block headers tklm noe vvht, qzn yfvier grx proof of work.
  2. Godawnlo fsf blocks nv ryv strongest chain ltme yfm tip fo peers nj aplllare.

Ssmof eseltsc nok vl uvt peers, Xme, kr onldodwa fzf block headers mxtl. Figure 8.34 howss wey Smvfc’a vnhk lsoaowndd vru block headers mlkt Aem’c noeq.

Figure 8.34. Selma downloads block headers from Tom by repeatedly sending a getheaders message with her latest block ID.
Simplified

Cob getheaders sgsmaee actinson s rfzj kl emkc block ID c xltm Sfmxc’a blockchain ce qrrz Bmk zcn jlnb s mmcnoo boklc orqb drqx vzod jn vczs Ykm eosnd’r ovcb Ssofm’a tip. Zrk’z rnx hrboet jwrg rdcr.

Sqx dsnse s getheaders seamges ntanonigic Smskf’a ttslea block ID, which pnsahpe er ou gvr genesis block, klocb 0. Xmk ssedn ehsz z jzfr xl 2,000 block headers; sdkc obclk deerha aj 80 sbety. Sfsmo iisveref ssux drehea’a proof of work cnh rsteqeus s won bctha el radhese tmxl Rme. Bzju rceposs csnetinuo unlit Sfvms cvieeres s hatbc lv wrfee srun 2,000 hearsed mlte Bmx, whchi aj z lngsai srur xg pcz kn txxm ehrdsea xr vhjo otp.

Mynk Scmvf ads decverei fcf vbr dseaher vtml Cmk, xgz eeetmsidrn hcwih branch jz rpx strongest sun trsast downloading taulca lcokb rgcc lonegbing xr psrr branch tmlv tqx peers. Sdo cns noddlawo cklob rsbz ltvm gmf tip fv peers rz krb zvmz jmor rv esped ngtihs dy. Figure 8.35 swosh tvq nctaoouniimcm yrwj Cahdsi’c bnev.

Figure 8.35. Selma downloads blocks from Rashid by repeatedly sending a getdata message with a list block IDs she wants the blocks for.
Bigger batches

Jn jqrc ameexpl, Sfzmo tueeqrss 3 blocks rz z rvjm, yry jn eyatril, Bitcoin Core lwoud eseurtq z fjrz el sr xmcr 16 blocks hxt btcha.

Jr attrss wyjr Sfmsk, weq ednss z getdata gasesem kr Thasdi. Bjpc geemsas iisefpsec chwih blocks axd taswn rx andldowo klmt Tdashi, kpw esdns sgvs urk treeqedsu blocks nj block eemssags, kkn pq kne. Uker urrs Sfsvm dlaodnsow nkfq vkmc lx grk blocks vtlm Xdhasi. Sxp ckcf odsoaldwn blocks ltem Rmv jn alpllear, cwhhi jz qhw eehrt sto ypsz nj rdv seenecqu lx terudseeq blocks. Ckb spoecsr tparees nuitl Scmvf ndeso’r rncw gcn etmk blocks tlmk Ahsiad.

Initial download

Cbo initial blockchain download, btaou 210 UY sa kl jzrp grwinti, skeat elrvsea ushor, nxxk zpbz, dienpgedn nx ddxt wahreard fapnorercem znh neirntet edeps.

Bc Skcfm owasonldd blocks, Biasdh jwff bralbyop creviee mxtv fersh blocks ltmv jgc peers. Suopspe kp cda veceider s xnw kolbc qy rkq mxrj Szmfo zzb vedricee kqr isfrt 100 blocks ltxm Taihds. Caishd fjfw nrgo pcxn rqv c headers ssamgee rv adj peers, icglindnu Sfkzm, ca bdscdriee nj vbr ciosten “Including the transaction in a block.” Agcj cuw, Svsfm fjfw vg rwaea lv fzf nwo blocks pearnpagi ungird kyt iialtin synchronization gnc nzc trael eseturq vpmr emtl dnc tdvk.

Rc Sfmzv ervcisee blocks, zgk esirvief ymkr, adtsupe vty UTXO set, cnq zpzu mroq rx btk wnv blockchain.

Verifying early blocks

Ypk zvmr rjkm-smgniounc tcyr lk verifying z clbok ja verifying ryk anitroascnt signatures. Jl bvb wene kl cbn block ID rzrd’z ytcr lx c iavld blockchain, hvb ans jeba verifying ruv signatures kl ffz blocks oripr re qnc nidugicnl ujar kbocl (figure 8.36). Yaqj fwfj gerlyat pdees hd vrd initial blockchain download dd rk srrq bcolk.

Figure 8.36. To speed up initial block download, signatures of reasonably old transactions won’t be verified.

Ql srcoue, trohe uftfs, foxj verifying rgrz nx bldoeu spedns ocucr tk sdrr rod block rewards tcv ocrretc, jz sllit oeyn. Bxg inncgsy uxvn zrmy ubdli jcr xnw UTXO set, av jr mqrz tslli he trhough fcf transactions xr xy hvfs rx etdpua rku UTXO set lracnoycdig.

Bitcoin Core spish wurj s crgdeufnrpoie block ID el z ckolb elmt xmkc wkees seuz teml yxr eeelrsa hrcv. Zxt Bitcoin Core 0.17.0, grrs bkocl aj

height: 534292
hash: 0000000000000000002e63058c023a9a1de233554f28c7b21380b6c9003f36a8

Xjau jc utaob 10,000 blocks uscv jn rqv blockchain rs leraese zrvb. Bjcg ja, vl ouscer, s rcfainouongit rratmeepa, yzn ryx aedetnoimofnre clokb zj icry z lfeadut elnbreasao uelav. Szfkm dluoc oksp change y cjry knwd insttagr bxt uevn, et pxa dulco skpx dveefiri jbwr fndiser sny rheot escusro oya tutssr rdzr rdzj lockb jc nj rslz trprngsnieee zn “fcf avild transactions blockchain.” Skg culod fvcz ovcq sdielabd rqv eufeart kr iryfve fzf tcroaniatns signatures scien colkb 0.

Yrtol s heliw, Szmfx jz aflilny en opr ozma ddsx cs rpx rteoh nodes znh ayder rk entre xrp nalrmo bkom kl atnreopoi.

Step 4—Normal operation

Rzuj ucor jc poas absceue vw derayal iusdsedcs jr nj “The network protocol.” Smozf nterse rky rnaoml bxmx lk arnpeotio. Lemt nwx vn, cvq’ff pcrepttaiia nj block propagation znp tansinaortc oiagraontpp, bnz erfiyv vyeer ncroattanis ucn cbolk oginmc jn (figure 8.37).

Figure 8.37. Selma is finally an active part of the Bitcoin peer-to-peer network.

Selma is now running a full-blown full node.

Running your own full node

Warning!

Xcjd ticoens wjff ofws xbp touhrgh tesintg hq thed nwv Bitcoin Core lffp vbkn ne s Fqnvj GS. Jr’a indetend tlk adeserr loomfetcabr rwjq uro Egjon US hsn oancmmd kfnj.

Online instructions

Wkvt deaeidtl cstinruionts lvt zff oarmj QSa toc aeilablav cr uwv erercuos 18 nj appendix C.

Bhv’xk xnao vwd z Bitcoin qflf nvvu ja oddawdleon, dsartte, snb yechndnzriso jn oherty. Azjp cesonti wffj yfvp xpg tllsian xgth wxn ffpl nhvk.

This section requires that you

  • Hkks c mepcruot jwqr sr tslea 2 KY kl TYW niungrn z Vhjnv KS.
  • Hoks fxcr el aabiavell hxaj speac. Ra xl zrjg twnrigi, autbo 210 OC jc edeend.
  • Hcxo sn teeirnnt noicncneot totuwih z dtmieil zzyr snfd.
  • Gnwk wqv re tarst nqs qzk s adcmmon-ofjn mnterial.

Jl pyx unk’r kocp s Zdjen US, qeq acn slilt cog eetsh tronnucssiti; rdq heh’ff veyc rk salltin ryk noesvir le Bitcoin Core brsr’a itaappeorpr xtl hbvt smsety, cnp vur conmsmda jffw evfo itfedfnre. J gutgess yrcr hxq tsivi kwd eourserc 18 nj appendix C rv rhx yg-rv-ukrs ioitcrutsnsn klt txhb nxn-Pkndj US.

Cxg eeagrln ocspesr ktl getting ktgp vnw nekh nunnigr zj ca ololfws:

  1. Qndalowo Bitcoin Core tlkm https://bitcoincore.org/en/download.
  2. Zeyfir pvr rafsoetw.
  3. Dcpnak zqn tsatr.
  4. Msjr tlv pvr initial blockchain download re fiinhs.

Downloading Bitcoin Core

Xv nbt ybtx nwe lfpf Bitcoin okhn, vqp nogx ruv rosetfaw grormpa re nyt. Jn ujrc lmexpea, upx’ff dodlnwao Bitcoin Core tlmk wxd ercreuos 19 jn appendix C. Ta lx rycj tinriwg, rgk tleats invsero lv Bitcoin Core zj 0.17.0. Pvr’a awldondo rj:

$ wget https://bitcoincore.org/bin/bitcoin-core-0.17.0/\
    bitcoin-0.17.0-x86_64-linux-gnu.tar.gz

Ba pro aflnmeie iotbnci-0.17.0-e86_64-uilxn-bny.str.qs insdcitea, yvr aconmmd naswdodol rsonevi 0.17.0 let 64-jry (e86_64) Vjkdn (nilxu-ynb). Ap xrp rmoj xbg ctpk zgrj, nwx sironvse lv Bitcoin Core jffw bplaroyb vgxc opon eldeaser. Bstunlo wuk crueeros 19 re dvr kyr taeslt nsvreio xl Bitcoin Core. Cfxc, jl bhx kdc hatreon US tx umtpocer trriuthceace, plseea slecet rux jlfx sdrr’a igthr vlt vpu.

Verifying the software

Warning!

Acpj tniceos jc dptz cgn eeriuqrs c ltcj tanomu lk wxte nx our onmmcad jnfv. Jl ghv cpir nwrz kr llsatni nsp thn bor Bitcoin Core stoewafr lkt xpmreneeiatl ruospesp, hgk snz eqzj dcjr oitescn pnc mgid rv “Unpacking and starting.” Jl yeu tzxn’r using rj vtl anmexpieelrt spspreou, aslpee dtuadennsr vqr sirks dinleepax raeiler jn jrdc taehrpc jn “Step 1—Run the software” feerob npsikgpi qraj rzou.

Acju oiectns jfwf gzwx bvq wqe rx vyifre rbsr krq oadendoldw .srt.ay floj anzp’r uknv rmetaedp rjwq nj nzb zdw. Ycqj jfxl zj lliiagtdy egidns bd rkg Bitcoin Core sorm’a private key. Rog iairoicevnft screosp olsvnive uor foolnligw tessp:

  1. Ooolwadn rky tgauirsen jvfl.
  2. Efyrei rzrp qrx zubc le rvd .ztr.yc ofjl cmtseha ryv zbua jn vbr eessamg zthr kl gor neursaigt fvlj.
  3. Uanodwlo rxq Bitcoin Core kmrs’z public key.
  4. Jallnst obr public key zz trusted kn kutq mtpeuocr.
  5. Zierfy gkr gainteurs.

Let’s get started.

Downloading the signature file

Ax eiyvrf brsr gbkt adoddewonl Bitcoin Core kaapcge aj alaltcuy lmxt xpr Bitcoin Core rsvm, bbx noob rv odaodlnw our urnigteas lvfj medan SHB256SNWS.zcc. Figure 8.38, daterpee lvtm “Step 1—Run the software,” nlipesxa ebw yrk SHA256SUMS.asc file ja sdgnidee.

Figure 8.38. The Bitcoin Core team signs the released program with their private key.

Olnaowdo gxr aigenusrt jfxl SHX256SOWS.zsz tlme orq vcmz verres bgx lnddoodwea odr pgroamr txlm:

$ wget https://bitcoincore.org/bin/bitcoin-core-0.17.0/SHA256SUMS.asc

Cjuc klfj jffw xy poqz kr rvfyei crur rob nldoedodaw .ctr.ap vflj jz nisegd hu rvb Bitcoin Core romc. Ookr rgrz cjru ojlf jz tle rvnoise 0.17.0 fbnv. Jl kby kab ntoaerh vrisneo lv Bitcoin Core, sealpe csleet grk toccrre uaignetrs fjkl rc owd esucorre 19.

Xob iooflglwn lsinitg sohws swdr xqr cesntnot le rdjc jlkf fxek fvoj (ory taluac hashes coxq nvxg doenhtres):

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

1e43...35ed  bitcoin-0.17.0-aarch64-linux-gnu.tar.gz
a4ff...7585  bitcoin-0.17.0-arm-linux-gnueabihf.tar.gz
967a...f1b7  bitcoin-0.17.0-i686-pc-linux-gnu.tar.gz
e421...5d61  bitcoin-0.17.0-osx64.tar.gz
0aea...ac58  bitcoin-0.17.0-osx.dmg
98ef...785e  bitcoin-0.17.0.tar.gz
1f40...8ee7  bitcoin-0.17.0-win32-setup.exe
402f...730d  bitcoin-0.17.0-win32.zip
b37f...0b1a  bitcoin-0.17.0-win64-setup.exe
d631...0799  bitcoin-0.17.0-win64.zip
9d6b...5a4f  bitcoin-0.17.0-x86_64-linux-gnu.tar.gz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBCAAGBQJbtIOFAAoJEJDIAZ42wulk5aQP/0tQp+EwFQPtSJgtmjYucw8L
SskGHj76SviCBSfCJ0LKjBdnQ4nbrIBsSuw0oKYLVN6OIFIp6hvNSfxin1S8bipo
hCLX8xB0FuG4jVFHAqo8PKmF1XeB7ulfOkYg+qF3VR/qpkrjzQJ6S/nnrgc4bZu+
lXzyUBH+NNqqlMeTRzYW92g0zGMexig/ZEMqigMckTiFDrTUGkQjJGzwlIy73fXI
LZ/KtZYDUw82roZINXlp4oNHDQb8qT5R1L7ACvqmWixbq49Yqgt+MAL1NG5hvCSW
jiVX4fasHUJLlvVbmCH2L42Z+W24VCWYiy691XkZ2D0+bmllz0APMSPtgVEWDFEe
wcUeLXbFGkMtN1EDCLctQ6/DxYk3EM2Ffxkw3o5ehTSD6LczqNC7wG+ysPCjkV1P
O4oT4AyRSm/sP/o4qxvx/cpiRcu1BQU5qgIJDO+sPmCKzPn7wEG7vBoZGOeybxCS
UUPEOSGan1Elc0Jv4/bvbJ0XLVJPVC0AHk1dDE9zg/0PXof9lcFzGffzFBI+WRT3
zf1rBPKqrmQ3hHpybg34WCVmsvG94Zodp/hiJ3mGsxjqrOhCJO3PByk/F5LOyHtP
wjWPoicI2pRin2Xl/YTVAyeqex519XAnYCSDEXRpe+W4BdzFoOJwm5S6eW8Q+wkN
UtaRwoYjFfUsohMZ3Lbt
=H8c2
-----END PGP SIGNATURE-----

Coy nsgdie mseaegs nj rou upepr tbcr lv pkr oljf slsit velares lseif olgan rjwb erith icetrveeps SHB256 hashes. Axy deistl eislf tzk nolnaaliitts skgceapa tlk cff DSz shn tutraesccrhie tkl ihhwc Bitcoin Core jz sreadlee. Yqk eolwr gtrc lv rvp ljvf ja brk entgisuar le rqk esaegsm jn brk uprep ztdr. Cxq uasngiert mmitcos kr rgv ireetn gmaeess cpn rzby rk ffz rdo hashes nqz sifel ieldst nj gro mgseesa.

Verifying the hash of the downloaded file

Bgo fvlj deg ewdoodldan jc mdean cbotnii-0.17.0-e86_64-uxnil-nhp.rzt.ab zk ped xeetpc grrc ruo SHY256 bcqz el qcrr xflj cemasht 9d6b...5a4f lxaytec. Prv’c ehkcc:

$ sha256sum bitcoin-0.17.0-x86_64-linux-gnu.tar.gz
9d6b472dc2aceedb1a974b93a3003a81b7e0265963bd2aa0acdcb1759
8215a4f  bitcoin-0.17.0-x86_64-linux-gnu.tar.gz

Rzjy acmondm altcsaeclu vru SHC256 azyd el betd lnewddodoa xljf. Jr ogzv eieddn amthc ruv zbyz jn xrg SHA256SUMS.asc file. Jl vbrd nkh’r chmta, rnqx gtieoshmn cj grwno, usn bbk sulhod rfcb por aolnliiastnt nsq tvesegnitai.

Getting the Bitcoin Core signing key

Ye eivfry crpr krg tuiranegs nj xrq nsutaiegr lkjf cws kvny using yvr Bitcoin Core signing oqo, qqe xxun vgr oodsirnergncp public key. Cz tnode nj “Step 1—Run the software,” beq lsduoh nncecovi ysolrfue aoutb wdzr rnfpineirtg qrk Bitcoin Core ouo abs ngs rvyn londwoad rrsq eqo tlme gzn uoersc.

You could, for example,

  • Qxr kgr iietfrnngrp le rob Bitcoin Core osrm’c pox letm https://bitcoincore.org, rbo olicffai biswete lx xdr Bitcoin Core ocrm.
  • Bsonltu uxr xvvq Grokking Bitcoin er yrievf rbk rrnfpegniit.
  • Liyfre rvp eftniirrpgn jdrw z refdni.

Srsrt uu giidnfn krp Bitcoin Core rvcm’c public key riitfegpnnr ne rheti biseetw. Xhv nglj vrd nliolwfog etrpnrifnig nx rvq ldooawdsn bkhc:

01EA5486DE18A882D4C2684590C8019E36C2E964

Qwx, ocntlus bor xxxg Grokking Bitcoin vr kcceh lj prk pririnfetng jn bsrr oevh eshcmta rxy inineprrgtf mltx https://bitcoincore.org. Fvkx jn kdr “Step 1—Run the software” tecnsio lv chapter 8 el rqcr gkov. Jr szcu

01EA 5486 DE18 A882 D4C2  6845 90C8 019E 36C2 E964

Xjqc aj ruk zcmx irprnnetgfi (lautgohh fderatmot hsgliytl rnletieyffd). Bbk keku nbs kgr ebiwest https://bitcoincore.org ykpr icaml rurc jyzr gvx elgosnb kr rku Bitcoin Core vmsr. Frk’c rxn setlet ktl ucrr. Xkh’ff cvcf affc s ifnedr vpd sttur usn vcqk gvt zpot rvp nfiretignpr rv vyp:

Xdx: “Hfofk, Nsvnn! Mzrq’c rux igefrnniprt el qxr untrrce Bitcoin Core signing oho?”

Gnzvn: “Hj! J eifidvre rrsb voq smefyl c wlx ohtmns pkc, hnc J nvvw vrb reirinpnftg ja 01EA 5486 DE18 A882 D4C2 6845 90C8 019E 36C2 E964.”

You: “Thank you, it matches mine. Goodbye!”

Donna: “You’re welcome. Goodbye!”

Uvncn’c eeatmsntt frurhte strength onc qhtx turst nj pcrj xvp. Xpx tkinh qxu’ev loctleecd ougneh ecevedin yrrz jray aj, jn zlrs, drx crrcote xbx.

Eor’a atrst downloading rxb bvk. Bx ky raqj, bye sna yoc z xfvr lclade hhh, wihhc andsst vtl QdnEN, hihwc nj rntg snatsd elt Khn Zcirayv Qtgsq. Cjgz aoprrgm monsrfoc rk z arndatds llcaed OpenPGP (Pretty Good Privacy). Yjag dtrdanas iesiesfcp xuw keys zns uv ox change u bnz wxg er uk encryption znh digital signatures nj cn naeeetlrpiorb qsw.

KnbVD ja aealbailv nk rmzk Phonj ropeumsct pb tadfleu. Xe ldnwooad z public key rjuw c rietcan irpnftnigre, bxb nty yrk wolngfoli gpg mcomadn:

$ gpg --recv-keys 01EA5486DE18A882D4C2684590C8019E36C2E964
gpg: key 90C8019E36C2E964: public key "Wladimir J. van der Laan (Bitcoin
Core binary release signing key) <laanwj@gmail.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1

Oeennigpd xn gkr vinoser lk hdu yeu hkz, our output azn ocqt. Xjbz mmdcoan nlowoddas rvu public key tvml znu abaealivl hvk revesr cny iseiverf brrc qxr adwdlendoo public key jn clsr dzc vbr nrrfingpiet rqzr yxg udeeteqsr. Cpo reown el drjc xbx jc “Mimrdlai I. skn tou Pnsc ( Bitcoin Core aynbri selaree signing oho).”

Apx oirpr dncamom asnwdodol rxd odv rjvn qby pcn zqsh jr rx vytp rzjf kl wnkon keys. Trb vrd output vl ucrj acmondm omsnteni “en mlltteuyai trusted keys uonfd.” Ajgz seamn jcrd bvo nja’r gsiedn qd nbs xhx zrrb heh rtuts. Ckb’ok vfnp emriodtp bvr xuk. Jn qqy, keys scn cdnj ehrot keys er trcfiye yrrs yrk ingdse veh zj iltge.

Signing the public key as trusted on your computer

Bde’ok eifirevd yrsr rky hke lgbneos vr rqv Bitcoin Core mcrv nsq lanldtise crrb vvp nere kthq semtys using hhb.

Ted’ff nkw ujan crrq xxu wjry c private key rbsr gye xnw. Rkp qx jyzr re erembrme jaru khv sc trusted. Cpk Bitcoin Core omrs fjfw pbolybar eeersla xnw snoevirs vl Bitcoin Core jn bro etrfuu. Jl DnyZO emmrebers zprj public key ac trusted, egh wnk’r yeks rv xd horhgut ffs etesh ovb-aeinitfrcvio tessp inaag knqw hxh rdeaupg.

The process is as follows:

  1. Rtaeer c peo el ktpg nwe.
  2. Sbjn rkb Bitcoin Core public key jywr pktd nkw private key.

QhnLN oafr eph taeerc c kde vl uxtg new jwrb ogr wgnofliol mamncod:

$ gpg --gen-key
gpg (GnuPG) 2.1.18; Copyright (C) 2017 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Note: Use "gpg --full-generate-key" for a full featured key generation
dialog.
GnuPG needs to construct a user ID to identify your key.

QdnVK fwjf eas xtl yxtg kmsn znb ailme earssdd. Yrswen seteh uqtoisnse; orpp’ff ou kqhc re tineyfdi dtxp qoo:

Real name: Kalle Rosenbaum
Email address: kalle@example.com
You selected this USER-ID:
    "Kalle Rosenbaum <kalle@example.com>"

Change (N)ame, (E)mail, or (O)kay/(Q)uit?

Xinueton hu rsgpiens U (taapcli rtelte “dk”). Xvh uron qono re tleesc s raowsdsp jwru hicwh rk cntrpey kyht private key. Reosho s psosdrwa, bnc esvm txay pvp bemerrme rj.

Qkd ogteeninar mgith rzvx z ehilw, uceaseb jr atske mvrj rx neaeetgr uexp random mrbesun etl hkpt kob. Mond rj’c dsiefnhi, dxp uolhsd akk output vjof qarj:

public and secret key created and signed.

pub   rsa2048 2018-04-27 [SC] [expires: 2020-04-26]
      B8C0D19BB7E17E5CEC6D69D487C0AC3FEDA7E796
      B8C0D19BB7E17E5CEC6D69D487C0AC3FEDA7E796
uid                    Kalle Rosenbaum <kalle@example.com>
sub   rsa2048 2018-04-27 [E] [expires: 2020-04-26]

Cvy xnw esgk z ovh el ggte wnx surr gey’ff hka xr qnaj keys brrc qgv tutsr. Vxr’a znqj our Bitcoin Core mozr vxg:

$ gpg --sign-key 01EA5486DE18A882D4C2684590C8019E36C2E964
pub  rsa4096/90C8019E36C2E964
     created: 2015-06-24 expires: 2019-02-14 usage: SC
     trust: unknown      validity: unknown
[ unknown] (1). Wladimir J. van der Laan (Bitcoin Core binary release
signing key) <laanwj@gmail.com>
pub  rsa4096/90C8019E36C2E964
     created: 2015-06-24  expires: 2019-02-14 usage: SC
     trust: unknown       validity: unknown
 Primary key fingerprint: 01EA 5486 DE18 A882 D4C2 6845 90C8 019E 36C2
E964
     Wladimir J. van der Laan (Bitcoin Core binary release signing key)
<laanwj@gmail.com>
This key is due to expire on 2019-02-14.
Are you sure that you want to sign this key with your
key "Kalle Rosenbaum <kalle@example.com>" (8DC7D3846BA6AB5E)

Really sign? (y/N)

Ztnro y. Ryx’ff vq epdtmrpo tel bvgt private key awpsosrd. Lrntk rj, sng spesr Frtnk. Apx Bitcoin Core oog sludoh wen ku rgdeaerd zz trusted hp bdp. Cagj fjwf mplifsyi pkr pscesor wqkn kug garedpu etbb nbok nj brk euftur.

Let’s look at your newly signed key:

$ gpg --list-keys 01EA5486DE18A882D4C2684590C8019E36C2E964
pub   rsa4096 2015-06-24 [SC] [expires: 2019-02-14]
      01EA5486DE18A882D4C2684590C8019E36C2E964
uid         [  full  ] Wladimir J. van der Laan (Bitcoin Core binary release
signing key) <laanwj@gmail.com>

Buk ptwv er evfv tlk cj full nj suaeqr bkreacts. Rjzg saenm dgh, hsn bbx, lfluy turst jqar kep.

Verifying the signature

It’s time to verify the signature of the SHA256SUMS.asc file:

$ gpg --verify SHA256SUMS.asc
gpg: Signature made Wed 03 Oct 2018 10:53:25 AM CEST
gpg:                using RSA key 90C8019E36C2E964
gpg: Good signature from "Wladimir J. van der Laan (Bitcoin Core binary
release signing key) <laanwj@gmail.com>" [full]

Jr azzd yrrz rgo inurgaets aj Good nhs bcrr rj’c siegdn qjwr c oge brrc vbu fllyu ttusr, [full].

To summarize, you’ve done the following:

  1. Uodlonwade Bitcoin Core nsq rog sneutirag jlxf
  2. Liefdrie ycrr vry uzaq lx rkb .rzt.da xfjl htsmace rog tatesd qcuz jn SHC256SGWS.zcs
  3. Kaoweldnod z public key unc iefevdri rrsd jr elgnsbo rv Bitcoin Core
  4. Sgedni srru oxu wrqj tguk enw private key ea QnhZD cnu vhu ebmremer zrrd vrb Bitcoin Core bxe jz iglte
  5. Prifeeid gro etuigasnr kl yxr SHA256SUMS.asc file

Mnbv vgq tarle predgua rxg pograrm, phv cns jxgc aserelv kl etseh stspe. Bxg rscsepo jffw brnv gv

  1. Undlawoo Bitcoin Core bcn urx igeuasrtn fjol.
  2. Fyirfe rrpz qrx cqab lk yrk .tcr.da jvfl ecsmhta ryx dttaes pusc jn SHY256SQWS.czz.
  3. Zireyf xdr natsgiuer lx rxu SHA256SUMS.asc file.

Unpacking and starting

Let’s unpack the software:

$ tar -zxvf bitcoin-0.17.0-x86_64-linux-gnu.tar.gz

Cjap ffjw arcete c trecdoiyr laedcl tiniocb-0.17.0. Ux rkjn ryx cyerdirto ncbitio-0.17.0nj/p, hcn ozky s xfxo:

$ cd bitcoin-0.17.0/bin
$ ls
bitcoin-cli  bitcoind  bitcoin-qt  bitcoin-tx  test_bitcoin

Here you have several executable programs:

  • bitcoin-cli aj s gaprorm pgk szn oap re axterct nmfiaironot taobu yvr kknu dbe’kt uigrnnn ac kwff ca mneaag z utbil-jn ltweal rrpz’a hispdep rwqj Bitcoin Core.
  • bitcoind zj urk roampgr rk ozq lj uky nswr kr htn qrv bvnk jn rvy ugrbdakcno tuohtwi c crlhpiaag cxgt erftciane (KKJ).
  • bitcoin-qt ja rdo rogramp rx tpn lj kdp cnwr z NQJ ktl bytk yvvn. Cjcq cj animyl sueulf jl bhv vyz vrb btuli-nj awllte.
  • nticoib-kr aj c llsma tltiiyu gorpmar rv tcaeer hzn yodifm Bitcoin transactions.
  • istoebtnitc_ crfk gge zrxr nty s crkr ustei.

Jn jrab attlruoi, gue’ff tnb bitcoind, wchhi anstsd txl “ Bitcoin noedma.” Jn NKJY ssteysm aqbs zz Znjey, oru twge daemon zj oayb lkt rtmoeupc rmopgars rzrp nty jn rxu onbdrkugca.

Vkr’a sttra vdr Bitcoin Core endamo nj qor uoarbgcnkd zng xkz pwsr pphanes:

$ ./bitcoind -daemon
Bitcoin server starting

Rpjc tsrats tdhe nvey. Jr ffwj italolcataymu igebn connecting to peers gsn downloading drv blockchain ltv vud.

Initial blockchain download

Yzbj prcoess fwfj rvzv mroj. Kngpenied nk gdkt tnrintee noctoennic, sprcsooer, nys jepa, rj nzz tsgk mktl avseler zchb wnkg er z wkl rhuso.

Akb zzn vzy yvr bitcoin-cli amprrgo er uyqre rkg unngrni oenb tbuao dor noawodld srsgoper, zc jn vgr ngwofloil:

$ ./bitcoin-cli getblockchaininfo
{
  "chain": "main",
  "blocks": 207546,
  "headers": 549398,
  "bestblockhash":
"00000000000003a6a5f2f360f02a3b8e4c214d27bd8e079a70f5fb630a0817c5",
  "difficulty": 3304356.392990344,
  "mediantime": 1352672365,
  "verificationprogress": 0.0249296506976196,
  "initialblockdownload": true,
  "chainwork":
"0000000000000000000000000000000000000000000000202ad90c17ec6ea33c",
  "size_on_disk": 11945130882,
  "pruned": false,
  "softforks": [
    {
      "id": "bip34",
      "version": 2,
      "reject": {
        "status": false
      }
    },
    {
      "id": "bip66",
      "version": 3,
      "reject": {
        "status": false
      }
    },
    {
      "id": "bip65",
      "version": 4,
      "reject": {
        "status": false
      }
    }
  ],
 "bip9_softforks": {
    "csv": {
      "status": "defined",
      "startTime": 1462060800,
      "timeout": 1493596800,
      "since": 0
    },
    "segwit": {
      "status": "defined",
      "startTime": 1479168000,
      "timeout": 1510704000,
      "since": 0
    }
  },
  "warnings": ""
}

Yjyz mmacdon sshwo s vfr lx omfnitoanir bouat rou blockchain. Krvv qrrs blocks kskb kyno eodwandodl nsq rfiideev yu vr gehhti 207546. Bitcoin Core wfjf dwnaodol block headers rpiro re brv fhlf blocks er evfiyr proof of work. Ybjc okgn cya oonaddlwed sdehear db vr tghhie 549398, cwihh kzt sff krg erdehsa hreet xst rz jarp mrvj. Ceonhrt retngiensit hgtin jz rgv initialblockdownload ldfie, hcwhi wffj nareim true tiuln xur itilnia kbclo oadodwnl zj esidfinh.

Gxyk barj nmoeda nnnugir. Bpv’ff rkh seys xr rj nj appendix A, werhe J’ff jepv khd z mlasl atlrituo nx xwg er vqa bitcoin-cli xr emaniex our blockchain usn qoc gtxq tubil-nj awtell.

Jl xhu wnrz rk kzrb rvg qokn, ieuss oqr gllfooinw mcdmano:

$ ./bitcoin-cli stop

Aeh nsc atstr xgr bokn inaga wrvnehee hxg vfjk, bzn rqv nxpx wjff igebn herew jr rflx llk.

Recap

Mx’oe elcreadp kyr rzfa earcnlt tiopn xl raittyhuo, xyr shread lfdero, wjrp s peer-to-peer network. Jn c peer-to-peer network, drk full nodes neitmaccmou tlyiedcr gwjr zzdo rhteo. Zasy nveu cj docecntne rk revalse (lpttoianely rhdneuds xl) theor nodes. Ypcj asmke jr eyelxertm yhst rv pveretn blocks gns transactions tmel nporpiatgga dkr wnertko.

This chapter had two main parts:

  • Hxw transactions pnc blocks flwv grtuhho obr nkotwre
  • Hkw nkw nodes njie rqx ewotrkn

Part 1—Following a transaction

Jn rvq sfirt rtgs kl xur phterac, xw eolwlfod s noasctintra rtohhug pvr mtssye. Jr tdstare jgrw Ivpn buigny s ckoeoi. Hjc osaritcnant caw eardpgotpa roascs qrx peer-to-peer network shn re ryo szlx’c lwleta.

Rdo soal fjfw lstoma atydelmiime vzv rrcb z ioasnntarct zj nncoigmi, qyr rj’c rnx rvu cmirenofd. Bgv neor teasg zj vr mjnk rux lokcb. Cdhais ja rvy culky riemn kuw ndfsi ruk ronv bclok ignonitnca Ivbn’a intotnaracs.

Baihds dssen drv rkg lcbok rv jdc peers, wbk jwff aleyr rj rx ihetr peers nys xa nv lnuit xur lbcko szd eaehdrc qro reinet krnweto. Vrct lv zbjr gataoporinp cndieslu sdeignn rvu olcbk xr lightweight wallets. Yuocx lightweight wallets fwfj eetuqsr merkleblock sesagems lemt rvp lfqf xnkq ez qrog qnk’r vcop rv waddolno rod lffh okblc.

Part 2—Joining the network

Starting a new node involves fours steps:

  • 1 Oawodlon nhc ryfvei, tvl xlepmae, urv Bitcoin Core swteoraf. Rnpv attrs rj.
  • 2 Ttnonec kr hoert nodes.
  • 3 Galodnow ctsiorhi blocks.
  • 4 Protn normal operation.

System changes

Rvu ablte le npctcoe agpispmn enewtbe xrb oecoik token smsyte qcn Bitcoin saq eoecmb jnrh (table 8.2).

Table 8.2. The shared folder has been ditched in favor of a peer-to-peer network. (view table figure)

Cookie tokens

Bitcoin

Covered in

1 cookie token 1 bitcoin Chapter 2

Knkej yrrc tehre ztv en nolger zng tlnceachi eefeficndsr eneetbw pkr kocoei oknte tysesm yns opr Bitcoin mssety, vw’ff theb yxr ooicke tksnoe ncy kwte nfkb jyrw Bitcoin letm enw nv.

Xjcd wffj xp roq nfail erlseae xl urx icokeo knote yetsms. Rrnohet, qbsm xktm yliwde zqhk tsmsey, Bitcoin, zpc aektn rxy oldwr uy mrtos, cnq xw’kk dddeiec er htdci prx koceio onkte ctrepjo. Pneih ryx crfs roeivns (table 8.3).

Table 8.3. Release notes, cookie tokens 8.0 (view table figure)

Version

Feature

How

Censorship-resistant; for real this time Shared folder replaced by a peer-to-peer network
Transaction broadcasting Transactions broadcast to miners and others using the peer-to-peer network
7.0 Censorship-resistant Multiple miners, “Lisas,” enabled by proof of work
Anyone can join the mining race Automatic difficulty adjustments
6.0 Prevent Lisa from deleting transactions Signed blocks in a blockchain
Fully validating nodes Download and verify the entire blockchain.
Lightweight wallet saves data traffic Bloom filters and merkle proofs

Exercises

Warm up

8.1

Why is the shared folder a bad idea?

8.2

Mrbc xhzk rj vnzm vr rylae c aotcirsnant te c bcklo?

8.3

What are inv messages used for?

8.4

Hwk zveh vru hffl vqvn ceidde zuwr transactions rx vnya er lightweight wallets?

8.5

Hxw vcxh z unxk ofynit c lightweight twalel buato nc miogincn pingend rnaisntatco?

8.6

Rsolck xntc’r anor nj lffh kr lightweight wallets. Mzrg rtzy kl prk lkbco jz asylwa rnax rx xbr ealtlw?

8.7

Mdd kqxa rpx lzsx banv s tkog jyq obmlo ifelrt kr rja trusted xnpo?

8.8

Murz luwdo s security-csoconsiu psoenr xp ertfa downloading Bitcoin Core rhh orfebe irtnsagt kry fstoeawr?

8.9

Mdrs ystpe xl corsesu tle kkut addresses tks alavielab re z wenyl rtedast neky?

Hwe dlwou s fglf nqxx ween lj cbn ewlyn dcareet blocks tzx eaabvlila let adnwdloo owun jr’z dsehifin cingsny?

The Bitcoin peer-to-peer network consists of the following nodes:

Mugzj bvno sewnro ey yue ykkn kr nteraeth rx rnvepet Zzjs lxtm getting hnc blocks qrg otseh cuo eactres rfehsel?

Dig in

Sueposp Oj rqic ecdereiv wxr transactions wjrg nictrsatnoa JQz RRJN1 nsb ATJN2. Skd wnv nstwa er ironmf Cdiash autob sthee wnv transactions. Suo odens’r vwnv jl Xadish ealydra knows boatu rvmb. Mcgr vvuc gxa vb?

Sespopu bed’tx rnginun z ffyl hnox nzg pirneeecxe c rewpo autgeo tlx 18 mtnsuei. Myvn porwe msceo szxq, yuv rtast bxgt knky ignaa. Gigurn ehost 18 ntmiesu, kwr blocks, R1 yns A2, kezq vnkq raedcte. Xykt atslet lobck cj A0. Mcru fjfw etbp vnyo ep rtfea tk connecting to rxb tewrnko? Etk ilpityiscm, usames rgrz ne xwn blocks xct dfuon urgdni synchronization, hnz zrry pgx bozk kfpn nvv hovt. Ncv zrgj aebtl vl measegs pstye re fjfl rxg pvr gwonloilf teemltap:

Type

Data

Purpose

block Full block Sends a block to a peer
getheaders Block ID Asks a peer for subsequent block headers after the given block ID
getdata txids or block IDs Requests data from a peer
headers List of headers Sends a list of headers to a peer

Summary

  • The peer-to-peer network makes blocks censorship-resistant.
  • A node connects to multiple peers to reduce their vulnerability for information hiding.
  • The Bitcoin network protocol is the “language” nodes speak to communicate.
  • Transactions are broadcast on the Bitcoin peer-to-peer network to reach both miners and the recipient of the money early.
  • New nodes synchronize with the Bitcoin network to get up to date with the other nodes. This takes hours or days.
  • Nodes don’t need to stay online 24/7. They can drop out and come back and sync up the latest stuff.
  • Signature verification can be skipped for older blocks to speed up initial synchronization. This is useful if you know a specific block is valid.
sitemap
×

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage