diff --git a/appdx-pycoin.asciidoc b/appdx-pycoin.asciidoc index 4e43f736..e99a12c0 100644 --- a/appdx-pycoin.asciidoc +++ b/appdx-pycoin.asciidoc @@ -20,9 +20,9 @@ $ ku create input : create network : Bitcoin -wallet key : xprv9s21ZrQH143K3LU5ctPZTBnb9kTjA5Su9DcWHvXJemiJBsY7VqXUG7hipgdWaU\ +wallet key : xprv9s21ZrQH143K3LU5ctPZTBnb9kTjA5Su9DcWHvXJemiJBsY7VqXUG7hipgdWaU m2nhnzdvxJf5KJo9vjP2nABX65c5sFsWsV8oXcbpehtJi -public version : xpub661MyMwAqRbcFpYYiuvZpKjKhnJDZYAkWSY76JvvD7FH4fsG3Nqiov2CfxzxY8\ +public version : xpub661MyMwAqRbcFpYYiuvZpKjKhnJDZYAkWSY76JvvD7FH4fsG3Nqiov2CfxzxY8 DGcpfT56AMFeo8M8KPkFMfLUtvwjwb6WPv8rY65L2q8Hz tree depth : 0 fingerprint : 9d9c6092 @@ -40,7 +40,7 @@ public pair y : 59807879657469774102040120298272207730921291736633247737077406 y as hex : 843a0f6ed9c0eb1962c74533795406914fe3f1957c5238951f4fe245a4fcd625 y parity : odd key pair as sec : 03a90b3008792432060fa04365941e09a8e4adf928bdbdb9dad41131274e379322 - uncompressed : 04a90b3008792432060fa04365941e09a8e4adf928bdbdb9dad41131274e379322\ + uncompressed : 04a90b3008792432060fa04365941e09a8e4adf928bdbdb9dad41131274e379322 843a0f6ed9c0eb1962c74533795406914fe3f1957c5238951f4fe245a4fcd625 hash160 : 9d9c609247174ae323acfc96c852753fe3c8819d uncompressed : 8870d869800c9b91ce1eb460f4c60540f87c15d7 @@ -60,9 +60,9 @@ $ ku P:foo input : P:foo network : Bitcoin -wallet key : xprv9s21ZrQH143K31AgNK5pyVvW23gHnkBq2wh5aEk6g1s496M8ZMjxncCKZKgb5j\ +wallet key : xprv9s21ZrQH143K31AgNK5pyVvW23gHnkBq2wh5aEk6g1s496M8ZMjxncCKZKgb5j ZoY5eSJMJ2Vbyvi2hbmQnCuHBujZ2WXGTux1X2k9Krdtq -public version : xpub661MyMwAqRbcFVF9ULcqLdsEa5WnCCugQAcgNd9iEMQ31tgH6u4DLQWoQayvtS\ +public version : xpub661MyMwAqRbcFVF9ULcqLdsEa5WnCCugQAcgNd9iEMQ31tgH6u4DLQWoQayvtS VYFvXz2vPPpbXE1qpjoUFidhjFj82pVShWu9curWmb2zy tree depth : 0 fingerprint : 5d353a2e @@ -80,7 +80,7 @@ public pair y : 58994218069605424278320703250689780154785099509277691723126325 y as hex : 826d8b4d3010aea16ff4c1c1d3ae68541d9a04df54a2c48cc241c2983544de52 y parity : even key pair as sec : 02b4e599dfa44555a4ed38bcfff0071d5af676a86abf123c5b4b4e8e67a0b0b13f - uncompressed : 04b4e599dfa44555a4ed38bcfff0071d5af676a86abf123c5b4b4e8e67a0b0b13f\ + uncompressed : 04b4e599dfa44555a4ed38bcfff0071d5af676a86abf123c5b4b4e8e67a0b0b13f 826d8b4d3010aea16ff4c1c1d3ae68541d9a04df54a2c48cc241c2983544de52 hash160 : 5d353a2ecdb262477172852d57a3f11de0c19286 uncompressed : e5bd3a7e6cb62b4c820e51200fb1c148d79e67da @@ -244,7 +244,7 @@ public pair y : 32670510020758816978083085130507043184471273380659243275938904 y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 y parity : even key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 - uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ + uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 @@ -271,7 +271,7 @@ public pair y : 3267051002075881697808308513050704318447127338065924327593890 y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 y parity : even key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 - uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ + uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 @@ -295,7 +295,7 @@ From public pair (on Testnet): ---- $ ku -nT 55066263022277343669578718895168534326250603453777594175500187360389116729240,even -input : 550662630222773436695787188951685343262506034537775941755001873603\ +input : 550662630222773436695787188951685343262506034537775941755001873603 89116729240,even network : Bitcoin testnet public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240 @@ -304,7 +304,7 @@ public pair y : 326705100207588169780830851305070431844712733806592432 y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 y parity : even key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 - uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ + uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 diff --git a/ch02.asciidoc b/ch02.asciidoc index c4db0763..9ec31b56 100644 --- a/ch02.asciidoc +++ b/ch02.asciidoc @@ -43,9 +43,9 @@ image::images/msbt_0202.png["payment-request"] [[payment-request-URL]] .The payment request QR code encodes the following URL, defined in BIP0021: ---- -bitcoin:1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA?\ -amount=0.015&\ -label=Bob%27s%20Cafe&\ +bitcoin:1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA? +amount=0.015& +label=Bob%27s%20Cafe& message=Purchase%20at%20Bob%27s%20Cafe Components of the URL diff --git a/ch03.asciidoc b/ch03.asciidoc index 8f5c9352..e5336ac2 100644 --- a/ch03.asciidoc +++ b/ch03.asciidoc @@ -645,13 +645,13 @@ $ bitcoin-cli decoderawtransaction 0100000001d717...388ac00000000 "txid" : "d3c7e022ea80c4808e64dd0a1dba009f3eaee2318a4ece562f8ef815952717d7", "vout" : 0, "scriptSig" : { - "asm" : "3045022100a4ebbeec83225dedead659bbde7da3d026c8b8e12e61a2df0dd0\ - 758e227383b302203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9b2ac1b\ - d193dfba201 04793ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede65e4\ + "asm" : "3045022100a4ebbeec83225dedead659bbde7da3d026c8b8e12e61a2df0dd0 + 758e227383b302203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9b2ac1b + d193dfba201 04793ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede65e4 c4b884ac5b5b6dede05ba84727e34c8fd3ee1d6929d7a44b6e111d41cc79e05dbfe5cea", - "hex" : "483045022100a4ebbeec83225dedead659bbde7da3d026c8b8e12e61a2df0d\ - d0758e227383b302203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9b2ac\ - 1bd193dfba2014104793ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede6\ + "hex" : "483045022100a4ebbeec83225dedead659bbde7da3d026c8b8e12e61a2df0d + d0758e227383b302203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9b2ac + 1bd193dfba2014104793ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede6 5e4c4b884ac5b5b6dede05ba84727e34c8fd3ee1d6929d7a44b6e111d41cc79e05dbfe5cea" }, "sequence" : 4294967295 @@ -662,7 +662,7 @@ $ bitcoin-cli decoderawtransaction 0100000001d717...388ac00000000 "value" : 0.05000000, "n" : 0, "scriptPubKey" : { - "asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c13d1fd2\ + "asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c13d1fd2 OP_EQUALVERIFY OP_CHECKSIG", "hex" : "76a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac", "reqSigs" : 1, @@ -676,7 +676,7 @@ $ bitcoin-cli decoderawtransaction 0100000001d717...388ac00000000 "value" : 1.03362847, "n" : 1, "scriptPubKey" : { - "asm" : "OP_DUP OP_HASH160 107b7086b31518935c8d28703d66d09b36231343\ + "asm" : "OP_DUP OP_HASH160 107b7086b31518935c8d28703d66d09b36231343 OP_EQUALVERIFY OP_CHECKSIG", "hex" : "76a914107b7086b31518935c8d28703d66d09b3623134388ac", "reqSigs" : 1, @@ -867,7 +867,7 @@ $ bitcoin-cli gettxout 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae "confirmations" : 7, "value" : 0.05000000, "scriptPubKey" : { - "asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c13d1fd2\ + "asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c13d1fd2 OP_EQUALVERIFY OP_CHECKSIG", "hex" : "76a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac", "reqSigs" : 1, @@ -894,24 +894,24 @@ 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): ---- -$ bitcoin-cli createrawtransaction \ -'[{"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae3", "vout" : 0}]' \ -'{"1LnfTndy3qzXGN19Jwscj1T8LR3MVe3JDb": 0.025, \ +$ bitcoin-cli createrawtransaction +'[{"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae3", "vout" : 0}]' +'{"1LnfTndy3qzXGN19Jwscj1T8LR3MVe3JDb": 0.025, "1hvzSofGwT8cjb8JU7nBsCSfEVQX5u9CL": 0.0245}' -0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c\ -0000000000ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd6810756\ -4a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d\ +0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c +0000000000ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd6810756 +4a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d 1fd288ac00000000 ---- 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: ---- -$ bitcoin-cli decoderawtransaction \ -0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c\ -0000000000ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd6810756\ -4a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d\ +$ bitcoin-cli decoderawtransaction +0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c +0000000000ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd6810756 +4a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d 1fd288ac00000000 ---- [source,json] @@ -936,7 +936,7 @@ $ bitcoin-cli decoderawtransaction \ "value" : 0.02500000, "n" : 0, "scriptPubKey" : { - "asm" : "OP_DUP OP_HASH160 d90d36e98f62968d2bc9bbd68107564a156a9bcf\ + "asm" : "OP_DUP OP_HASH160 d90d36e98f62968d2bc9bbd68107564a156a9bcf OP_EQUALVERIFY OP_CHECKSIG", "hex" : "76a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88ac", "reqSigs" : 1, @@ -950,7 +950,7 @@ $ bitcoin-cli decoderawtransaction \ "value" : 0.02450000, "n" : 1, "scriptPubKey" : { - "asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c13d1fd2\ + "asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c13d1fd2 OP_EQUALVERIFY OP_CHECKSIG", "hex" : "76a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac", "reqSigs" : 1, @@ -975,18 +975,18 @@ As you may notice, the transaction contains an empty +scriptSig+ because we have ---- $ bitcoin-cli walletpassphrase foo 360 -$ bitcoin-cli signrawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862a\ -ecf53ebd69f9a89c0000000000ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564\ +$ bitcoin-cli signrawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862a +ecf53ebd69f9a89c0000000000ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564 a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac00000000 ---- [source,json] ---- { - "hex" : "0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c0000\ -00006a47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54e0a1b76d661f020c9022010397f0\ -0149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4af52051a06012103c9700559f690c4a9182faa8bed88\ -ad8a0c563777ac1d3f00fd44ea6c71dc5127ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9b\ -bd68107564a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac\ + "hex" : "0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c0000 +00006a47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54e0a1b76d661f020c9022010397f0 +0149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4af52051a06012103c9700559f690c4a9182faa8bed88 +ad8a0c563777ac1d3f00fd44ea6c71dc5127ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9b +bd68107564a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac 00000000", "complete" : true } @@ -996,13 +996,13 @@ The +signrawtransaction+ command returns another hex-encoded raw transaction. We [source,bash] ---- -$ bitcoin-cli decoderawtransaction\ -0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c\ -000000006a47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54e0a1b76\ -d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4af52051\ -a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71dc5127ff\ -ffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88a\ -c50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac000000\ +$ bitcoin-cli decoderawtransaction +0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c +000000006a47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54e0a1b76 +d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4af52051 +a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71dc5127ff +ffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88a +c50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac000000 00 ---- [source,json] @@ -1016,13 +1016,13 @@ c50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac000000\ "txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae3", "vout" : 0, "scriptSig" : { - "asm" : "304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54e0a1b76\ - d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4af5\ - 2051a0601 03c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71d\ + "asm" : "304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54e0a1b76 + d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4af5 + 2051a0601 03c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71d c5127", - "hex" : "47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54e0a1b\ - 76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4a\ - f52051a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c\ + "hex" : "47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54e0a1b + 76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4a + f52051a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c 71dc5127" }, "sequence" : 4294967295 @@ -1033,7 +1033,7 @@ c50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac000000\ "value" : 0.02500000, "n" : 0, "scriptPubKey" : { - "asm" : "OP_DUP OP_HASH160 d90d36e98f62968d2bc9bbd68107564a156a9bcf\ + "asm" : "OP_DUP OP_HASH160 d90d36e98f62968d2bc9bbd68107564a156a9bcf OP_EQUALVERIFY OP_CHECKSIG", "hex" : "76a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88ac", "reqSigs" : 1, @@ -1047,7 +1047,7 @@ c50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac000000\ "value" : 0.02450000, "n" : 1, "scriptPubKey" : { - "asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c13d1fd2\ + "asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c13d1fd2 OP_EQUALVERIFY OP_CHECKSIG", "hex" : "76a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac", "reqSigs" : 1, @@ -1066,13 +1066,13 @@ 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: ---- -$ bitcoin-cli sendrawtransaction\ -0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c\ -000000006a47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54e0a1b76\ -d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4af52051\ -a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71dc5127ff\ -ffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88a\ -c50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac000000\ +$ bitcoin-cli sendrawtransaction +0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c +000000006a47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54e0a1b76 +d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4af52051 +a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71dc5127ff +ffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88a +c50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac000000 00 ae74538baa914f3799081ba78429d5d84f36a0127438e9f721dff584ac17b346 @@ -1081,7 +1081,7 @@ ae74538baa914f3799081ba78429d5d84f36a0127438e9f721dff584ac17b346 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+: ---- -$ bitcoin-cli gettransaction \ +$ bitcoin-cli gettransaction ae74538baa914f3799081ba78429d5d84f36a0127438e9f721dff584ac17b346 ---- [source,json] diff --git a/ch04.asciidoc b/ch04.asciidoc index 4c3c89fe..8e8f721d 100644 --- a/ch04.asciidoc +++ b/ch04.asciidoc @@ -133,7 +133,7 @@ image::images/msbt_0403.png["ecc-over-F17-math"] So, for example, the following is a point P with coordinates (x,y) that is a point on the +secp256k1+ curve. You can check this yourself using Python: ---- -P = (55066263022277343669578718895168534326250603453777594175500187360389116729240,\ +P = (55066263022277343669578718895168534326250603453777594175500187360389116729240, 32670510020758816978083085130507043184471273380659243275938904335757337482424) ---- @@ -533,7 +533,7 @@ $ sudo pip install ecdsa $ # Run the script $ python ec-math.py Secret: 38090835015954358862481132628887443905906204995912378278060168703580660294000 -EC point: (70048853531867179489857750497606966272382583471322935454624595540007269312627,\ +EC point: (70048853531867179489857750497606966272382583471322935454624595540007269312627, 105262206478686743191060800263479589329920209527285803935736021686045542353380) BTC public key: 029ade3effb0a67d5c8609850d797366af428f4a0d5194cb221d807770a1522873 ---- @@ -600,7 +600,7 @@ Tables pass:[] and pa |======= | *Entropy input (128 bits)*| 0c1e24e5917779d297e14d45f14e1a1a | *Mnemonic (12 words)* | army van defense carry jealous true garbage claim echo media make crunch -| *Seed (512 bits)* | 3338a6d2ee71c7f28eb5b882159634cd46a898463e9d2d0980f8e80dfbba5b0fa0291e5fb88\ +| *Seed (512 bits)* | 3338a6d2ee71c7f28eb5b882159634cd46a898463e9d2d0980f8e80dfbba5b0fa0291e5fb88 8a599b44b93187be6ee3ab5fd3ead7dd646341b2cdb8d08d13bf7 |======= @@ -610,7 +610,7 @@ Tables pass:[] and pa | *Entropy input (256 bits)* | 2041546864449caff939d32d574753fe684d3c947c3346713dd8423e74abcf8c | *Mnemonic (24 words)* | cake apple borrow silk endorse fitness top denial coil riot stay wolf luggage oxygen faint major edit measure invite love trap field dilemma oblige -| *Seed (512 bits)* | 3972e432e99040f75ebe13a660110c3e29d131a2c808c7ee5f1631d0a977fcf473bee22\ +| *Seed (512 bits)* | 3972e432e99040f75ebe13a660110c3e29d131a2c808c7ee5f1631d0a977fcf473bee22 fce540af281bf7cdeade0dd2c1c795bd02f1e4049e205a0158906c343 |======= @@ -799,20 +799,20 @@ BIP0044 specifies the structure as consisting of five predefined tree levels: ---- $ sx hd-seed > m # create a new master private key from a seed and store in file "m" $ cat m # show the master extended private key -xprv9s21ZrQH143K38iQ9Y5p6qoB8C75TE71NfpyQPdfGvzghDt39DHPFpovvtWZaRgY5uPwV7RpEgHs7cvd\ +xprv9s21ZrQH143K38iQ9Y5p6qoB8C75TE71NfpyQPdfGvzghDt39DHPFpovvtWZaRgY5uPwV7RpEgHs7cvd gfiSjLjjbuGKGcjRyU7RGGSS8Xa $ cat m | sx hd-pub 0 # generate the M/0 extended public key -xpub67xpozcx8pe95XVuZLHXZeG6XWXHpGq6Qv5cmNfi7cS5mtjJ2tgypeQbBs2UAR6KECeeMVKZBPLrtJun\ +xpub67xpozcx8pe95XVuZLHXZeG6XWXHpGq6Qv5cmNfi7cS5mtjJ2tgypeQbBs2UAR6KECeeMVKZBPLrtJun SDMstweyLXhRgPxdp14sk9tJPW9 $ cat m | sx hd-priv 0 # generate the m/0 extended private key -xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6\ +xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6 GoNMKUga5biW6Hx4tws2six3b9c $ cat m | sx hd-priv 0 | sx hd-to-wif # show the private key of m/0 as a WIF L1pbvV86crAGoDzqmgY85xURkz3c435Z9nirMt52UbnGjYMzKBUN $ cat m | sx hd-pub 0 | sx hd-to-address # show the bitcoin address of M/0 1CHCnCjgMNb6digimckNQ6TBVcTWBAmPHK $ cat m | sx hd-priv 0 | sx hd-priv 12 --hard | sx hd-priv 4 # generate m/0/12'/4 -xprv9yL8ndfdPVeDWJenF18oiHguRUj8jHmVrqqD97YQHeTcR3LCeh53q5PXPkLsy2kRaqgwoS6YZBLatRZR\ +xprv9yL8ndfdPVeDWJenF18oiHguRUj8jHmVrqqD97YQHeTcR3LCeh53q5PXPkLsy2kRaqgwoS6YZBLatRZR yUeAkRPe1kLR1P6Mn7jUrXFquUt ---- ==== diff --git a/ch05.asciidoc b/ch05.asciidoc index b6b05ff4..a27cf8bf 100644 --- a/ch05.asciidoc +++ b/ch05.asciidoc @@ -175,9 +175,9 @@ If we run the _select-utxo.py_ script without a parameter, it will attempt to co ---- $ python select-utxo.py 50000000 For transaction amount 50000000 Satoshis (0.500000 bitcoin) use: -([<7dbc497969c7475e45d952c4a872e213fb15d45e5cd3473c386a71a1b0c136a1:0 with 25000000 Satoshis>, \ - <7f42eda67921ee92eae5f79bd37c68c9cb859b899ce70dba68c48338857b7818:0 with 16100000 Satoshis>, \ - <6596fd070679de96e405d52b51b8e1d644029108ec4cbfe451454486796a1ecf:0 with 16050000 Satoshis>],\ +([<7dbc497969c7475e45d952c4a872e213fb15d45e5cd3473c386a71a1b0c136a1:0 with 25000000 Satoshis>, + <7f42eda67921ee92eae5f79bd37c68c9cb859b899ce70dba68c48338857b7818:0 with 16100000 Satoshis>, + <6596fd070679de96e405d52b51b8e1d644029108ec4cbfe451454486796a1ecf:0 with 16050000 Satoshis>], 'Change: 7150000 Satoshis') ---- ==== @@ -373,7 +373,7 @@ The preceding locking script can be satisfied with an unlocking script of the fo The two scripts together would form the following combined validation script: ---- - OP_DUP OP_HASH160 \ + OP_DUP OP_HASH160 OP_EQUAL OP_CHECKSIG ---- @@ -441,7 +441,7 @@ or any combination of two signatures from the private keys corresponding to the The two scripts together would form the combined validation script: ---- -OP_0 \ +OP_0 2 3 OP_CHECKMULTISIG ---- @@ -478,7 +478,7 @@ In <> we introduced Mohammed, an electronics importe The resulting script is quite long and looks like this: ---- -2 \ +2 5 OP_CHECKMULTISIG ---- @@ -509,24 +509,24 @@ Let's look at Mohammed's company, the complex multi-signature script, and the re First, the multi-signature script that Mohammed's company uses for all incoming payments from customers: ---- -2 \ +2 5 OP_CHECKMULTISIG ---- If the placeholders are replaced by actual public keys (shown here as 520-bit numbers starting with 04) you can see that this script becomes very long: ---- 2 -04C16B8698A9ABF84250A7C3EA7EEDEF9897D1C8C6ADF47F06CF73370\ -D74DCCA01CDCA79DCC5C395D7EEC6984D83F1F50C900A24DD47F569FD\ -4193AF5DE762C58704A2192968D8655D6A935BEAF2CA23E3FB87A3495\ -E7AF308EDF08DAC3C1FCBFC2C75B4B0F4D0B1B70CD2423657738C0C2B\ -1D5CE65C97D78D0E34224858008E8B49047E63248B75DB7379BE9CDA8\ -CE5751D16485F431E46117B9D0C1837C9D5737812F393DA7D4420D7E1\ -A9162F0279CFC10F1E8E8F3020DECDBC3C0DD389D99779650421D65CB\ -D7149B255382ED7F78E946580657EE6FDA162A187543A9D85BAAA93A4\ -AB3A8F044DADA618D087227440645ABE8A35DA8C5B73997AD343BE5C2\ -AFD94A5043752580AFA1ECED3C68D446BCAB69AC0BA7DF50D56231BE0\ -AABF1FDEEC78A6A45E394BA29A1EDF518C022DD618DA774D207D137AA\ +04C16B8698A9ABF84250A7C3EA7EEDEF9897D1C8C6ADF47F06CF73370 +D74DCCA01CDCA79DCC5C395D7EEC6984D83F1F50C900A24DD47F569FD +4193AF5DE762C58704A2192968D8655D6A935BEAF2CA23E3FB87A3495 +E7AF308EDF08DAC3C1FCBFC2C75B4B0F4D0B1B70CD2423657738C0C2B +1D5CE65C97D78D0E34224858008E8B49047E63248B75DB7379BE9CDA8 +CE5751D16485F431E46117B9D0C1837C9D5737812F393DA7D4420D7E1 +A9162F0279CFC10F1E8E8F3020DECDBC3C0DD389D99779650421D65CB +D7149B255382ED7F78E946580657EE6FDA162A187543A9D85BAAA93A4 +AB3A8F044DADA618D087227440645ABE8A35DA8C5B73997AD343BE5C2 +AFD94A5043752580AFA1ECED3C68D446BCAB69AC0BA7DF50D56231BE0 +AABF1FDEEC78A6A45E394BA29A1EDF518C022DD618DA774D207D137AA B59E0B000EB7ED238F4D800 5 OP_CHECKMULTISIG ---- diff --git a/ch08.asciidoc b/ch08.asciidoc index 3aa3bf8f..a8497524 100644 --- a/ch08.asciidoc +++ b/ch08.asciidoc @@ -208,7 +208,7 @@ $ bitcoin-cli getblock 0000000000000001b6b9a13b095e96db41c4a928b97ef2d944a9b31b2 ==== [source, bash] ---- -$ bitcoin-cli getrawtransaction\ +$ bitcoin-cli getrawtransaction d5ada064c6417ca25c4308bd158c34b77e1c0eca2a73cda16c737e7424afba2f 1 ---- ==== @@ -219,8 +219,8 @@ $ bitcoin-cli getrawtransaction\ [source,json] ---- { - "hex" : "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff\ - 0f03443b0403858402062f503253482fffffffff0110c08d9500000000232102aa970c592640d19de03ff6f329d\ + "hex" : "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff + 0f03443b0403858402062f503253482fffffffff0110c08d9500000000232102aa970c592640d19de03ff6f329d 6fd2eecb023263b9ba5d1b81c29b523da8b21ac00000000", "txid" : "d5ada064c6417ca25c4308bd158c34b77e1c0eca2a73cda16c737e7424afba2f", "version" : 1, @@ -236,7 +236,7 @@ $ bitcoin-cli getrawtransaction\ "value" : 25.09094928, "n" : 0, "scriptPubKey" : { - "asm" : "02aa970c592640d19de03ff6f329d6fd2eecb023263b9ba5d1b81c29b523da8b21\ + "asm" : "02aa970c592640d19de03ff6f329d6fd2eecb023263b9ba5d1b81c29b523da8b21 OP_CHECKSIG", "hex" : "2102aa970c592640d19de03ff6f329d6fd2eecb023263b9ba5d1b81c29b523da8b21ac", "reqSigs" : 1, diff --git a/glossary.asciidoc b/glossary.asciidoc new file mode 100644 index 00000000..eacf1970 --- /dev/null +++ b/glossary.asciidoc @@ -0,0 +1,61 @@ +[preface] +=== Quick Glossary + +This quick glossary contains many of the terms used in relation to bitcoin. These terms are used throughout the book, so bookmark this for a quick reference. + +address:: + A bitcoin address looks like +1DSrfJdB2AnWaFNgSbv3MZC2m74996JafV+. It consists of a string of letters and numbers starting with a "1" (number one). Just like you ask others to send an email to your email address, you would ask others to send you bitcoin to your bitcoin address.((("bitcoin address")))((("address", see="bitcoin address")))((("public key", see="bitcoin address"))) + +bip:: + Bitcoin Improvement Proposals. A set of proposals that members of the bitcoin community have submitted to improve bitcoin. For example, BIP0021 is a proposal to improve the bitcoin uniform resource identifier (URI) scheme.((("bip"))) + +bitcoin:: + The name of the currency unit (the coin), the network, and the software.((("bitcoin"))) + +block:: + A grouping of transactions, marked with a timestamp, and a fingerprint of the previous block. The block header is hashed to produce a proof of work, thereby validating the transactions. Valid blocks are added to the main block chain by network consensus.((("block"))) + +block chain:: + A list of validated blocks, each linking to its predecessor all the way to the genesis block.((("block chain"))) + +confirmations:: + Once a transaction is included in a block, it has one confirmation. As soon as _another_ block is mined on the same block chain, the transaction has two confirmations, and so on. Six or more confirmations is considered sufficient proof that a transaction cannot be reversed.((("confirmations"))) + +difficulty:: + A network-wide setting that controls how much computation is required to produce a proof of work.((("difficulty"))) + +difficulty target:: + A difficulty at which all the computation in the network will find blocks approximately every 10 minutes.((("target difficulty"))) + +difficulty retargeting:: + A network-wide recalculation of the difficulty that occurs once every 2,106 blocks and considers the hashing power of the previous 2,106 blocks.((("difficulty retargeting"))) + +fees:: + The sender of a transaction often includes a fee to the network for processing the requested transaction. Most transactions require a minimum fee of 0.5 mBTC.((("fees"))) + +hash:: + A digital fingerprint of some binary input.((("hash"))) + +genesis block:: + The first block in the block chain, used to initialize the cryptocurrency.((("genesis block"))) + +miner:: +A network node that finds valid proof of work for new blocks, by repeated hashing.((("miner"))) + +network:: +A peer-to-peer network that propagates transactions and blocks to every bitcoin node on the network.((("network"))) + +Proof-Of-Work:: + A piece of data that requires significant computation to find. In bitcoin, miners must find a numeric solution to the SHA256 algorithm that meets a network-wide target, the difficulty target. ((("proof-of-work"))) + +reward:: +An amount included in each new block as a reward by the network to the miner who found the Proof-Of-Work solution. It is currently 25BTC per block.((("reward"))) + +secret key (aka private key):: + The secret number that unlocks bitcoins sent to the corresponding address. A secret key looks like +5J76sF8L5jTtzE96r66Sf8cka9y44wdpJjMwCxR3tzLh3ibVPxh+.((("secret key")))((("private key", see="secret key"))) + +transaction:: +In simple terms, a transfer of bitcoins from one address to another. More precisely, a transaction is a signed data structure expressing a transfer of value. Transactions are transmitted over the bitcoin network, collected by miners, and included into blocks, made permanent on the blockchain.((("transaction"))) + +wallet:: +Software that holds all your bitcoin addresses and secret keys. Use it to send, receive, and store your bitcoin.((("wallet"))) \ No newline at end of file diff --git a/preface.asciidoc b/preface.asciidoc index ee8f232a..7a1a086b 100644 --- a/preface.asciidoc +++ b/preface.asciidoc @@ -3,19 +3,19 @@ === Writing the Bitcoin Book -I first stumbled upon bitcoin in mid-2011. My immediate reaction was more or less "Pfft! Nerd money!" and I ignored it for another six months, failing to grasp its importance. This is a reaction that I have seen repeated among many of the smartest people I know, which gives me some consolation. The second time I came across bitcoin in a mailing list discussion, I decided to read the white paper written by Satoshi Nakamoto, to study the authoritative source and see what it was all about. I still remember the moment I finished reading those nine pages, when I realized that bitcoin was not simply a digital currency, but a network of trust that could also provide the basis for so much more than just currencies. The realization that "this isn't money, it's a decentralized trust network," started me on a four-month journey to devour every scrap of information about bitcoin I could find. I became obsessed and enthralled, spending twelve or more hours each day glued to a screen, reading, writing, coding, and learning as much as I could. I emerged from this state of fugue, more than 20 lbs lighter from lack of consistent meals, determined to dedicate myself to working on bitcoin. +I first stumbled upon bitcoin in mid-2011. My immediate reaction was more or less "Pfft! Nerd money!" and I ignored it for another six months, failing to grasp its importance. This is a reaction that I have seen repeated among many of the smartest people I know, which gives me some consolation. The second time I came across bitcoin, in a mailing list discussion, I decided to read the white paper written by Satoshi Nakamoto, to study the authoritative source and see what it was all about. I still remember the moment I finished reading those nine pages, when I realized that bitcoin was not simply a digital currency, but a network of trust that could also provide the basis for so much more than just currencies. The realization that "this isn't money, it's a decentralized trust network," started me on a four-month journey to devour every scrap of information about bitcoin I could find. I became obsessed and enthralled, spending 12 or more hours each day glued to a screen, reading, writing, coding, and learning as much as I could. I emerged from this state of fugue, more than 20 pounds lighter from lack of consistent meals, determined to dedicate myself to working on bitcoin. -Two years later, after creating a number of small startups to explore various bitcoin-related services and products, I decided that it was time to write my first book. Bitcoin was the topic that had driven me into a frenzy of creativity, consumed my thoughts, and was the most exciting technology I had encountered since the Internet. It was now time to share my passion about this amazing technology with a broader audience. +Two years later, after creating a number of small startups to explore various bitcoin-related services and products, I decided that it was time to write my first book. Bitcoin was the topic that had driven me into a frenzy of creativity and consumed my thoughts; it was the most exciting technology I had encountered since the Internet. It was now time to share my passion about this amazing technology with a broader audience. === Intended Audience -This book is mostly intended for coders. If you can use a programming language, this book will teach you how cryptographic currencies work, how to use them, and how to develop software that works with them. The first few chapters are also suitable as an in-depth introduction to bitcoin for noncoders—those trying to understand the inner workings of bitcoin and crypto-currencies. +This book is mostly intended for coders. If you can use a programming language, this book will teach you how cryptographic currencies work, how to use them, and how to develop software that works with them. The first few chapters are also suitable as an in-depth introduction to bitcoin for noncoders—those trying to understand the inner workings of bitcoin and cryptocurrencies. === Why Are There Bugs on the Cover? The leafcutter ant is a species that exhibits highly complex behavior in a colony super-organism, but each individual ant operates on a set of simple rules driven by social interaction and the exchange of chemical scents (pheromones). Per Wikipedia: "Next to humans, leafcutter ants form the largest and most complex animal societies on Earth." Leafcutter ants don't actually eat leaves, but rather use them to farm a fungus, which is the central food source for the colony. Get that? These ants are farming! -Although ants form a caste-based society and have a queen for producing offspring, there is no central authority or leader in an ant colony. The highly intelligent and sophisticated behavior exhibited by a multimillion member colony is an emergent property from the interaction of the individuals in a social network. +Although ants form a caste-based society and have a queen for producing offspring, there is no central authority or leader in an ant colony. The highly intelligent and sophisticated behavior exhibited by a multimillion-member colony is an emergent property from the interaction of the individuals in a social network. Nature demonstrates that decentralized systems can be resilient and can produce emergent complexity and incredible sophistication without the need for a central authority, hierarchy, or complex parts. @@ -46,13 +46,13 @@ This icon indicates a warning or caution. === Code Examples -The examples are illustrated in Python, C++, and using the command-line of a Unix-like operating system such as Linux or Mac OS X. All code snippets are available in the https://github.com/aantonop/bitcoinbook[GitHub repository] in the _code_ subdirectory of the main repo. Fork the book code, try the code examples, or submit corrections via GitHub. +The examples are illustrated in Python, C++, and using the command line of a Unix-like operating system such as Linux or Mac OS X. All code snippets are available in the https://github.com/aantonop/bitcoinbook[GitHub repository] in the _code_ subdirectory of the main repo. Fork the book code, try the code examples, or submit corrections via GitHub. All the code snippets can be replicated on most operating systems with a minimal installation of compilers and interpreters for the corresponding languages. Where necessary, we provide basic installation instructions and step-by-step examples of the output of those instructions. Some of the code snippets and code output have been reformatted for print. In all such cases, the lines have been split by a backslash (\) character, followed by a newline character. When transcribing the examples, remove those two characters and join the lines again and you should see identical results as shown in the example. -All the code snippets use real values and calculations where possible, so that you can build from example to example and see the same results in any code you write to calculate the same values. For example, the private keys and corresponding public keys and addresses are all real. The sample transactions, blocks, and blockchain references have all been introduced in the actual bitcoin blockchain and are part of the public ledger, so you can review them on any bitcoin system. +All the code snippets use real values and calculations where possible, so that you can build from example to example and see the same results in any code you write to calculate the same values. For example, the private keys and corresponding public keys and addresses are all real. The sample transactions, blocks, and block chain references have all been introduced in the actual bitcoin block chain and are part of the public ledger, so you can review them on any bitcoin system. === Using Code Examples @@ -60,7 +60,7 @@ This book is here to help you get your job done. In general, if example code is We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “_Mastering Bitcoin_ by Andreas M. Antonopoulos (O’Reilly). Copyright 2015 Andreas M. Antonopoulos, 978-1-449-37404-4.” -Some editions of this books 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:[permissions@oreilly.com]. @@ -111,23 +111,23 @@ Watch us on YouTube: link:$$http://www.youtube.com/oreillymedia$$[] === Acknowledgments -This book represents the efforts and contributions of many people. I am grateful for all the help I received from friends, colleagues, and even complete strangers, who joined me in this effort to write the definitive technical book on crypto-currencies and bitcoin. +This book represents the efforts and contributions of many people. I am grateful for all the help I received from friends, colleagues, and even complete strangers, who joined me in this effort to write the definitive technical book on cryptocurrencies and bitcoin. -It is impossible to make a distinction between the bitcoin technology and the bitcoin community, and this book is as much a product of that community as it is a book on the technology. My work on this book was encouraged, cheered on, supported, and rewarded by the entire bitcoin community from the very beginning until the very end. More than anything, this book has allowed me to be part of a wonderful community for two years and I can't thank you enough for accepting me in this community. There are far too many people to mention by name—people I've met at conferences, events, seminars, meetups, pizza gatherings, and small private gatherings, as well as many who communicated with me by Twitter, on reddit, on bitcointalk.org, and on GitHub who have had an impact on this book. Every idea, analogy, question, answer, and explanation you find in this book was at some point inspired, tested, or improved through my interactions with the community. Thank you all for your support; without you this book would not have happened. I am forever grateful. +It is impossible to make a distinction between the bitcoin technology and the bitcoin community, and this book is as much a product of that community as it is a book on the technology. My work on this book was encouraged, cheered on, supported, and rewarded by the entire bitcoin community from the very beginning until the very end. More than anything, this book has allowed me to be part of a wonderful community for two years and I can't thank you enough for accepting me into this community. There are far too many people to mention by name—people I've met at conferences, events, seminars, meetups, pizza gatherings, and small private gatherings, as well as many who communicated with me by Twitter, on reddit, on bitcointalk.org, and on GitHub who have had an impact on this book. Every idea, analogy, question, answer, and explanation you find in this book was at some point inspired, tested, or improved through my interactions with the community. Thank you all for your support; without you this book would not have happened. I am forever grateful. -The journey to becoming an author starts long before the first book, of course. My first language (and schooling) was Greek, so I had to take a remedial English Writing course in my first year of university. I owe thanks to Diana Kordas, my English Writing teacher, who helped me build confidence and skills that year. Later, as a professional, I developed my technical writing skills on the topic of data centers, writing for _Network World_ magazine. I owe thanks to John Dix and John Gallant who gave me my first writing job as a columnist at _Network World_ and to my editor Michael Cooney and my colleague Johna Till Johnson who edited my columns and made them fit for publication. Writing 500 words a week for four years gave me enough experience to eventually consider becoming an author. Thanks to Jean de Vera for her early encouragement to become an author and for always believing and insisting that I had a book in me. +The journey to becoming an author starts long before the first book, of course. My first language (and schooling) was Greek, so I had to take a remedial English writing course in my first year of university. I owe thanks to Diana Kordas, my English writing teacher, who helped me build confidence and skills that year. Later, as a professional, I developed my technical writing skills on the topic of data centers, writing for _Network World_ magazine. I owe thanks to John Dix and John Gallant, who gave me my first writing job as a columnist at _Network World_ and to my editor Michael Cooney and my colleague Johna Till Johnson who edited my columns and made them fit for publication. Writing 500 words a week for four years gave me enough experience to eventually consider becoming an author. Thanks to Jean de Vera for her early encouragement to become an author and for always believing and insisting that I had a book in me. -Thanks also to those who supported me when I submitted my book proposal to O'Reilly, by providing references and reviewing the proposal. Specifically, thanks to John Gallant, Gregory Ness, Richard Stiennon, Joel Snyder, Adam B. Levine, Sandra Gittlen, John Dix, Johna Till Johnson, Roger Ver, and Jon Matonis. Special thanks to Richard Kagan and Tymon Mattoszko who reviewed early versions of the proposal and Matthew Owain Taylor who copyedited the proposal. +Thanks also to those who supported me when I submitted my book proposal to O'Reilly, by providing references and reviewing the proposal. Specifically, thanks to John Gallant, Gregory Ness, Richard Stiennon, Joel Snyder, Adam B. Levine, Sandra Gittlen, John Dix, Johna Till Johnson, Roger Ver, and Jon Matonis. Special thanks to Richard Kagan and Tymon Mattoszko, who reviewed early versions of the proposal and Matthew Owain Taylor, who copyedited the proposal. -Thanks to Cricket Liu, author of the O'Reilly title _DNS and BIND_, who introduced me to O'Reilly. Thanks also to Michael Loukides and Allyson MacDonald at O'Reilly who worked for months to help make this book happen. Allyson was especially patient when deadlines were missed and deliverables delayed as life intervened in our planned schedule. +Thanks to Cricket Liu, author of the O'Reilly title _DNS and BIND_, who introduced me to O'Reilly. Thanks also to Michael Loukides and Allyson MacDonald at O'Reilly, who worked for months to help make this book happen. Allyson was especially patient when deadlines were missed and deliverables delayed as life intervened in our planned schedule. -The first few drafts of the first few chapters were the hardest, because bitcoin is a difficult subject to unravel. Every time I pulled on one thread of the bitcoin technology, I had to pull in the whole thing. I repeatedly got stuck and a bit despondent as I struggled to make the topic easy to understand and create a narrative around such a dense technical subject. Eventually, I decided to tell the story of bitcoin through the stories of the people using bitcoin and the whole book became a lot easier to write. I owe thanks to my friend and mentor, Richard Kagan, who helped me unravel the story and get past the moments of writer's block, and Pamela Morgan who reviewed early drafts of each chapter and asked the hard questions to make them better. Also, thanks to the developers of the San Francisco Bitcoin Developers Meetup group and Taariq Lewis, the group's co-founder, for helping to test the early material. +The first few drafts of the first few chapters were the hardest, because bitcoin is a difficult subject to unravel. Every time I pulled on one thread of the bitcoin technology, I had to pull in the whole thing. I repeatedly got stuck and a bit despondent as I struggled to make the topic easy to understand and create a narrative around such a dense technical subject. Eventually, I decided to tell the story of bitcoin through the stories of the people using bitcoin and the whole book became a lot easier to write. I owe thanks to my friend and mentor, Richard Kagan, who helped me unravel the story and get past the moments of writer's block, and Pamela Morgan, who reviewed early drafts of each chapter and asked the hard questions to make them better. Also, thanks to the developers of the San Francisco Bitcoin Developers Meetup group and Taariq Lewis, the group's co-founder, for helping to test the early material. -During the development of the book, I made early drafts available on GitHub and invited public comments. More than a hundred comments, suggestions, corrections, and contributions were submitted in response. Those contributions are explicitly acknowledged, with my thanks, in <>. Special thanks to Minh T. Nguyen who volunteered to manage the GitHub contributions and added many significant contributions himself. Thanks also to Andrew Naugler for infographic design. +During the development of the book, I made early drafts available on GitHub and invited public comments. More than a hundred comments, suggestions, corrections, and contributions were submitted in response. Those contributions are explicitly acknowledged, with my thanks, in <>. Special thanks to Minh T. Nguyen, who volunteered to manage the GitHub contributions and added many significant contributions himself. Thanks also to Andrew Naugler for infographic design. Once the book was drafted, it went through several rounds of technical review. Thanks to Cricket Liu and Lorne Lantz for their thorough review, comments, and support. -Several bitcoin developers contributed code samples, reviews, comments, and encouragement. Thanks to Amir Taaki for example code snippets and many great comments, Vitalik Buterin and Richard Kiss for help with elliptic curve math and code contributions, Gavin Andresen for corrections, comments, and encouragement, and Michalis Kargakis for comments, contributions, and btcd writeup. +Several bitcoin developers contributed code samples, reviews, comments, and encouragement. Thanks to Amir Taaki for example code snippets and many great comments; Vitalik Buterin and Richard Kiss for help with elliptic curve math and code contributions; Gavin Andresen for corrections, comments, and encouragement; and Michalis Kargakis for comments, contributions, and btcd writeup. I owe my love of words and books to my mother, Theresa, who raised me in a house with books lining every wall. My mother also bought me my first computer in 1982, despite being a self-described technophobe. My father, Menelaos, a civil engineer who just published his first book at 80 years old, was the one who taught me logical and analytical thinking and a love of science and engineering. @@ -136,112 +136,27 @@ Thank you all for supporting me throughout this journey. [[github_contrib]] ==== Early Release Draft (GitHub Contributions) -Many contributors offered comments, corrections, and additions to the early-release draft on GitHub. Thank you all for your contributions to this book. Notable contributors included the following: +Many contributors offered comments, corrections, and additions to the early-release draft on GitHub. Thank you all for your contributions to this book. Following is a list of notable GitHub contributors, including their GitHub ID in parentheses: -===== Name: GitHub ID - -* *Minh T. Nguyen, GitHub contribution editor: enderminh* -* Ed Eykholt: edeykholt -* Michalis Kargakis: kargakis -* Erik Wahlström: erikwam -* Richard Kiss: richardkiss -* Eric Winchell: winchell -* Sergej Kotliar: ziggamon -* Nagaraj Hubli: nagarajhubli +* Minh T. Nguyen, GitHub contribution editor (enderminh) +* Ed Eykholt (edeykholt) +* Michalis Kargakis (kargakis) +* Erik Wahlström (erikwam) +* Richard Kiss (richardkiss) +* Eric Winchell (winchell) +* Sergej Kotliar (ziggamon) +* Nagaraj Hubli (nagarajhubli) * ethers -* Alex Waters: alexwaters -* Mihail Russu: MihailRussu -* Ish Ot Jr.: ishotjr -* James Addison: jayaddison -* Nekomata: nekomata-3 -* Simon de la Rouviere: simondlr -* Chapman Shoop: belovachap -* Holger Schinzel: schinzelh -* effectsToCause: vericoin -* Stephan Oeste: Emzy -* Joe Bauers: joebauers -* Jason Bisterfeldt: jbisterfeldt -* Ed Leafe: EdLeafe - -=== Quick Glossary - -This quick glossary contains many of the terms used in relation to bitcoin. These terms are used throughout the book, so bookmark this for a quick reference and clarification. - -address:: -((("bitcoin address"))) -((("address", see="bitcoin address"))) -((("public key", see="bitcoin address"))) - A bitcoin address looks like +1DSrfJdB2AnWaFNgSbv3MZC2m74996JafV+. It consists of a string of letters and numbers starting with a "1" (number one). Just like you ask others to send an email to your email address, you would ask others to send you bitcoin to your bitcoin address. - -bip:: -((("bip"))) - Bitcoin Improvement Proposals. A set of proposals that members of the bitcoin community have submitted to improve bitcoin. For example, BIP0021 is a proposal to improve the bitcoin URI scheme. - -bitcoin:: -((("bitcoin"))) - The name of the currency unit (the coin), the network, and the software. - -block:: -((("block"))) - A grouping of transactions, marked with a timestamp, and a fingerprint of the previous block. The block header is hashed to find a Proof-Of-Work, thereby validating the transactions. Valid blocks are added to the main blockchain by network consensus. - -blockchain:: -((("blockchain"))) - A list of validated blocks, each linking to its predecessor all the way to the genesis block. - -confirmations:: -((("confirmations"))) - Once a transaction is included in a block, it has "one confirmation." As soon as _another_ block is mined on the same blockchain, the transaction has two confirmations, etc. Six or more confirmations is considered sufficient proof that a transaction cannot be reversed. - -difficulty:: -((("difficulty"))) - A network-wide setting that controls how much computation is required to find a Proof-Of-Work. - -difficulty target:: -((("target difficulty"))) - A difficulty at which all the computation in the network will find blocks approximately every 10 minutes. - -difficulty re-targeting:: -((("difficulty re-targeting"))) - A network-wide recalculation of the difficulty that occurs once every 2,106 blocks and considers the hashing power of the previous 2,106 blocks. - -fees:: -((("fees"))) - The sender of a transaction often includes a fee to the network for processing the requested transaction. Most transactions require a minimum fee of 0.5mBTC. - -hash:: -((("hash"))) - A digital fingerprint of some binary input. - -genesis block:: -((("genesis block"))) - The first block in the blockchain, used to initialize the crypto-currency. - -miner:: -((("miner"))) - A network node that finds valid Proof-Of-Work for new blocks, by repeated hashing. - -network:: -((("network"))) - A peer-to-peer network that propagates transactions and blocks to every bitcoin node on the network. - -Proof-Of-Work:: -((("proof-of-work"))) - A piece of data that requires significant computation to find. In bitcoin, miners must find a numeric solution to the SHA256 algorithm that meets a network-wide target, the difficulty target. - -reward:: -((("reward"))) - An amount included in each new block as a reward by the network to the miner who found the Proof-Of-Work solution. It is currently 25BTC per block. - -secret key (aka private key):: -((("secret key"))) -((("private key", see="secret key"))) - The secret number that unlocks bitcoins sent to the corresponding address. A secret key looks like +5J76sF8L5jTtzE96r66Sf8cka9y44wdpJjMwCxR3tzLh3ibVPxh+. - -transaction:: -((("transaction"))) - In simple terms, a transfer of bitcoins from one address to another. More precisely, a transaction is a signed data structure expressing a transfer of value. Transactions are transmitted over the bitcoin network, collected by miners, and included into blocks, made permanent on the blockchain. - -wallet:: -((("wallet"))) - Software that holds all your bitcoin addresses and secret keys. Use it to send, receive, and store your bitcoin. \ No newline at end of file +* Alex Waters (alexwaters) +* Mihail Russu (MihailRussu) +* Ish Ot Jr. (ishotjr) +* James Addison (jayaddison) +* Nekomata (nekomata-3) +* Simon de la Rouviere (simondlr) +* Chapman Shoop (belovachap) +* Holger Schinzel (schinzelh) +* effectsToCause (vericoin) +* Stephan Oeste (Emzy) +* Joe Bauers (joebauers) +* Jason Bisterfeldt (jbisterfeldt) +* Ed Leafe (EdLeafe) \ No newline at end of file diff --git a/pycoin.asciidoc b/pycoin.asciidoc index 7f8bf3c6..24db91dd 100644 --- a/pycoin.asciidoc +++ b/pycoin.asciidoc @@ -42,9 +42,9 @@ Create a BIP32 Key using the default entropy sources of GPG and /dev/random: input : create network : Bitcoin - wallet key : xprv9s21ZrQH143K3LU5ctPZTBnb9kTjA5Su9DcWHvXJemiJBsY7VqXUG7hipgdWaU\ + wallet key : xprv9s21ZrQH143K3LU5ctPZTBnb9kTjA5Su9DcWHvXJemiJBsY7VqXUG7hipgdWaU m2nhnzdvxJf5KJo9vjP2nABX65c5sFsWsV8oXcbpehtJi - public version : xpub661MyMwAqRbcFpYYiuvZpKjKhnJDZYAkWSY76JvvD7FH4fsG3Nqiov2CfxzxY8\ + public version : xpub661MyMwAqRbcFpYYiuvZpKjKhnJDZYAkWSY76JvvD7FH4fsG3Nqiov2CfxzxY8 DGcpfT56AMFeo8M8KPkFMfLUtvwjwb6WPv8rY65L2q8Hz tree depth : 0 fingerprint : 9d9c6092 @@ -62,7 +62,7 @@ Create a BIP32 Key using the default entropy sources of GPG and /dev/random: y as hex : 843a0f6ed9c0eb1962c74533795406914fe3f1957c5238951f4fe245a4fcd625 y parity : odd key pair as sec : 03a90b3008792432060fa04365941e09a8e4adf928bdbdb9dad41131274e379322 - uncompressed : 04a90b3008792432060fa04365941e09a8e4adf928bdbdb9dad41131274e379322\ + uncompressed : 04a90b3008792432060fa04365941e09a8e4adf928bdbdb9dad41131274e379322 843a0f6ed9c0eb1962c74533795406914fe3f1957c5238951f4fe245a4fcd625 hash160 : 9d9c609247174ae323acfc96c852753fe3c8819d uncompressed : 8870d869800c9b91ce1eb460f4c60540f87c15d7 @@ -78,9 +78,9 @@ Create a BIP32 key from a passphrase: input : P:foo network : Bitcoin - wallet key : xprv9s21ZrQH143K31AgNK5pyVvW23gHnkBq2wh5aEk6g1s496M8ZMjxncCKZKgb5j\ + wallet key : xprv9s21ZrQH143K31AgNK5pyVvW23gHnkBq2wh5aEk6g1s496M8ZMjxncCKZKgb5j ZoY5eSJMJ2Vbyvi2hbmQnCuHBujZ2WXGTux1X2k9Krdtq - public version : xpub661MyMwAqRbcFVF9ULcqLdsEa5WnCCugQAcgNd9iEMQ31tgH6u4DLQWoQayvtS\ + public version : xpub661MyMwAqRbcFVF9ULcqLdsEa5WnCCugQAcgNd9iEMQ31tgH6u4DLQWoQayvtS VYFvXz2vPPpbXE1qpjoUFidhjFj82pVShWu9curWmb2zy tree depth : 0 fingerprint : 5d353a2e @@ -98,7 +98,7 @@ Create a BIP32 key from a passphrase: y as hex : 826d8b4d3010aea16ff4c1c1d3ae68541d9a04df54a2c48cc241c2983544de52 y parity : even key pair as sec : 02b4e599dfa44555a4ed38bcfff0071d5af676a86abf123c5b4b4e8e67a0b0b13f - uncompressed : 04b4e599dfa44555a4ed38bcfff0071d5af676a86abf123c5b4b4e8e67a0b0b13f\ + uncompressed : 04b4e599dfa44555a4ed38bcfff0071d5af676a86abf123c5b4b4e8e67a0b0b13f 826d8b4d3010aea16ff4c1c1d3ae68541d9a04df54a2c48cc241c2983544de52 hash160 : 5d353a2ecdb262477172852d57a3f11de0c19286 uncompressed : e5bd3a7e6cb62b4c820e51200fb1c148d79e67da @@ -211,7 +211,7 @@ From secret exponent: y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 y parity : even key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 - uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ + uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 @@ -234,7 +234,7 @@ Litecoin version: y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 y parity : even key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 - uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ + uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 @@ -250,7 +250,7 @@ From public pair (on Testnet): $ ku -nT 55066263022277343669578718895168534326250603453777594175500187360389116729240,even - input : 550662630222773436695787188951685343262506034537775941755001873603\ + input : 550662630222773436695787188951685343262506034537775941755001873603 89116729240,even network : Bitcoin testnet public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240 @@ -259,7 +259,7 @@ From public pair (on Testnet): y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 y parity : even key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 - uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ + uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 @@ -581,7 +581,7 @@ Compare to using ku: y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 y parity : even key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 - uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ + uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5