mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2024-11-25 01:18:18 +00:00
updating passthroughs for htmlbook toolchain
This commit is contained in:
parent
788d57de75
commit
072d2f3cad
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,3 @@
|
|||||||
*.html
|
|
||||||
dump.asciidoc
|
dump.asciidoc
|
||||||
code/python-env
|
code/python-env
|
||||||
*.csv
|
*.csv
|
||||||
|
@ -164,10 +164,6 @@
|
|||||||
|=======
|
|=======
|
||||||
|
|
||||||
|
|
||||||
++++
|
|
||||||
<?hard-pagebreak?>
|
|
||||||
++++
|
|
||||||
|
|
||||||
<<tx_script_ops_table_internal>> shows operator codes reserved for use by the internal script parser.(((range="endofrange", startref="ix_appdx-scriptops-asciidoc1")))(((range="endofrange", startref="ix_appdx-scriptops-asciidoc0")))
|
<<tx_script_ops_table_internal>> shows operator codes reserved for use by the internal script parser.(((range="endofrange", startref="ix_appdx-scriptops-asciidoc1")))(((range="endofrange", startref="ix_appdx-scriptops-asciidoc0")))
|
||||||
|
|
||||||
[[tx_script_ops_table_internal]]
|
[[tx_script_ops_table_internal]]
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
"appdx-pycoin.asciidoc",
|
"appdx-pycoin.asciidoc",
|
||||||
"appdx-bx.asciidoc",
|
"appdx-bx.asciidoc",
|
||||||
"ix.html",
|
"ix.html",
|
||||||
"author_bio.xml",
|
"author_bio.html",
|
||||||
"colo.asciidoc"
|
"colo.html"
|
||||||
],
|
],
|
||||||
"formats": {
|
"formats": {
|
||||||
"pdf": {
|
"pdf": {
|
||||||
@ -64,4 +64,4 @@
|
|||||||
"title": "Mastering Bitcoin",
|
"title": "Mastering Bitcoin",
|
||||||
"print_isbn13": "9781449374044",
|
"print_isbn13": "9781449374044",
|
||||||
"templating": false
|
"templating": false
|
||||||
}
|
}
|
||||||
|
10
author_bio.html
Normal file
10
author_bio.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<section data-type="colophon" class="abouttheauthor">
|
||||||
|
<h1>About the Author</h1>
|
||||||
|
<p><strong>Andreas M. Antonopoulos</strong> is a noted technologist and serial entrepreneur who has become one of the most well-known and well-respected figures in bitcoin. As an engaging public speaker, teacher, and writer, Andreas makes complex subjects accessible and easy to understand. As an advisor, he helps startups recognize, evaluate, and navigate security and business risks.</p>
|
||||||
|
|
||||||
|
<p>Andreas grew up with the Internet, starting his first company, an early BBS and proto-ISP, as a teenager in his home in Greece. He earned degrees in computer science, data communications, and distributed systems from University College London (UCL), recently ranked among the world’s top 10 universities. After moving to the US, Andreas co-founded and managed a successful technology research company, and in that role advised dozens of Fortune 500 company executives on networking, security, data centers, and cloud computing. More than 200 of his articles on security, cloud computing, and data centers have been published in print and syndicated worldwide. He holds two patents in networking and security.</p>
|
||||||
|
|
||||||
|
<p>In 1990, Andreas started teaching various IT topics in private, professional, and academic environments. He honed his speaking skills in front of audiences ranging in size from five executives in a boardroom to thousands of people in large conferences. With more than 400 speaking engagements under his belt he is considered a world-class and charismatic public speaker and teacher. In 2014, he was appointed as a teaching fellow with the University of Nicosia, the first university in the world to offer a masters degree in digital currency. In this role, he helped develop the curriculum and co-taught the Introduction to Digital Currencies course, offered as a massive open online course (MOOC) through the university.</p>
|
||||||
|
|
||||||
|
<p>As a bitcoin entrepreneur, Andreas has founded a number of bitcoin businesses and launched several community open source projects. He serves as an advisor to several bitcoin and cryptocurrency companies. He is a widely published author of articles and blog posts on bitcoin, a permanent host on the popular Let’s Talk Bitcoin podcast, and a frequent speaker at technology and security conferences worldwide.</p>
|
||||||
|
</section>
|
@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
<bookinfo>
|
|
||||||
<authorblurb><para><emphasis role="strong">Andreas M. Antonopoulos</emphasis> is a noted technologist and serial entrepreneur who has become one of the most well-known and well-respected figures in bitcoin. As an engaging public speaker, teacher, and writer, Andreas makes complex subjects accessible and easy to understand. As an advisor, he helps startups recognize, evaluate, and navigate security and business risks.</para>
|
|
||||||
|
|
||||||
<para>Andreas grew up with the Internet, starting his first company, an early BBS and proto-ISP, as a teenager in his home in Greece. He earned degrees in computer science, data communications, and distributed systems from University College London (UCL), recently ranked among the world’s top 10 universities. After moving to the US, Andreas co-founded and managed a successful technology research company, and in that role advised dozens of Fortune 500 company executives on networking, security, data centers, and cloud computing. More than 200 of his articles on security, cloud computing, and data centers have been published in print and syndicated worldwide. He holds two patents in networking and security.</para>
|
|
||||||
|
|
||||||
<para>In 1990, Andreas started teaching various IT topics in private, professional, and academic environments. He honed his speaking skills in front of audiences ranging in size from five executives in a boardroom to thousands of people in large conferences. With more than 400 speaking engagements under his belt he is considered a world-class and charismatic public speaker and teacher. In 2014, he was appointed as a teaching fellow with the University of Nicosia, the first university in the world to offer a masters degree in digital currency. In this role, he helped develop the curriculum and co-taught the Introduction to Digital Currencies course, offered as a massive open online course (MOOC) through the university.</para>
|
|
||||||
|
|
||||||
<para>As a bitcoin entrepreneur, Andreas has founded a number of bitcoin businesses and launched several community open source projects. He serves as an advisor to several bitcoin and cryptocurrency companies. He is a widely published author of articles and blog posts on bitcoin, a permanent host on the popular Let’s Talk Bitcoin podcast, and a frequent speaker at technology and security conferences worldwide.</para></authorblurb>
|
|
||||||
</bookinfo>
|
|
||||||
|
|
@ -193,10 +193,6 @@ Joe then enters the bitcoin value for the transaction, 0.10 bitcoin. He carefull
|
|||||||
|
|
||||||
If Alice has a smartphone or laptop with her, she will also be able to see the transaction. The bitcoin ledger—a constantly growing file that records every bitcoin transaction that has ever occurred—is public, meaning that all she has to do is look up her own address and see if any funds have been sent to it. She can do this quite easily at the((("blockchain.info website"))) blockchain.info website by entering her address in the search box. The website will show her a http://bit.ly/1u0FFKL[page] listing all the transactions to and from that address. If Alice is watching that page, it will update to show a new transaction transferring 0.10 bitcoin to her balance soon after Joe hits Send.
|
If Alice has a smartphone or laptop with her, she will also be able to see the transaction. The bitcoin ledger—a constantly growing file that records every bitcoin transaction that has ever occurred—is public, meaning that all she has to do is look up her own address and see if any funds have been sent to it. She can do this quite easily at the((("blockchain.info website"))) blockchain.info website by entering her address in the search box. The website will show her a http://bit.ly/1u0FFKL[page] listing all the transactions to and from that address. If Alice is watching that page, it will update to show a new transaction transferring 0.10 bitcoin to her balance soon after Joe hits Send.
|
||||||
|
|
||||||
++++
|
|
||||||
<?hard-pagebreak?>
|
|
||||||
++++
|
|
||||||
|
|
||||||
.Confirmations
|
.Confirmations
|
||||||
****
|
****
|
||||||
((("confirmation of transactions")))At first, Alice's address will show the transaction from Joe as "Unconfirmed." This means that the transaction has been propagated to the network but has not yet been included in the bitcoin transaction ledger, known as the blockchain. To be included, the transaction must be "picked up" by a miner and included in a block of transactions. Once a new block is created, in approximately 10 minutes, the transactions within the block will be accepted as "confirmed" by the network and can be spent. The transaction is seen by all instantly, but it is only "trusted" by all when it is included in a newly mined block.
|
((("confirmation of transactions")))At first, Alice's address will show the transaction from Joe as "Unconfirmed." This means that the transaction has been propagated to the network but has not yet been included in the bitcoin transaction ledger, known as the blockchain. To be included, the transaction must be "picked up" by a miner and included in a block of transactions. Once a new block is created, in approximately 10 minutes, the transactions within the block will be accepted as "confirmed" by the network and can be spent. The transaction is seen by all instantly, but it is only "trusted" by all when it is included in a newly mined block.
|
||||||
|
264
ch03.asciidoc
264
ch03.asciidoc
@ -597,10 +597,11 @@ Commands: +gettransaction+, +getrawtransaction+, +decoderawtransaction+
|
|||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<programlisting>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli gettransaction 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66<?pdf-cr?>c309acbae2c14ae3
|
$ bitcoin-cli gettransaction 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66↵
|
||||||
|
c309acbae2c14ae3
|
||||||
|
|
||||||
</programlisting>
|
</pre>
|
||||||
++++
|
++++
|
||||||
[source,json]
|
[source,json]
|
||||||
----
|
----
|
||||||
@ -629,35 +630,56 @@ Transaction IDs are not authoritative until a transaction has been confirmed. Ab
|
|||||||
The transaction form shown with the command +gettransaction+ is the simplified form. To retrieve the full transaction code and decode it, we will use two commands: +getrawtransaction+ and +decoderawtransaction+. First, +getrawtransaction+ takes the _transaction hash (txid)_ as a parameter and returns the full transaction as a "raw" hex string, exactly as it exists on the bitcoin network:
|
The transaction form shown with the command +gettransaction+ is the simplified form. To retrieve the full transaction code and decode it, we will use two commands: +getrawtransaction+ and +decoderawtransaction+. First, +getrawtransaction+ takes the _transaction hash (txid)_ as a parameter and returns the full transaction as a "raw" hex string, exactly as it exists on the bitcoin network:
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<programlisting>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli getrawtransaction 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1f<?pdf-cr?>c66c309acbae2c14ae3
|
$ bitcoin-cli getrawtransaction 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1f↵
|
||||||
|
c66c309acbae2c14ae3
|
||||||
|
|
||||||
0100000001d717279515f88e2f56ce4e8a31e2ae3e9f00ba1d0add648e80c480ea22e0c7d3000<?pdf-cr?>000008b483045022100a4ebbeec83225dedead659bbde7da3d026c8b8e12e61a2df0dd0758e22<?pdf-cr?>7383b302203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9b2ac1bd193dfba2014<?pdf-cr?>104793ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede65e4c4b884ac5b5b6dede<?pdf-cr?>05ba84727e34c8fd3ee1d6929d7a44b6e111d41cc79e05dbfe5ceaffffffff02404b4c0000000<?pdf-cr?>0001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac1f312906000000001976a9<?pdf-cr?>14107b7086b31518935c8d28703d66d09b3623134388ac00000000
|
0100000001d717279515f88e2f56ce4e8a31e2ae3e9f00ba1d0add648e80c480ea22e0c7d3000↵
|
||||||
</programlisting>
|
000008b483045022100a4ebbeec83225dedead659bbde7da3d026c8b8e12e61a2df0dd0758e22↵
|
||||||
|
7383b302203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9b2ac1bd193dfba2014↵
|
||||||
|
104793ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede65e4c4b884ac5b5b6dede↵
|
||||||
|
05ba84727e34c8fd3ee1d6929d7a44b6e111d41cc79e05dbfe5ceaffffffff02404b4c0000000↵
|
||||||
|
0001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac1f312906000000001976a9↵
|
||||||
|
14107b7086b31518935c8d28703d66d09b3623134388ac00000000
|
||||||
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
To decode this hex string, use the +decoderawtransaction+ command. Copy and paste the hex as the first parameter of +decoderawtransaction+ to get the full contents interpreted as a JSON data structure (for formatting reasons the hex string is shortened in the following example):
|
To decode this hex string, use the +decoderawtransaction+ command. Copy and paste the hex as the first parameter of +decoderawtransaction+ to get the full contents interpreted as a JSON data structure (for formatting reasons the hex string is shortened in the following example):
|
||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<programlisting>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli decoderawtransaction 0100000001d717279515f88e2f56ce4e8a31e2ae3e<?pdf-cr?>9f00ba1d0add648e80c480ea22e0c7d3000000008b483045022100a4ebbeec83225dedead659b<?pdf-cr?>bde7da3d026c8b8e12e61a2df0dd0758e227383b302203301768ef878007e9ef7c304f70ffaf1<?pdf-cr?>f2c975b192d34c5b9b2ac1bd193dfba2014104793ac8a58ea751f9710e39aad2e296cc14daa44<?pdf-cr?>fa59248be58ede65e4c4b884ac5b5b6dede05ba84727e34c8fd3ee1d6929d7a44b6e111d41cc7<?pdf-cr?>9e05dbfe5ceaffffffff02404b4c00000000001976a91407bdb518fa2e6089fd810235cf1100c<?pdf-cr?>9c13d1fd288ac1f312906000000001976a914107b7086b31518935c8d28703d66d09b36231343<?pdf-cr?>88ac00000000
|
$ bitcoin-cli decoderawtransaction 0100000001d717279515f88e2f56ce4e8a31e2ae3e↵
|
||||||
</programlisting>
|
9f00ba1d0add648e80c480ea22e0c7d3000000008b483045022100a4ebbeec83225dedead659b↵
|
||||||
|
bde7da3d026c8b8e12e61a2df0dd0758e227383b302203301768ef878007e9ef7c304f70ffaf1↵
|
||||||
|
f2c975b192d34c5b9b2ac1bd193dfba2014104793ac8a58ea751f9710e39aad2e296cc14daa44↵
|
||||||
|
fa59248be58ede65e4c4b884ac5b5b6dede05ba84727e34c8fd3ee1d6929d7a44b6e111d41cc7↵
|
||||||
|
9e05dbfe5ceaffffffff02404b4c00000000001976a91407bdb518fa2e6089fd810235cf1100c↵
|
||||||
|
9c13d1fd288ac1f312906000000001976a914107b7086b31518935c8d28703d66d09b36231343↵
|
||||||
|
88ac00000000
|
||||||
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
{
|
{
|
||||||
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae3",
|
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae3",
|
||||||
"version" : 1,
|
"version" : 1,
|
||||||
"locktime" : 0,
|
"locktime" : 0,
|
||||||
"vin" : [
|
"vin" : [
|
||||||
{
|
{
|
||||||
"txid" : "d3c7e022ea80c4808e64dd0a1dba009f3eaee2318a4ece562f8ef815<?pdf-cr?>952717d7",
|
"txid" : "d3c7e022ea80c4808e64dd0a1dba009f3eaee2318a4ece562f8ef815↵
|
||||||
|
952717d7",
|
||||||
"vout" : 0,
|
"vout" : 0,
|
||||||
"scriptSig" : {
|
"scriptSig" : {
|
||||||
"asm" : "3045022100a4ebbeec83225dedead659bbde7da3d026c8b8e12e<?pdf-cr?>61a2df0dd0758e227383b302203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9b2<?pdf-cr?>ac1bd193dfba20104793ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede65e4c4b<?pdf-cr?>884ac5b5b6dede05ba84727e34c8fd3ee1d6929d7a44b6e111d41cc79e05dbfe5cea",
|
"asm" : "3045022100a4ebbeec83225dedead659bbde7da3d026c8b8e12e↵
|
||||||
"hex": "483045022100a4ebbeec83225dedead659bbde7da3d026c8b8e1<?pdf-cr?>2e61a2df0dd0758e227383b302203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9<?pdf-cr?>b2ac1bd193dfba2014104793ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede65e<?pdf-cr?>4c4b884ac5b5b6dede05ba84727e34c8fd3ee1d6929d7a44b6e111d41cc79e05dbfe5cea"
|
61a2df0dd0758e227383b302203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9b2↵
|
||||||
|
ac1bd193dfba20104793ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede65e4c4b↵
|
||||||
|
884ac5b5b6dede05ba84727e34c8fd3ee1d6929d7a44b6e111d41cc79e05dbfe5cea",
|
||||||
|
"hex": "483045022100a4ebbeec83225dedead659bbde7da3d026c8b8e1↵
|
||||||
|
2e61a2df0dd0758e227383b302203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9↵
|
||||||
|
b2ac1bd193dfba2014104793ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede65e↵
|
||||||
|
4c4b884ac5b5b6dede05ba84727e34c8fd3ee1d6929d7a44b6e111d41cc79e05dbfe5cea"
|
||||||
},
|
},
|
||||||
"sequence" : 4294967295
|
"sequence" : 4294967295
|
||||||
}
|
}
|
||||||
@ -667,7 +689,8 @@ $ bitcoin-cli decoderawtransaction 0100000001d717279515f88e2f56ce4e8a31e2ae3e<?p
|
|||||||
"value" : 0.05000000,
|
"value" : 0.05000000,
|
||||||
"n" : 0,
|
"n" : 0,
|
||||||
"scriptPubKey" : {
|
"scriptPubKey" : {
|
||||||
"asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c<?pdf-cr?>13d1fd2 OP_EQUALVERIFY OP_CHECKSIG",
|
"asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c↵
|
||||||
|
13d1fd2 OP_EQUALVERIFY OP_CHECKSIG",
|
||||||
"hex" : "76a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac",
|
"hex" : "76a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac",
|
||||||
"reqSigs" : 1,
|
"reqSigs" : 1,
|
||||||
"type" : "pubkeyhash",
|
"type" : "pubkeyhash",
|
||||||
@ -680,7 +703,8 @@ $ bitcoin-cli decoderawtransaction 0100000001d717279515f88e2f56ce4e8a31e2ae3e<?p
|
|||||||
"value" : 1.03362847,
|
"value" : 1.03362847,
|
||||||
"n" : 1,
|
"n" : 1,
|
||||||
"scriptPubKey" : {
|
"scriptPubKey" : {
|
||||||
"asm" : "OP_DUP OP_HASH160 107b7086b31518935c8d28703d66d09b36<?pdf-cr?>231343 OP_EQUALVERIFY OP_CHECKSIG",
|
"asm" : "OP_DUP OP_HASH160 107b7086b31518935c8d28703d66d09b36↵
|
||||||
|
231343 OP_EQUALVERIFY OP_CHECKSIG",
|
||||||
"hex" : "76a914107b7086b31518935c8d28703d66d09b3623134388ac",
|
"hex" : "76a914107b7086b31518935c8d28703d66d09b3623134388ac",
|
||||||
"reqSigs" : 1,
|
"reqSigs" : 1,
|
||||||
"type" : "pubkeyhash",
|
"type" : "pubkeyhash",
|
||||||
@ -691,7 +715,7 @@ $ bitcoin-cli decoderawtransaction 0100000001d717279515f88e2f56ce4e8a31e2ae3e<?p
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
</screen>
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
The transaction decode shows all the components of this transaction, including the transaction inputs and outputs. In this case we see that the transaction that credited our new address with 50 millibits used one input and generated two outputs. The input to this transaction was the output from a previously confirmed transaction (shown as the vin txid starting with +d3c7+). The two outputs correspond to the 50 millibit credit and an output with change back to the sender.
|
The transaction decode shows all the components of this transaction, including the transaction inputs and outputs. In this case we see that the transaction that credited our new address with 50 millibits used one input and generated two outputs. The input to this transaction was the output from a previously confirmed transaction (shown as the vin txid starting with +d3c7+). The two outputs correspond to the 50 millibit credit and an output with change back to the sender.
|
||||||
@ -702,18 +726,20 @@ Once the transaction we received has been confirmed by inclusion in a block, the
|
|||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli gettransaction 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66<?pdf-cr?>c309acbae2c14ae3
|
$ bitcoin-cli gettransaction 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66↵
|
||||||
</screen>
|
c309acbae2c14ae3
|
||||||
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
{
|
{
|
||||||
"amount" : 0.05000000,
|
"amount" : 0.05000000,
|
||||||
"confirmations" : 1,
|
"confirmations" : 1,
|
||||||
"blockhash" : "000000000000000051d2e759c63a26e247f185ecb7926ed7a6624bc31c<?pdf-cr?>2a717b",
|
"blockhash" : "000000000000000051d2e759c63a26e247f185ecb7926ed7a6624bc31c↵
|
||||||
|
2a717b",
|
||||||
"blockindex" : 18,
|
"blockindex" : 18,
|
||||||
"blocktime" : 1392660808,
|
"blocktime" : 1392660808,
|
||||||
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae3",
|
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae3",
|
||||||
@ -728,7 +754,7 @@ $ bitcoin-cli gettransaction 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66<?p
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
</screen>
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
Here, we see the new information in the entries +blockhash+ (the hash of the block in which the transaction was included), and +blockindex+ with value 18 (indicating that our transaction was the 18th transaction in that block).
|
Here, we see the new information in the entries +blockhash+ (the hash of the block in which the transaction was included), and +blockindex+ with value 18 (indicating that our transaction was the 18th transaction in that block).
|
||||||
@ -747,21 +773,24 @@ Commands: +getblock+, +getblockhash+
|
|||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli getblock 000000000000000051d2e759c63a26e247f185ecb7926ed7a6624b<?pdf-cr?>c31c2a717b true
|
$ bitcoin-cli getblock 000000000000000051d2e759c63a26e247f185ecb7926ed7a6624b↵
|
||||||
</screen>
|
c31c2a717b true
|
||||||
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
{
|
{
|
||||||
"hash" : "000000000000000051d2e759c63a26e247f185ecb7926ed7a6624bc31c2a717<?pdf-cr?>b",
|
"hash" : "000000000000000051d2e759c63a26e247f185ecb7926ed7a6624bc31c2a717↵
|
||||||
|
b",
|
||||||
"confirmations" : 2,
|
"confirmations" : 2,
|
||||||
"size" : 248758,
|
"size" : 248758,
|
||||||
"height" : 286384,
|
"height" : 286384,
|
||||||
"version" : 2,
|
"version" : 2,
|
||||||
"merkleroot" : "9891747e37903016c3b77c7a0ef10acf467c530de52d84735bd555387<?pdf-cr?>19f9916",
|
"merkleroot" : "9891747e37903016c3b77c7a0ef10acf467c530de52d84735bd555387↵
|
||||||
|
19f9916",
|
||||||
"tx" : [
|
"tx" : [
|
||||||
"46e130ab3c67d31d2b2c7f8fbc1ca71604a72e6bc504c8a35f777286c6d89bf0",
|
"46e130ab3c67d31d2b2c7f8fbc1ca71604a72e6bc504c8a35f777286c6d89bf0",
|
||||||
"2d5625725b66d6c1da88b80b41e8c07dc5179ae2553361c96b14bcf1ce2c3868",
|
"2d5625725b66d6c1da88b80b41e8c07dc5179ae2553361c96b14bcf1ce2c3868",
|
||||||
@ -790,11 +819,14 @@ $ bitcoin-cli getblock 000000000000000051d2e759c63a26e247f185ecb7926ed7a6624b<?p
|
|||||||
"nonce" : 3888130470,
|
"nonce" : 3888130470,
|
||||||
"bits" : "19015f53",
|
"bits" : "19015f53",
|
||||||
"difficulty" : 3129573174.52228737,
|
"difficulty" : 3129573174.52228737,
|
||||||
"chainwork" : "000000000000000000000000000000000000000000001931d1658fc048<?pdf-cr?>79e466",
|
"chainwork" : "000000000000000000000000000000000000000000001931d1658fc048↵
|
||||||
"previousblockhash" : "0000000000000000177e61d5f6ba6b9450e0dade9f39c257b4<?pdf-cr?>d48b4941ac77e7",
|
79e466",
|
||||||
"nextblockhash" : "0000000000000001239d2c3bf7f4c68a4ca673e434702a57da8fe0<?pdf-cr?>d829a92eb6"
|
"previousblockhash" : "0000000000000000177e61d5f6ba6b9450e0dade9f39c257b4↵
|
||||||
|
d48b4941ac77e7",
|
||||||
|
"nextblockhash" : "0000000000000001239d2c3bf7f4c68a4ca673e434702a57da8fe0↵
|
||||||
|
d829a92eb6"
|
||||||
|
|
||||||
</screen>
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
The block contains 367 transactions and as you can see, the 18th transaction listed (+9ca8f9...+) is the txid of the one crediting 50 millibits to our address. The +height+ entry tells us this is the 286384th block in the blockchain.
|
The block contains 367 transactions and as you can see, the 18th transaction listed (+9ca8f9...+) is the txid of the one crediting 50 millibits to our address. The +height+ entry tells us this is the 286384th block in the blockchain.
|
||||||
@ -803,32 +835,34 @@ We can also retrieve a block by its block height using the +getblockhash+ comman
|
|||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli getblockhash 0
|
$ bitcoin-cli getblockhash 0
|
||||||
|
|
||||||
000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
|
000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
|
||||||
</screen>
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
Here, we retrieve the block hash of the "genesis block," the first block mined by Satoshi Nakamoto, at height zero. Retrieving this block shows:
|
Here, we retrieve the block hash of the "genesis block," the first block mined by Satoshi Nakamoto, at height zero. Retrieving this block shows:
|
||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1<?pdf-cr?>b60a8ce26f
|
$ bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1↵b60a8ce26f
|
||||||
</screen>
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
{
|
{
|
||||||
"hash" : "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26<?pdf-cr?>f",
|
"hash" : "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26↵
|
||||||
|
f",
|
||||||
"confirmations" : 286388,
|
"confirmations" : 286388,
|
||||||
"size" : 285,
|
"size" : 285,
|
||||||
"height" : 0,
|
"height" : 0,
|
||||||
"version" : 1,
|
"version" : 1,
|
||||||
"merkleroot" : "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7af<?pdf-cr?>deda33b",
|
"merkleroot" : "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7af↵
|
||||||
|
deda33b",
|
||||||
"tx" : [
|
"tx" : [
|
||||||
"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"
|
"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"
|
||||||
],
|
],
|
||||||
@ -836,16 +870,18 @@ $ bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1<?p
|
|||||||
"nonce" : 2083236893,
|
"nonce" : 2083236893,
|
||||||
"bits" : "1d00ffff",
|
"bits" : "1d00ffff",
|
||||||
"difficulty" : 1.00000000,
|
"difficulty" : 1.00000000,
|
||||||
"chainwork" : "0000000000000000000000000000000000000000000000000000000100<?pdf-cr?>010001",
|
"chainwork" : "0000000000000000000000000000000000000000000000000000000100↵
|
||||||
"nextblockhash" : "00000000839a8e6886ab5951d76f411475428afc90947ee320161b<?pdf-cr?>bf18eb6048"
|
010001",
|
||||||
|
"nextblockhash" : "00000000839a8e6886ab5951d76f411475428afc90947ee320161b↵
|
||||||
|
bf18eb6048"
|
||||||
}
|
}
|
||||||
</screen>
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
The +getblock+, +getblockhash+, and +gettransaction+ commands can be used to explore the blockchain database, programmatically.
|
The +getblock+, +getblockhash+, and +gettransaction+ commands can be used to explore the blockchain database, programmatically.
|
||||||
|
|
||||||
|
|
||||||
==== Creating, Signing, and Submitting Transactions Based on pass:[<phrase role="keep-together">Unspent Outputs</phrase>]
|
==== Creating, Signing, and Submitting Transactions Based on pass:[<span class="keep-together">Unspent Outputs</span>]
|
||||||
|
|
||||||
Commands: +listunspent+, +gettxout+, +createrawtransaction+, +decoderawtransaction+, +signrawtransaction+, +sendrawtransaction+
|
Commands: +listunspent+, +gettxout+, +createrawtransaction+, +decoderawtransaction+, +signrawtransaction+, +sendrawtransaction+
|
||||||
|
|
||||||
@ -860,10 +896,11 @@ $ bitcoin-cli listunspent
|
|||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c<?pdf-cr?>14ae3",
|
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c↵
|
||||||
|
14ae3",
|
||||||
"vout" : 0,
|
"vout" : 0,
|
||||||
"address" : "1hvzSofGwT8cjb8JU7nBsCSfEVQX5u9CL",
|
"address" : "1hvzSofGwT8cjb8JU7nBsCSfEVQX5u9CL",
|
||||||
"account" : "",
|
"account" : "",
|
||||||
@ -872,7 +909,7 @@ $ bitcoin-cli listunspent
|
|||||||
"confirmations" : 7
|
"confirmations" : 7
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
</screen>
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
We see that the transaction +9ca8f9...+ created an output (with vout index 0) assigned to the address +1hvzSo...+ for the amount of 50 millibits, which at this point has received seven confirmations. Transactions use previously created outputs as their inputs by referring to them by the previous txid and vout index. We will now create a transaction that will spend the 0th vout of the txid +9ca8f9...+ as its input and assign it to a new output that sends value to a new address.
|
We see that the transaction +9ca8f9...+ created an output (with vout index 0) assigned to the address +1hvzSo...+ for the amount of 50 millibits, which at this point has received seven confirmations. Transactions use previously created outputs as their inputs by referring to them by the previous txid and vout index. We will now create a transaction that will spend the 0th vout of the txid +9ca8f9...+ as its input and assign it to a new output that sends value to a new address.
|
||||||
@ -881,16 +918,18 @@ First, let's look at the specific output in more detail. We use +gettxout+ to ge
|
|||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli gettxout 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309ac<?pdf-cr?>bae2c14ae3 0
|
$ bitcoin-cli gettxout 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309ac↵
|
||||||
</screen>
|
bae2c14ae3 0
|
||||||
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
{
|
{
|
||||||
"bestblock" : "0000000000000001405ce69bd4ceebcdfdb537749cebe89d371eb37e13<?pdf-cr?>899fd9",
|
"bestblock" : "0000000000000001405ce69bd4ceebcdfdb537749cebe89d371eb37e13↵
|
||||||
|
899fd9",
|
||||||
"confirmations" : 7,
|
"confirmations" : 7,
|
||||||
"value" : 0.05000000,
|
"value" : 0.05000000,
|
||||||
"scriptPubKey" : {
|
"scriptPubKey" : {
|
||||||
@ -906,7 +945,7 @@ $ bitcoin-cli gettxout 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309ac<?p
|
|||||||
"version" : 1,
|
"version" : 1,
|
||||||
"coinbase" : false
|
"coinbase" : false
|
||||||
}
|
}
|
||||||
</screen>
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
What we see here is the output that assigned 50 millibits to our address +1hvz...+. To spend this output we will create a new transaction. First, let's make an address to which we will send the money:
|
What we see here is the output that assigned 50 millibits to our address +1hvz...+. To spend this output we will create a new transaction. First, let's make an address to which we will send the money:
|
||||||
@ -922,31 +961,42 @@ We will send 25 millibits to the new address +1LnfTn...+ we just created in our
|
|||||||
We use +createrawtransaction+ to create this transaction. As parameters to +createrawtransaction+ we provide the transaction input (the 50 millibit unspent output from our confirmed transaction) and the two transaction outputs (money sent to the new address and change sent back to the previous address):
|
We use +createrawtransaction+ to create this transaction. As parameters to +createrawtransaction+ we provide the transaction input (the 50 millibit unspent output from our confirmed transaction) and the two transaction outputs (money sent to the new address and change sent back to the previous address):
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli createrawtransaction '[{"txid" : "9ca8f969bd3ef5ec2a8685660fdbf<?pdf-cr?>7a8bd365524c2e1fc66c309acbae2c14ae3", "vout" : 0}]' '{"1LnfTndy3qzXGN19Jwscj1<?pdf-cr?>T8LR3MVe3JDb": 0.025, "1hvzSofGwT8cjb8JU7nBsCSfEVQX5u9CL": 0.0245}'
|
$ bitcoin-cli createrawtransaction '[{"txid" : "9ca8f969bd3ef5ec2a8685660fdbf↵
|
||||||
|
$ bitcoin-cli createrawtransaction '[{"txid" : "9ca8f969bd3ef5ec2a8685660fdbf↵
|
||||||
|
7a8bd365524c2e1fc66c309acbae2c14ae3", "vout" : 0}]' '{"1LnfTndy3qzXGN19Jwscj1↵
|
||||||
|
T8LR3MVe3JDb": 0.025, "1hvzSofGwT8cjb8JU7nBsCSfEVQX5u9CL": 0.0245}'
|
||||||
|
|
||||||
0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c000<?pdf-cr?>0000000ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a<?pdf-cr?>9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac0<?pdf-cr?>0000000
|
0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c000↵
|
||||||
</screen>
|
0000000ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a↵
|
||||||
|
9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac0↵
|
||||||
|
0000000
|
||||||
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
The +createrawtransaction+ command produces a raw hex string that encodes the transaction details we supplied. Let's confirm everything is correct by decoding this raw string using the +decoderawtransaction+ command:
|
The +createrawtransaction+ command produces a raw hex string that encodes the transaction details we supplied. Let's confirm everything is correct by decoding this raw string using the +decoderawtransaction+ command:
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli decoderawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bd<?pdf-cr?>a8f7db0f6685862aecf53ebd69f9a89c0000000000ffffffff02a0252600000000001976a914d<?pdf-cr?>90d36e98f62968d2bc9bbd68107564a156a9bcf88ac50622500000000001976a91407bdb518fa<?pdf-cr?>2e6089fd810235cf1100c9c13d1fd288ac00000000
|
$ bitcoin-cli decoderawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bd↵
|
||||||
</screen>
|
a8f7db0f6685862aecf53ebd69f9a89c0000000000ffffffff02a0252600000000001976a914d↵
|
||||||
|
90d36e98f62968d2bc9bbd68107564a156a9bcf88ac50622500000000001976a91407bdb518fa↵
|
||||||
|
2e6089fd810235cf1100c9c13d1fd288ac00000000
|
||||||
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
{
|
{
|
||||||
"txid" : "0793299cb26246a8d24e468ec285a9520a1c30fcb5b6125a102e3fc05d4f3cb<?pdf-cr?>a",
|
"txid" : "0793299cb26246a8d24e468ec285a9520a1c30fcb5b6125a102e3fc05d4f3cb↵
|
||||||
|
a",
|
||||||
"version" : 1,
|
"version" : 1,
|
||||||
"locktime" : 0,
|
"locktime" : 0,
|
||||||
"vin" : [
|
"vin" : [
|
||||||
{
|
{
|
||||||
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acb<?pdf-cr?>ae2c14ae3",
|
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acb↵
|
||||||
|
ae2c14ae3",
|
||||||
"vout" : 0,
|
"vout" : 0,
|
||||||
"scriptSig" : {
|
"scriptSig" : {
|
||||||
"asm" : "",
|
"asm" : "",
|
||||||
@ -960,7 +1010,8 @@ $ bitcoin-cli decoderawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bd<?p
|
|||||||
"value" : 0.02500000,
|
"value" : 0.02500000,
|
||||||
"n" : 0,
|
"n" : 0,
|
||||||
"scriptPubKey" : {
|
"scriptPubKey" : {
|
||||||
"asm" : "OP_DUP OP_HASH160 d90d36e98f62968d2bc9bbd68107564a15<?pdf-cr?>6a9bcf OP_EQUALVERIFY OP_CHECKSIG",
|
"asm" : "OP_DUP OP_HASH160 d90d36e98f62968d2bc9bbd68107564a15↵
|
||||||
|
6a9bcf OP_EQUALVERIFY OP_CHECKSIG",
|
||||||
"hex" : "76a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88ac",
|
"hex" : "76a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88ac",
|
||||||
"reqSigs" : 1,
|
"reqSigs" : 1,
|
||||||
"type" : "pubkeyhash",
|
"type" : "pubkeyhash",
|
||||||
@ -973,7 +1024,8 @@ $ bitcoin-cli decoderawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bd<?p
|
|||||||
"value" : 0.02450000,
|
"value" : 0.02450000,
|
||||||
"n" : 1,
|
"n" : 1,
|
||||||
"scriptPubKey" : {
|
"scriptPubKey" : {
|
||||||
"asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c1<?pdf-cr?>3d1fd2 OP_EQUALVERIFY OP_CHECKSIG",
|
"asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c1↵
|
||||||
|
3d1fd2 OP_EQUALVERIFY OP_CHECKSIG",
|
||||||
"hex" : "76a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac",
|
"hex" : "76a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac",
|
||||||
"reqSigs" : 1,
|
"reqSigs" : 1,
|
||||||
"type" : "pubkeyhash",
|
"type" : "pubkeyhash",
|
||||||
@ -984,7 +1036,7 @@ $ bitcoin-cli decoderawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bd<?p
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
</screen>
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
That looks correct! Our new transaction "consumes" the unspent output from our confirmed transaction and then spends it in two outputs, one for 25 millibits to our new address and one for 24.5 millibits as change back to the original address. The difference of 0.5 millibits represents the transaction fee and will be credited to the miner who finds the block that includes our transaction.
|
That looks correct! Our new transaction "consumes" the unspent output from our confirmed transaction and then spends it in two outputs, one for 25 millibits to our new address and one for 24.5 millibits as change back to the original address. The difference of 0.5 millibits represents the transaction fee and will be credited to the miner who finds the block that includes our transaction.
|
||||||
@ -997,45 +1049,67 @@ As you might notice, the transaction contains an empty +scriptSig+ because we ha
|
|||||||
====
|
====
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli walletpassphrase foo 360
|
$ bitcoin-cli walletpassphrase foo 360
|
||||||
$ bitcoin-cli signrawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda8<?pdf-cr?>f7db0f6685862aecf53ebd69f9a89c0000000000ffffffff02a0252600000000001976a914d90<?pdf-cr?>d36e98f62968d2bc9bbd68107564a156a9bcf88ac50622500000000001976a91407bdb518fa2e<?pdf-cr?>6089fd810235cf1100c9c13d1fd288ac00000000
|
$ bitcoin-cli signrawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda8↵
|
||||||
</screen>
|
f7db0f6685862aecf53ebd69f9a89c0000000000ffffffff02a0252600000000001976a914d90↵
|
||||||
|
d36e98f62968d2bc9bbd68107564a156a9bcf88ac50622500000000001976a91407bdb518fa2e↵
|
||||||
|
6089fd810235cf1100c9c13d1fd288ac00000000
|
||||||
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
{
|
{
|
||||||
"hex" : "0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53e<?pdf-cr?>bd69f9a89c000000006a47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54<?pdf-cr?>e0a1b76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4af<?pdf-cr?>52051a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71dc512<?pdf-cr?>7ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88<?pdf-cr?>ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac00000000",
|
"hex" : "0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53e↵
|
||||||
|
bd69f9a89c000000006a47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54↵
|
||||||
|
e0a1b76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4af↵
|
||||||
|
52051a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71dc512↵
|
||||||
|
7ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88↵
|
||||||
|
ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac00000000",
|
||||||
"complete" : true
|
"complete" : true
|
||||||
}
|
}
|
||||||
</screen>
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
The +signrawtransaction+ command returns another hex-encoded raw transaction. We decode it to see what changed, with +decoderawtransaction+:
|
The +signrawtransaction+ command returns another hex-encoded raw transaction. We decode it to see what changed, with +decoderawtransaction+:
|
||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli decoderawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda<?pdf-cr?>8f7db0f6685862aecf53ebd69f9a89c000000006a47304402203e8a16522da80cef66bacfbc0c<?pdf-cr?>800c6d52c4a26d1d86a54e0a1b76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87<?pdf-cr?>e3897a273ef54b277e4af52051a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac<?pdf-cr?>1d3f00fd44ea6c71dc5127ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9b<?pdf-cr?>bd68107564a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100<?pdf-cr?>c9c13d1fd288ac00000000
|
$ bitcoin-cli decoderawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda↵
|
||||||
</screen>
|
8f7db0f6685862aecf53ebd69f9a89c000000006a47304402203e8a16522da80cef66bacfbc0c↵
|
||||||
|
800c6d52c4a26d1d86a54e0a1b76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87↵
|
||||||
|
e3897a273ef54b277e4af52051a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac↵
|
||||||
|
1d3f00fd44ea6c71dc5127ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9b↵
|
||||||
|
bd68107564a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100↵
|
||||||
|
c9c13d1fd288ac00000000
|
||||||
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
{
|
{
|
||||||
"txid" : "ae74538baa914f3799081ba78429d5d84f36a0127438e9f721dff584ac17b34<?pdf-cr?>6",
|
"txid" : "ae74538baa914f3799081ba78429d5d84f36a0127438e9f721dff584ac17b34↵
|
||||||
|
6",
|
||||||
"version" : 1,
|
"version" : 1,
|
||||||
"locktime" : 0,
|
"locktime" : 0,
|
||||||
"vin" : [
|
"vin" : [
|
||||||
{
|
{
|
||||||
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acb<?pdf-cr?>ae2c14ae3",
|
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acb↵
|
||||||
|
ae2c14ae3",
|
||||||
"vout" : 0,
|
"vout" : 0,
|
||||||
"scriptSig" : {
|
"scriptSig" : {
|
||||||
"asm" : "304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86<?pdf-cr?>a54e0a1b76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e<?pdf-cr?>4af52051a0601 03c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71dc5<?pdf-cr?>127",
|
"asm" : "304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86↵
|
||||||
"hex" : "47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d<?pdf-cr?>86a54e0a1b76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b27<?pdf-cr?>7e4af52051a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71<?pdf-cr?>dc5127"
|
a54e0a1b76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e↵
|
||||||
|
4af52051a0601 03c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71dc5↵
|
||||||
|
127",
|
||||||
|
"hex" : "47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d↵
|
||||||
|
86a54e0a1b76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b27↵
|
||||||
|
7e4af52051a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71↵
|
||||||
|
dc5127"
|
||||||
},
|
},
|
||||||
"sequence" : 4294967295
|
"sequence" : 4294967295
|
||||||
}
|
}
|
||||||
@ -1045,7 +1119,8 @@ $ bitcoin-cli decoderawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda<?
|
|||||||
"value" : 0.02500000,
|
"value" : 0.02500000,
|
||||||
"n" : 0,
|
"n" : 0,
|
||||||
"scriptPubKey" : {
|
"scriptPubKey" : {
|
||||||
"asm" : "OP_DUP OP_HASH160 d90d36e98f62968d2bc9bbd68107564a15<?pdf-cr?>6a9bcf OP_EQUALVERIFY OP_CHECKSIG",
|
"asm" : "OP_DUP OP_HASH160 d90d36e98f62968d2bc9bbd68107564a15↵
|
||||||
|
6a9bcf OP_EQUALVERIFY OP_CHECKSIG",
|
||||||
"hex" : "76a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88ac",
|
"hex" : "76a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88ac",
|
||||||
"reqSigs" : 1,
|
"reqSigs" : 1,
|
||||||
"type" : "pubkeyhash",
|
"type" : "pubkeyhash",
|
||||||
@ -1058,7 +1133,8 @@ $ bitcoin-cli decoderawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda<?
|
|||||||
"value" : 0.02450000,
|
"value" : 0.02450000,
|
||||||
"n" : 1,
|
"n" : 1,
|
||||||
"scriptPubKey" : {
|
"scriptPubKey" : {
|
||||||
"asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c1<?pdf-cr?>3d1fd2 OP_EQUALVERIFY OP_CHECKSIG",
|
"asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c1↵
|
||||||
|
3d1fd2 OP_EQUALVERIFY OP_CHECKSIG",
|
||||||
"hex" : "76a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac",
|
"hex" : "76a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac",
|
||||||
"reqSigs" : 1,
|
"reqSigs" : 1,
|
||||||
"type" : "pubkeyhash",
|
"type" : "pubkeyhash",
|
||||||
@ -1069,7 +1145,7 @@ $ bitcoin-cli decoderawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda<?
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
</screen>
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
Now, the inputs used in the transaction contain a +scriptSig+, which is a digital signature proving ownership of address +1hvz...+ and removing the lock on the output so that it can be spent. The signature makes this transaction verifiable by any node in the bitcoin network.
|
Now, the inputs used in the transaction contain a +scriptSig+, which is a digital signature proving ownership of address +1hvz...+ and removing the lock on the output so that it can be spent. The signature makes this transaction verifiable by any node in the bitcoin network.
|
||||||
@ -1077,17 +1153,25 @@ Now, the inputs used in the transaction contain a +scriptSig+, which is a digita
|
|||||||
Now it's time to submit the newly created transaction to the network. We do that with the command +sendrawtransaction+, which takes the raw hex string produced by +signrawtransaction+. This is the same string we just decoded:
|
Now it's time to submit the newly created transaction to the network. We do that with the command +sendrawtransaction+, which takes the raw hex string produced by +signrawtransaction+. This is the same string we just decoded:
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli sendrawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda8<?pdf-cr?>f7db0f6685862aecf53ebd69f9a89c000000006a47304402203e8a16522da80cef66bacfbc0c8<?pdf-cr?>00c6d52c4a26d1d86a54e0a1b76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e<?pdf-cr?>3897a273ef54b277e4af52051a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1<?pdf-cr?>d3f00fd44ea6c71dc5127ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bb<?pdf-cr?>d68107564a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c<?pdf-cr?>9c13d1fd288ac00000000ae74538baa914f3799081ba78429d5d84f36a0127438e9f721dff584<?pdf-cr?>ac17b346
|
$ bitcoin-cli sendrawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda8↵
|
||||||
</screen>
|
f7db0f6685862aecf53ebd69f9a89c000000006a47304402203e8a16522da80cef66bacfbc0c8↵
|
||||||
|
00c6d52c4a26d1d86a54e0a1b76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e↵
|
||||||
|
3897a273ef54b277e4af52051a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1↵
|
||||||
|
d3f00fd44ea6c71dc5127ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bb↵
|
||||||
|
d68107564a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c↵
|
||||||
|
9c13d1fd288ac00000000ae74538baa914f3799081ba78429d5d84f36a0127438e9f721dff584↵
|
||||||
|
ac17b346
|
||||||
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
The command +sendrawtransaction+ returns a _transaction hash (txid)_ as it submits the transaction on the network. We can now query that transaction ID with +gettransaction+:
|
The command +sendrawtransaction+ returns a _transaction hash (txid)_ as it submits the transaction on the network. We can now query that transaction ID with +gettransaction+:
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
$ bitcoin-cli gettransaction ae74538baa914f3799081ba78429d5d84f36a0127438e9f7<?pdf-cr?>21dff584ac17b346
|
$ bitcoin-cli gettransaction ae74538baa914f3799081ba78429d5d84f36a0127438e9f7↵
|
||||||
</screen>
|
21dff584ac17b346
|
||||||
|
</pre>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
[source,json]
|
[source,json]
|
||||||
|
@ -112,7 +112,6 @@ $ bx seed | bx ec-new | bx ec-to-wif
|
|||||||
image::images/msbt_0402.png["ecc-curve"]
|
image::images/msbt_0402.png["ecc-curve"]
|
||||||
|
|
||||||
Bitcoin uses a specific elliptic curve and set of mathematical constants, as defined in a standard called((("secp256k1 curve standard"))) +secp256k1+, established by the((("National Institute of Standards and Technology (NIST)"))) National Institute of Standards and Technology (NIST). The +secp256k1+ curve is defined by the following function, which produces an elliptic curve:
|
Bitcoin uses a specific elliptic curve and set of mathematical constants, as defined in a standard called((("secp256k1 curve standard"))) +secp256k1+, established by the((("National Institute of Standards and Technology (NIST)"))) National Institute of Standards and Technology (NIST). The +secp256k1+ curve is defined by the following function, which produces an elliptic curve:
|
||||||
|
|
||||||
[latexmath]
|
[latexmath]
|
||||||
++++
|
++++
|
||||||
\begin{equation}
|
\begin{equation}
|
||||||
@ -292,10 +291,6 @@ image::images/msbt_0406.png["Base58CheckEncoding"]
|
|||||||
|
|
||||||
In bitcoin, most of the data presented to the user is Base58Check-encoded to make it compact, easy to read, and easy to detect errors. The version prefix in Base58Check encoding is used to create easily distinguishable formats, which when encoded in Base58 contain specific characters at the beginning of the Base58Check-encoded payload. These characters make it easy for humans to identify the type of data that is encoded and how to use it. This is what differentiates, for example, a Base58Check-encoded bitcoin address that starts with a 1 from a Base58Check-encoded private key WIF format that starts with a 5. Some example version prefixes and the resulting Base58 characters are shown in <<base58check_versions>>.((("Base58Check encoding","prefixes, listed")))
|
In bitcoin, most of the data presented to the user is Base58Check-encoded to make it compact, easy to read, and easy to detect errors. The version prefix in Base58Check encoding is used to create easily distinguishable formats, which when encoded in Base58 contain specific characters at the beginning of the Base58Check-encoded payload. These characters make it easy for humans to identify the type of data that is encoded and how to use it. This is what differentiates, for example, a Base58Check-encoded bitcoin address that starts with a 1 from a Base58Check-encoded private key WIF format that starts with a 5. Some example version prefixes and the resulting Base58 characters are shown in <<base58check_versions>>.((("Base58Check encoding","prefixes, listed")))
|
||||||
|
|
||||||
++++
|
|
||||||
<?hard-pagebreak?>
|
|
||||||
++++
|
|
||||||
|
|
||||||
[[base58check_versions]]
|
[[base58check_versions]]
|
||||||
.Base58Check version prefix and encoded result examples
|
.Base58Check version prefix and encoded result examples
|
||||||
[options="header"]
|
[options="header"]
|
||||||
@ -358,10 +353,6 @@ Address: 1PRTTaJesdNovgne6Ehcdu1fpEdX7913CK
|
|||||||
|
|
||||||
<<table_4-3>> shows the private key generated in these three formats.
|
<<table_4-3>> shows the private key generated in these three formats.
|
||||||
|
|
||||||
++++
|
|
||||||
<?hard-pagebreak?>
|
|
||||||
++++
|
|
||||||
|
|
||||||
[[table_4-3]]
|
[[table_4-3]]
|
||||||
.Example: Same key, different formats
|
.Example: Same key, different formats
|
||||||
[options="header"]
|
[options="header"]
|
||||||
@ -520,7 +511,7 @@ include::code/key-to-address-ecc-example.py[]
|
|||||||
.Running key-to-address-ecc-example.py
|
.Running key-to-address-ecc-example.py
|
||||||
====
|
====
|
||||||
++++
|
++++
|
||||||
<screen>
|
<pre data-type="programlisting">
|
||||||
$ python key-to-address-ecc-example.py
|
$ python key-to-address-ecc-example.py
|
||||||
Private Key (hex) is:
|
Private Key (hex) is:
|
||||||
3aba4162c7251c891207b747840551a71939b0de081f85c4e44cf7c13e41daa6
|
3aba4162c7251c891207b747840551a71939b0de081f85c4e44cf7c13e41daa6
|
||||||
@ -543,7 +534,7 @@ Bitcoin Address (b58check) is:
|
|||||||
1thMirt546nngXqyPEz532S8fLwbozud8
|
1thMirt546nngXqyPEz532S8fLwbozud8
|
||||||
Compressed Bitcoin Address (b58check) is:
|
Compressed Bitcoin Address (b58check) is:
|
||||||
14cxpo3MBCYYWCgF74SWTdcmxipnGUsPw3
|
14cxpo3MBCYYWCgF74SWTdcmxipnGUsPw3
|
||||||
</screen>
|
</pre>
|
||||||
++++
|
++++
|
||||||
====
|
====
|
||||||
|
|
||||||
@ -636,7 +627,7 @@ BIP0039 defines the creation of a mnemonic code and seed as a follows:
|
|||||||
|
|
||||||
The mnemonic code represents 128 to 256 bits, which are used to derive a longer (512-bit) seed through the use of the key-stretching function PBKDF2. The resulting seed is used to create a deterministic wallet and all of its derived keys.
|
The mnemonic code represents 128 to 256 bits, which are used to derive a longer (512-bit) seed through the use of the key-stretching function PBKDF2. The resulting seed is used to create a deterministic wallet and all of its derived keys.
|
||||||
|
|
||||||
Tables pass:[<xref linkend="table_4-6" xrefstyle="select: labelnumber"/>] and pass:[<xref linkend="table_4-7" xrefstyle="select: labelnumber"/>] show some examples of mnemonic codes and the seeds they produce.
|
Tables pass:[<a data-type="xref" href="#table_4-6" data-xrefstyle="select: labelnumber">#table_4-6</a>] and pass:[<a data-type="xref" href="#table_4-7" data-xrefstyle="select: labelnumber">#table_4-7</a>] show some examples of mnemonic codes and the seeds they produce.
|
||||||
|
|
||||||
[[table_4-6]]
|
[[table_4-6]]
|
||||||
.128-bit entropy mnemonic code and resulting seed
|
.128-bit entropy mnemonic code and resulting seed
|
||||||
@ -1059,7 +1050,7 @@ image::images/msbt_0415.png[]
|
|||||||
((("paper wallets","spending")))((("private keys","exposing with paper wallets")))Although you can deposit funds into a paper wallet several times, you should withdraw all funds only once, spending everything. This is because in the process of unlocking and spending funds some wallets might generate a change address if you spend less than the whole amount. Additionally, if the computer you use to sign the transaction is compromised, you risk exposing the private key. By spending the entire balance of a paper wallet only once, you reduce the risk of key compromise. If you need only a small amount, send any remaining funds to a new paper wallet in the same transaction.
|
((("paper wallets","spending")))((("private keys","exposing with paper wallets")))Although you can deposit funds into a paper wallet several times, you should withdraw all funds only once, spending everything. This is because in the process of unlocking and spending funds some wallets might generate a change address if you spend less than the whole amount. Additionally, if the computer you use to sign the transaction is compromised, you risk exposing the private key. By spending the entire balance of a paper wallet only once, you reduce the risk of key compromise. If you need only a small amount, send any remaining funds to a new paper wallet in the same transaction.
|
||||||
====
|
====
|
||||||
|
|
||||||
Paper wallets come in many designs and sizes, with many different features. Some are intended to be given as gifts and have seasonal themes, such as Christmas and New Year's themes. Others are designed for storage in a bank vault or safe with the private key hidden in some way, either with opaque scratch-off stickers, or folded and sealed with tamper-proof adhesive foil. Figures pass:[<xref linkend="paper_wallet_bpw" xrefstyle="select: labelnumber"/>] through pass:[<xref linkend="paper_wallet_spw" xrefstyle="select: labelnumber"/>] show various examples of paper wallets with security and backup features.
|
Paper wallets come in many designs and sizes, with many different features. Some are intended to be given as gifts and have seasonal themes, such as Christmas and New Year's themes. Others are designed for storage in a bank vault or safe with the private key hidden in some way, either with opaque scratch-off stickers, or folded and sealed with tamper-proof adhesive foil. Figures pass:[<a data-type="xref" href="#paper_wallet_bpw" data-xrefstyle="select: labelnumber">#paper_wallet_bpw</a>] through pass:[<a data-type="xref" href="#paper_wallet_spw" data-xrefstyle="select: labelnumber">#paper_wallet_spw</a>] show various examples of paper wallets with security and backup features.
|
||||||
|
|
||||||
[[paper_wallet_bpw]]
|
[[paper_wallet_bpw]]
|
||||||
.An example of a paper wallet from bitcoinpaperwallet.com with the private key on a folding flap.
|
.An example of a paper wallet from bitcoinpaperwallet.com with the private key on a folding flap.
|
||||||
|
@ -377,7 +377,7 @@ The two scripts together would form the following combined validation script:
|
|||||||
|
|
||||||
When executed, this combined script will evaluate to TRUE if, and only if, the unlocking script matches the conditions set by the locking script. In other words, the result will be TRUE if the unlocking script has a valid signature from the cafe's private key that corresponds to the public key hash set as an encumbrance.
|
When executed, this combined script will evaluate to TRUE if, and only if, the unlocking script matches the conditions set by the locking script. In other words, the result will be TRUE if the unlocking script has a valid signature from the cafe's private key that corresponds to the public key hash set as an encumbrance.
|
||||||
|
|
||||||
Figures pass:[<xref linkend="P2PubKHash1" xrefstyle="select: labelnumber"/>] and pass:[<xref linkend="P2PubKHash2" xrefstyle="select: labelnumber"/>] show (in two parts) a step-by-step execution of the combined script, which will prove this is a valid transaction.(((range="endofrange", startref="ix_ch05-asciidoc16")))(((range="endofrange", startref="ix_ch05-asciidoc15")))
|
Figures pass:[<a data-type="xref" href="#P2PubKHash1" data-xrefstyle="select: labelnumber">#P2PubKHash1</a>] and pass:[<a data-type="xref" href="#P2PubKHash2" data-xrefstyle="select: labelnumber">#P2PubKHash2</a>] show (in two parts) a step-by-step execution of the combined script, which will prove this is a valid transaction.(((range="endofrange", startref="ix_ch05-asciidoc16")))(((range="endofrange", startref="ix_ch05-asciidoc15")))
|
||||||
|
|
||||||
[[P2PubKHash1]]
|
[[P2PubKHash1]]
|
||||||
.Evaluating a script for a P2PKH transaction (Part 1 of 2)
|
.Evaluating a script for a P2PKH transaction (Part 1 of 2)
|
||||||
|
@ -52,11 +52,11 @@ The nonce, difficulty target, and timestamp are used in the mining process and w
|
|||||||
[[block_hash]]
|
[[block_hash]]
|
||||||
=== Block Identifiers: Block Header Hash and Block Height
|
=== Block Identifiers: Block Header Hash and Block Height
|
||||||
|
|
||||||
((("blocks","header hash")))((("blocks","height")))((("blocks","identifiers")))The primary identifier of a block is its cryptographic hash, a digital fingerprint, made by hashing the block header twice through the SHA256 algorithm. The resulting 32-byte hash is called the((("block hash")))((("block header hash"))) _block hash_ but is more accurately the _block header hash_, pass:[<phrase role="keep-together">because only the block header is used to compute it. For example,</phrase>] +000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f+ is the block hash of the first bitcoin block ever created. The block hash identifies a block uniquely and unambiguously and can be independently derived by any node by simply hashing the block header.
|
((("blocks","header hash")))((("blocks","height")))((("blocks","identifiers")))The primary identifier of a block is its cryptographic hash, a digital fingerprint, made by hashing the block header twice through the SHA256 algorithm. The resulting 32-byte hash is called the((("block hash")))((("block header hash"))) _block hash_ but is more accurately the _block header hash_, pass:[<span role="keep-together">because only the block header is used to compute it. For example,</span>] +000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f+ is the block hash of the first bitcoin block ever created. The block hash identifies a block uniquely and unambiguously and can be independently derived by any node by simply hashing the block header.
|
||||||
|
|
||||||
Note that the block hash is not actually included inside the block's data structure, neither when the block is transmitted on the network, nor when it is stored on a node's persistence storage as part of the blockchain. Instead, the block's hash is computed by each node as the block is received from the network. The block hash might be stored in a separate database table as part of the block's metadata, to facilitate indexing and faster retrieval of blocks from disk.
|
Note that the block hash is not actually included inside the block's data structure, neither when the block is transmitted on the network, nor when it is stored on a node's persistence storage as part of the blockchain. Instead, the block's hash is computed by each node as the block is received from the network. The block hash might be stored in a separate database table as part of the block's metadata, to facilitate indexing and faster retrieval of blocks from disk.
|
||||||
|
|
||||||
A second way to identify a block is by its position in the blockchain, called the((("block height"))) pass:[<phrase role="keep-together"><emphasis>block height</emphasis>. The first block ever created is at block height 0 (zero) and is the</phrase>] pass:[<phrase role="keep-together">same block that was previously referenced by the following block hash</phrase>] +000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f+. A block can thus be identified two ways: by referencing the block hash or by referencing the block height. Each subsequent block added "on top" of that first block is one position "higher" in the blockchain, like boxes stacked one on top of the other. The block height on January 1, 2014, was approximately 278,000, meaning there were 278,000 blocks stacked on top of the first block created in January 2009.
|
A second way to identify a block is by its position in the blockchain, called the((("block height"))) pass:[<span role="keep-together"><em>block height</em>. The first block ever created is at block height 0 (zero) and is the</span>] pass:[<span role="keep-together">same block that was previously referenced by the following block hash</span>] +000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f+. A block can thus be identified two ways: by referencing the block hash or by referencing the block height. Each subsequent block added "on top" of that first block is one position "higher" in the blockchain, like boxes stacked one on top of the other. The block height on January 1, 2014, was approximately 278,000, meaning there were 278,000 blocks stacked on top of the first block created in January 2009.
|
||||||
|
|
||||||
Unlike the block hash, the block height is not a unique identifier. Although a single block will always have a specific and invariant block height, the reverse is not true—the block height does not always identify a single block. Two or more blocks might have the same block height, competing for the same position in the blockchain. This scenario is discussed in detail in the section <<forks>>. The block height is also not a part of the block's data structure; it is not stored within the block. Each node dynamically identifies a block's position (height) in the blockchain when it is received from the bitcoin network. The block height might also be stored as metadata in an indexed database table for faster retrieval.
|
Unlike the block hash, the block height is not a unique identifier. Although a single block will always have a specific and invariant block height, the reverse is not true—the block height does not always identify a single block. Two or more blocks might have the same block height, competing for the same position in the blockchain. This scenario is discussed in detail in the section <<forks>>. The block height is also not a part of the block's data structure; it is not stored within the block. Each node dynamically identifies a block's position (height) in the blockchain when it is received from the bitcoin network. The block height might also be stored as metadata in an indexed database table for faster retrieval.
|
||||||
|
|
||||||
@ -202,10 +202,6 @@ image::images/msbt_0705.png["merkle_tree_path"]
|
|||||||
|
|
||||||
The code in <<merkle_example>> demonstrates the process of creating a merkle tree from the leaf-node hashes up to the root, using the libbitcoin library for some helper functions.
|
The code in <<merkle_example>> demonstrates the process of creating a merkle tree from the leaf-node hashes up to the root, using the libbitcoin library for some helper functions.
|
||||||
|
|
||||||
++++
|
|
||||||
<?hard-pagebreak?>
|
|
||||||
++++
|
|
||||||
|
|
||||||
[[merkle_example]]
|
[[merkle_example]]
|
||||||
.Building a merkle tree
|
.Building a merkle tree
|
||||||
====
|
====
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[[ch9]]
|
[[ch9]]
|
||||||
== Alternative Chains, Currencies, pass:[<phrase role="keep-together">and Applications</phrase>]
|
== Alternative Chains, Currencies, pass:[<span role="keep-together">and Applications</span>]
|
||||||
|
|
||||||
Bitcoin was the result of 20 years of research in distributed systems and currencies and brought a revolutionary new technology into the space: the decentralized consensus mechanism based on proof of work. This invention at the heart of bitcoin has ushered a wave of innovation in currencies, financial services, economics, distributed systems, voting systems, corporate governance, and contracts.
|
Bitcoin was the result of 20 years of research in distributed systems and currencies and brought a revolutionary new technology into the space: the decentralized consensus mechanism based on proof of work. This invention at the heart of bitcoin has ushered a wave of innovation in currencies, financial services, economics, distributed systems, voting systems, corporate governance, and contracts.
|
||||||
|
|
||||||
@ -354,4 +354,4 @@ else:
|
|||||||
|
|
||||||
=== Future of Currencies
|
=== Future of Currencies
|
||||||
|
|
||||||
The future of cryptographic currencies overall is even brighter than the future of bitcoin. Bitcoin introduced a completely new form of decentralized organization and consensus that has spawned hundreds of incredible innovations. These inventions will likely affect broad sectors of the economy, from distributed systems science to finance, economics, currencies, central banking, and corporate governance. Many human activities that previously required centralized institutions or organizations to function as authoritative or trusted points of control can now be decentralized. The invention of the blockchain and consensus system will significantly reduce the cost of organization and coordination on large-scale systems, while removing opportunities for concentration of power, corruption, and regulatory capture.
|
The future of cryptographic currencies overall is even brighter than the future of bitcoin. Bitcoin introduced a completely new form of decentralized organization and consensus that has spawned hundreds of incredible innovations. These inventions will likely affect broad sectors of the economy, from distributed systems science to finance, economics, currencies, central banking, and corporate governance. Many human activities that previously required centralized institutions or organizations to function as authoritative or trusted points of control can now be decentralized. The invention of the blockchain and consensus system will significantly reduce the cost of organization and coordination on large-scale systems, while removing opportunities for concentration of power, corruption, and regulatory capture.
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
[colophon]
|
|
||||||
= Colophon
|
|
||||||
|
|
||||||
The animal on the cover of _Mastering Bitcoin_ is a leafcutter ant (__Atta colombica__). The leafcutter ant, a nongeneric name, are tropical, fungus-growing ants endemic to South and Central America, Mexico, and southern United States. Aside from humans, leafcutter ants form the largest and most complex animal societies on the planet. They are named for the way they chew leaves, which serve as nutrition for their fungal garden.
|
|
||||||
|
|
||||||
Winged ants, both male and female, take part in a mass exit of their nest known as the _revoada_, or a nuptial flight. Females mate with multiple males to collect the 300 million sperm necessary to set up a colony. Females also store bits of the parental fungus garden mycelium in the infrabuccal pocket located in their oral cavity; they will use this to start their own fungal gardens. Once grounded, the female loses its wings and sets up an underground lair for her colony. The success rate for new queens is low: 2.5% establish a long-lived colony.
|
|
||||||
|
|
||||||
Once a colony has matured, ants are divided into castes based on size, with each caste performing various functions. There are usually four castes: minims, the smallest workers that tend to the young and fungus gardens; minors, slightly larger than minima, are the first line of defense for the colony and patrol the surrounding terrain and attack enemies; mediae, the general foragers that cut leaves and bring back leaf fragments to the nest; and majors, the largest worker ants that act as soldiers, defending the nest from intruders. Recent research has shown that majors also clear main foraging trails and carry bulky items back to the nest.
|
|
||||||
|
|
||||||
Many of the animals on O'Reilly covers are endangered; all of them are important to the world. To learn more about how you can help, go to http://animals.oreilly.com[animals.oreilly.com].
|
|
||||||
|
|
||||||
The cover image is from __Insects Abroad__. The cover fonts are URW Typewriter and Guardian Sans. The text font is Adobe Minion Pro; the heading font is Adobe Myriad Condensed; and the code font is Dalton Maag's Ubuntu Mono.
|
|
13
colo.html
Normal file
13
colo.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<section id="colophon" data-type="colophon">
|
||||||
|
<h1>Colophon</h1>
|
||||||
|
|
||||||
|
<p>The animal on the cover of <em>Mastering Bitcoin</em> is a leafcutter ant (<em>Atta colombica</em>). The leafcutter ant, a nongeneric name, are tropical, fungus-growing ants endemic to South and Central America, Mexico, and southern United States. Aside from humans, leafcutter ants form the largest and most complex animal societies on the planet. They are named for the way they chew leaves, which serve as nutrition for their fungal garden.</p>
|
||||||
|
|
||||||
|
<p>Winged ants, both male and female, take part in a mass exit of their nest known as the _revoada_, or a nuptial flight. Females mate with multiple males to collect the 300 million sperm necessary to set up a colony. Females also store bits of the parental fungus garden mycelium in the infrabuccal pocket located in their oral cavity; they will use this to start their own fungal gardens. Once grounded, the female loses its wings and sets up an underground lair for her colony. The success rate for new queens is low: 2.5% establish a long-lived colony.</p>
|
||||||
|
|
||||||
|
<p>Once a colony has matured, ants are divided into castes based on size, with each caste performing various functions. There are usually four castes: minims, the smallest workers that tend to the young and fungus gardens; minors, slightly larger than minima, are the first line of defense for the colony and patrol the surrounding terrain and attack enemies; mediae, the general foragers that cut leaves and bring back leaf fragments to the nest; and majors, the largest worker ants that act as soldiers, defending the nest from intruders. Recent research has shown that majors also clear main foraging trails and carry bulky items back to the nest.</p>
|
||||||
|
|
||||||
|
<p>Many of the animals on O'Reilly covers are endangered; all of them are important to the world. To learn more about how you can help, go to <a class="orm:hideurl" href="http://animals.oreilly.com"><em>animals.oreilly.com</em></a>.</p>
|
||||||
|
|
||||||
|
<p>The cover image is from <em>Insects Abroad</em>. The cover fonts are URW Typewriter and Guardian Sans. The text font is Adobe Minion Pro; the heading font is Adobe Myriad Condensed; and the code font is Dalton Maag's Ubuntu Mono.</p>
|
||||||
|
</section>
|
@ -5,7 +5,7 @@
|
|||||||
<p class="printlocation">Printed in the United States of America.</p>
|
<p class="printlocation">Printed in the United States of America.</p>
|
||||||
<p class="publisher">Published by <span class="publishername">O'Reilly Media, Inc.</span>, 1005 Gravenstein Highway North, Sebastopol, CA 95472.</p>
|
<p class="publisher">Published by <span class="publishername">O'Reilly Media, Inc.</span>, 1005 Gravenstein Highway North, Sebastopol, CA 95472.</p>
|
||||||
<p>O'Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most
|
<p>O'Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most
|
||||||
titles (<a href="http://safaribooksonline.com">http://safaribooksonline.com</a>). For more information, contact our corporate/institutional sales department: 800-998-9938 or <span data-type="email">corporate@oreilly.com</span>.</p>
|
titles (<a href="http://safaribooksonline.com">http://safaribooksonline.com</a>). For more information, contact our corporate/institutional sales department: 800-998-9938 or <span data-type="email"><em>corporate@oreilly.com</em></span>.</p>
|
||||||
<ul class="stafflist">
|
<ul class="stafflist">
|
||||||
<li><span class="staffrole">Editors: </span>Mike Loukides and Allyson MacDonald</li>
|
<li><span class="staffrole">Editors: </span>Mike Loukides and Allyson MacDonald</li>
|
||||||
<li><span class="staffrole">Production Editor: </span>Melanie Yarbrough</li>
|
<li><span class="staffrole">Production Editor: </span>Melanie Yarbrough</li>
|
||||||
@ -22,8 +22,12 @@
|
|||||||
<div>
|
<div>
|
||||||
<h1 class="revisions">Revision History for the First Edition</h1>
|
<h1 class="revisions">Revision History for the First Edition</h1>
|
||||||
<ul class="releases">
|
<ul class="releases">
|
||||||
<li><span class="revdate">2014-12-01:</span> First release</li>
|
<li><span class="revdate">2014-12-01</span>
|
||||||
<li><span class="revdate">2015-03-06:</span> Second release</li>
|
First release
|
||||||
|
</li>
|
||||||
|
<li><span class="revdate">2015-03-06</span>
|
||||||
|
Second release
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<p class="errata">See <a href="http://oreilly.com/catalog/errata.csp?isbn=9781449374044">http://oreilly.com/catalog/errata.csp?isbn=9781449374044</a> for release details.</p>
|
<p class="errata">See <a href="http://oreilly.com/catalog/errata.csp?isbn=9781449374044">http://oreilly.com/catalog/errata.csp?isbn=9781449374044</a> for release details.</p>
|
||||||
@ -32,7 +36,7 @@
|
|||||||
<p>While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.<!--PROD: Uncomment the following sentence if appropriate and add it to the above para: --><!--This book is not intended as [legal/medical/financial; use the appropriate reference] advice. Please consult a qualified professional if you require [legal/medical/financial] advice.--></p>
|
<p>While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.<!--PROD: Uncomment the following sentence if appropriate and add it to the above para: --><!--This book is not intended as [legal/medical/financial; use the appropriate reference] advice. Please consult a qualified professional if you require [legal/medical/financial] advice.--></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="copyright-bottom">
|
<div class="copyright-bottom">
|
||||||
<p class="isbn">978-1-449-49374-4</p>
|
<p class="isbn">978-1-4494-9374-4</p>
|
||||||
<p class="printer">[LSI]</p>
|
<p class="printer">[LSI]</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@ -62,39 +62,43 @@ We appreciate, but do not require, attribution. An attribution usually includes
|
|||||||
|
|
||||||
Some editions of this book are offered under an open source license, such as CC-BY-NC (creativecommons.org), in which case the terms of that license apply.
|
Some editions of this book are offered under an open source license, such as CC-BY-NC (creativecommons.org), in which case the terms of that license apply.
|
||||||
|
|
||||||
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at pass:[<email>permissions@oreilly.com</email>].
|
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at pass:[<a href="mailto:permissions@oreilly.com">permissions@oreilly.com</email>].
|
||||||
|
|
||||||
=== Safari® Books Online
|
=== Safari® Books Online
|
||||||
|
|
||||||
[role = "safarienabled"]
|
[role = "safarienabled"]
|
||||||
[NOTE]
|
[NOTE]
|
||||||
====
|
====
|
||||||
pass:[<ulink role="orm:hideurl:ital" url="http://my.safaribooksonline.com/?portal=oreilly">Safari Books Online</ulink>] is an on-demand digital library that delivers expert pass:[<ulink role="orm:hideurl" url="http://www.safaribooksonline.com/content">content</ulink>] in both book and video form from the world’s leading authors in technology and business.
|
pass:[<a href="http://safaribooksonline.com" class="orm:hideurl:ital"><em class="hyperlink">Safari Books Online</em></a>] is an on-demand digital library that delivers expert pass:[<a href="https://www.safaribooksonline.com/explore/" class="orm:hideurl">content</a>] in both book and video form from the world’s leading authors in technology and business.
|
||||||
====
|
====
|
||||||
|
|
||||||
Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.
|
Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.
|
||||||
|
|
||||||
Safari Books Online offers a range of pass:[<ulink role="orm:hideurl" url="http://www.safaribooksonline.com/subscriptions">product mixes</ulink>] and pricing programs for pass:[<ulink role="orm:hideurl" url="http://www.safaribooksonline.com/organizations-teams">organizations</ulink>], pass:[<ulink role="orm:hideurl" url="http://www.safaribooksonline.com/government">government agencies</ulink>], and pass:[<ulink role="orm:hideurl" url="http://www.safaribooksonline.com/individuals">individuals</ulink>]. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens pass:[<ulink role="orm:hideurl" url="http://www.safaribooksonline.com/publishers">more</ulink>]. For more information about Safari Books Online, please visit us pass:[<ulink role="orm:hideurl" url="http://www.safaribooksonline.com/">online</ulink>].
|
++++
|
||||||
|
<p>Safari Books Online offers a range of <a href="https://www.safaribooksonline.com/pricing/" class="orm:hideurl">plans and pricing</a> for <a href="https://www.safaribooksonline.com/enterprise/" class="orm:hideurl">enterprise</a>, <a href="https://www.safaribooksonline.com/government/" class="orm:hideurl">government</a>, <a href="https://www.safaribooksonline.com/academic-public-library/" class="orm:hideurl">education</a>, and individuals.</p>
|
||||||
|
|
||||||
|
<p>Members have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds <a href="https://www.safaribooksonline.com/our-library/" class="orm:hideurl">more</a>. For more information about Safari Books Online, please visit us <a class="orm:hideurl" href="http://safaribooksonline.com">online</a>.</p>
|
||||||
|
++++
|
||||||
|
|
||||||
=== How to Contact Us
|
=== How to Contact Us
|
||||||
|
|
||||||
Please address comments and questions concerning this book to the publisher:
|
Please address comments and questions concerning this book to the publisher:
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<simplelist>
|
<ul class="simplelist">
|
||||||
<member>O’Reilly Media, Inc.</member>
|
<li>O’Reilly Media, Inc.</li>
|
||||||
<member>1005 Gravenstein Highway North</member>
|
<li>1005 Gravenstein Highway North</li>
|
||||||
<member>Sebastopol, CA 95472</member>
|
<li>Sebastopol, CA 95472</li>
|
||||||
<member>800-998-9938 (in the United States or Canada)</member>
|
<li>800-998-9938 (in the United States or Canada)</li>
|
||||||
<member>707-829-0515 (international or local)</member>
|
<li>707-829-0515 (international or local)</li>
|
||||||
<member>707-829-0104 (fax)</member>
|
<li>707-829-0104 (fax)</li>
|
||||||
</simplelist>
|
</ul>
|
||||||
++++
|
++++
|
||||||
|
|
||||||
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at link:$$http://bit.ly/mastering_bitcoin$$[].
|
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at link:$$http://bit.ly/mastering_bitcoin$$[].
|
||||||
|
|
||||||
|
|
||||||
To comment or ask technical questions about this book, send email to pass:[<email>bookquestions@oreilly.com</email>].
|
To comment or ask technical questions about this book, send email to pass:[<a class="email" href="mailto:bookquestions@oreilly.com"><em>bookquestions@oreilly.com</em></a>].
|
||||||
|
|
||||||
For more information about our books, courses, conferences, and news, see our website at link:$$http://www.oreilly.com$$[].
|
For more information about our books, courses, conferences, and news, see our website at link:$$http://www.oreilly.com$$[].
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
@charset "UTF-8";
|
@charset "UTF-8";
|
||||||
|
|
||||||
@import "DYNAMIC CSS PLACEHOLDER";
|
|
||||||
|
|
||||||
/*--------Put Your Custom CSS Rules Below--------*/
|
/*--------Put Your Custom CSS Rules Below--------*/
|
||||||
|
|
||||||
/*----Uncomment to turn on automatic code wrapping----*/
|
/*----Uncomment to turn on automatic code wrapping----*/
|
||||||
@ -53,4 +51,4 @@ p.titlepageauthor {
|
|||||||
div.colophon {
|
div.colophon {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
----*/
|
----*/
|
||||||
|
Loading…
Reference in New Issue
Block a user