mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2025-01-22 13:40:58 +00:00
example code line wrap fixes
This commit is contained in:
parent
b0de0878e9
commit
a9141d48fb
@ -638,7 +638,7 @@ $ bitcoin-cli decoderawtransaction 0100000001d717...388ac00000000
|
||||
|
||||
|
||||
++++
|
||||
<screen language="json">
|
||||
<screen>
|
||||
{
|
||||
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae3",
|
||||
"version" : 1,
|
||||
@ -648,7 +648,8 @@ $ bitcoin-cli decoderawtransaction 0100000001d717...388ac00000000
|
||||
"txid" : "d3c7e022ea80c4808e64dd0a1dba009f3eaee2318a4ece562f8ef815<?pdf-cr?>952717d7",
|
||||
"vout" : 0,
|
||||
"scriptSig" : {
|
||||
"asm" : "3045022100a4ebbeec83225dedead659bbde7da3d026c8b8e12e<?pdf-cr?>61a2df0dd0758e227383b302203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9b2<?pdf-cr?>ac1bd193dfba20104793ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede65e4c4b<?pdf-cr?>884ac5b5b6dede05ba84727e34c8fd3ee1d6929d7a44b6e111d41cc79e05dbfe5cea","hex" :<?pdf-cr?>"483045022100a4ebbeec83225dedead659bbde7da3d026c8b8e12e61a2df0dd0758e227383b3<?pdf-cr?>02203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9b2ac1bd193dfba2014104793<?pdf-cr?>ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede65e4c4b884ac5b5b6dede05ba84<?pdf-cr?>727e34c8fd3ee1d6929d7a44b6e111d41cc79e05dbfe5cea"
|
||||
"asm" : "3045022100a4ebbeec83225dedead659bbde7da3d026c8b8e12e<?pdf-cr?>61a2df0dd0758e227383b302203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9b2<?pdf-cr?>ac1bd193dfba20104793ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede65e4c4b<?pdf-cr?>884ac5b5b6dede05ba84727e34c8fd3ee1d6929d7a44b6e111d41cc79e05dbfe5cea",
|
||||
"hex": "483045022100a4ebbeec83225dedead659bbde7da3d026c8b8e1<?pdf-cr?>2e61a2df0dd0758e227383b302203301768ef878007e9ef7c304f70ffaf1f2c975b192d34c5b9<?pdf-cr?>b2ac1bd193dfba2014104793ac8a58ea751f9710e39aad2e296cc14daa44fa59248be58ede65e<?pdf-cr?>4c4b884ac5b5b6dede05ba84727e34c8fd3ee1d6929d7a44b6e111d41cc79e05dbfe5cea"
|
||||
},
|
||||
"sequence" : 4294967295
|
||||
}
|
||||
@ -700,7 +701,7 @@ $ bitcoin-cli gettransaction 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66<?p
|
||||
|
||||
|
||||
++++
|
||||
<screen language="json">
|
||||
<screen>
|
||||
{
|
||||
"amount" : 0.05000000,
|
||||
"confirmations" : 1,
|
||||
@ -745,7 +746,7 @@ $ bitcoin-cli getblock 000000000000000051d2e759c63a26e247f185ecb7926ed7a6624b<?p
|
||||
|
||||
|
||||
++++
|
||||
<screen language="json">
|
||||
<screen>
|
||||
{
|
||||
"hash" : "000000000000000051d2e759c63a26e247f185ecb7926ed7a6624bc31c2a717<?pdf-cr?>b",
|
||||
"confirmations" : 2,
|
||||
@ -810,7 +811,7 @@ $ bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1<?p
|
||||
|
||||
|
||||
++++
|
||||
<screen language="json">
|
||||
<screen>
|
||||
{
|
||||
"hash" : "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26<?pdf-cr?>f",
|
||||
"confirmations" : 286388,
|
||||
@ -849,7 +850,7 @@ $ bitcoin-cli listunspent
|
||||
|
||||
|
||||
++++
|
||||
<screen language="json">
|
||||
<screen>
|
||||
[
|
||||
{
|
||||
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c<?pdf-cr?>14ae3",
|
||||
@ -877,7 +878,7 @@ $ bitcoin-cli gettxout 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309ac<?p
|
||||
|
||||
|
||||
++++
|
||||
<screen language="json">
|
||||
<screen>
|
||||
{
|
||||
"bestblock" : "0000000000000001405ce69bd4ceebcdfdb537749cebe89d371eb37e13<?pdf-cr?>899fd9",
|
||||
"confirmations" : 7,
|
||||
@ -911,7 +912,7 @@ 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):
|
||||
|
||||
++++
|
||||
<screen language="json">
|
||||
<screen>
|
||||
$ bitcoin-cli createrawtransaction '[{"txid" : "9ca8f969bd3ef5ec2a8685660fdbf<?pdf-cr?>7a8bd365524c2e1fc66c309acbae2c14ae3", "vout" : 0}]' '{"1LnfTndy3qzXGN19Jwscj1<?pdf-cr?>T8LR3MVe3JDb": 0.025, "1hvzSofGwT8cjb8JU7nBsCSfEVQX5u9CL": 0.0245}'
|
||||
|
||||
0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c000<?pdf-cr?>0000000ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a<?pdf-cr?>9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac0<?pdf-cr?>0000000
|
||||
@ -928,7 +929,7 @@ $ bitcoin-cli decoderawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bd<?p
|
||||
|
||||
|
||||
++++
|
||||
<screen language="json">
|
||||
<screen>
|
||||
{
|
||||
"txid" : "0793299cb26246a8d24e468ec285a9520a1c30fcb5b6125a102e3fc05d4f3cb<?pdf-cr?>a",
|
||||
"version" : 1,
|
||||
@ -962,8 +963,7 @@ $ bitcoin-cli decoderawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bd<?p
|
||||
"value" : 0.02450000,
|
||||
"n" : 1,
|
||||
"scriptPubKey" : {
|
||||
"asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c1<?pdf-cr?>3d1fd2
|
||||
OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"asm" : "OP_DUP OP_HASH160 07bdb518fa2e6089fd810235cf1100c9c1<?pdf-cr?>3d1fd2 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"hex" : "76a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac",
|
||||
"reqSigs" : 1,
|
||||
"type" : "pubkeyhash",
|
||||
@ -995,7 +995,7 @@ $ bitcoin-cli signrawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda8<?p
|
||||
|
||||
|
||||
++++
|
||||
<screen language="json">
|
||||
<screen>
|
||||
{
|
||||
"hex" : "0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53e<?pdf-cr?>bd69f9a89c000000006a47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54<?pdf-cr?>e0a1b76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4af<?pdf-cr?>52051a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71dc512<?pdf-cr?>7ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88<?pdf-cr?>ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac00000000",
|
||||
"complete" : true
|
||||
@ -1019,7 +1019,7 @@ bd68107564a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100<?p
|
||||
|
||||
|
||||
++++
|
||||
<screen language="json">
|
||||
<screen>
|
||||
{
|
||||
"txid" : "ae74538baa914f3799081ba78429d5d84f36a0127438e9f721dff584ac17b34<?pdf-cr?>6",
|
||||
"version" : 1,
|
||||
|
@ -203,9 +203,11 @@ Public Key K is defined as a point +K = (x,y)+:
|
||||
|
||||
----
|
||||
K = (x, y)
|
||||
|
||||
where,
|
||||
x = F028892BAD...DC341A
|
||||
y = 07CF33DA18...505BDB
|
||||
|
||||
x = F028892BAD7ED57D2FB57BF33081D5CFCF6F9ED3D3D7F159C2E2FFF579DC341A
|
||||
y = 07CF33DA18BD734C600B96A72BBC4749D5141C90EC8AC328AE52DDFE2E505BDB
|
||||
----
|
||||
|
||||
To visualize multiplication of a point with an integer, we will use the simpler elliptic curve over the real numbers—remember, the math is the same. Our goal is to find the multiple kG of the generator point G. That is the same as adding G to itself, k times in a row. In elliptic curves, adding a point to itself is the equivalent of drawing a tangent line on the point and finding where it intersects the curve again, then reflecting that point on the x-axis.
|
||||
@ -226,7 +228,7 @@ Most bitcoin implementations use the((("OpenSSL cryptographic library"))) http:/
|
||||
((("addresses, bitcoin", id="ix_ch04-asciidoc8", range="startofrange")))((("addresses, bitcoin","generally", id="ix_ch04-asciidoc9", range="startofrange")))A bitcoin address is a string of digits and characters that can be shared with anyone who wants to send you money. Addresses produced from public keys consist of a string of numbers and letters, beginning with the digit "1". Here's an example of a bitcoin address:
|
||||
|
||||
----
|
||||
1thMirt546nngXqyPEz532S8fLwbozud8
|
||||
1J7mdg5rbQyUHENYdx39WVWK7fsLpEoXZy
|
||||
----
|
||||
|
||||
|
||||
@ -403,14 +405,14 @@ As we saw previously, the public key is a point on the elliptic curve consisting
|
||||
Here's the public key generated by the private key we created earlier, shown as the coordinates +x+ and +y+:
|
||||
|
||||
----
|
||||
x = F028892BAD...DC341A
|
||||
y = 07CF33DA18...505BDB
|
||||
x = F028892BAD7ED57D2FB57BF33081D5CFCF6F9ED3D3D7F159C2E2FFF579DC341A
|
||||
y = 07CF33DA18BD734C600B96A72BBC4749D5141C90EC8AC328AE52DDFE2E505BDB
|
||||
----
|
||||
|
||||
Here's the same public key shown as a 520-bit number (130 hex digits) with the prefix +04+ followed by +x+ and then +y+ coordinates, as +04 x y+:
|
||||
|
||||
----
|
||||
K = 04F028892BAD...505BDB
|
||||
K = 04F028892BAD7ED57D2FB57BF33081D5CFCF6F9ED3D3D7F159C2E2FFF579DC341A<?pdf-cr?>07CF33DA18BD734C600B96A72BBC4749D5141C90EC8AC328AE52DDFE2E505BDB
|
||||
----
|
||||
|
||||
[[comp_pub]]
|
||||
@ -429,7 +431,7 @@ image::images/msbt_0407.png["pubkey_compression"]
|
||||
((("public keys","compression")))Here's the same public key generated previously, shown as a compressed public key stored in 264 bits (66 hex digits) with the prefix +03+ indicating the _y_ coordinate is odd:
|
||||
|
||||
----
|
||||
K = 03F028892BAD...DC341A
|
||||
K = 03F028892BAD7ED57D2FB57BF33081D5CFCF6F9ED3D3D7F159C2E2FFF579DC341A
|
||||
----
|
||||
|
||||
((("addresses, bitcoin","converting compressed keys to")))((("compressed keys","converting to bitcoin addresses")))This compressed public key corresponds to the same private key, meaning that it is generated from the same private key. However, it looks different from the uncompressed public key. More importantly, if we convert this compressed public key to a bitcoin address using the double-hash function (+RIPEMD160(SHA256(K))+) it will produce a _different_ bitcoin address. This can be confusing, because it means that a single private key can produce a public key expressed in two different formats (compressed and uncompressed) that produce two different bitcoin addresses. However, the private key is identical for both bitcoin addresses.
|
||||
@ -484,7 +486,6 @@ include::code/key-to-address-ecc-example.py[]
|
||||
[[key-to-address_script_run]]
|
||||
.Running key-to-address-ecc-example.py
|
||||
====
|
||||
[source,bash]
|
||||
----
|
||||
$ python key-to-address-ecc-example.py
|
||||
Private Key (hex) is:
|
||||
@ -501,8 +502,7 @@ Public Key (x,y) coordinates is:
|
||||
(41637322786646325214887832269588396900663353932545912953362782457239403430124L,
|
||||
16388935128781238405526710466724741593761085120864331449066658622400339362166L)
|
||||
Public Key (hex) is:
|
||||
045c0de3b9c8ab18dd04e3511243ec2952002dbfadc864b9628910169d9b9b00ec
|
||||
243bcefdd4347074d44bd7356d6a53c495737dd96295e2a9374bf5f02ebfc176
|
||||
045c0de3b9c8ab18dd04e3511243ec2952002dbfadc864b9628910169d9b9b00ec<?pdf-cr?>243bcefdd4347074d44bd7356d6a53c495737dd96295e2a9374bf5f02ebfc176
|
||||
Compressed Public Key (hex) is:
|
||||
025c0de3b9c8ab18dd04e3511243ec2952002dbfadc864b9628910169d9b9b00ec
|
||||
Bitcoin Address (b58check) is:
|
||||
@ -529,7 +529,6 @@ include::code/ec-math.py[]
|
||||
[[ec_math_run]]
|
||||
.Installing the Python ECDSA library and running the ec_math.py script
|
||||
====
|
||||
[source,bash]
|
||||
----
|
||||
$ # Install Python PIP package manager
|
||||
$ sudo apt-get install python-pip
|
||||
|
Loading…
Reference in New Issue
Block a user