mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2025-03-25 20:05:43 +00:00
Made changes to ch03.asciidoc
This commit is contained in:
parent
3078a9e5d7
commit
7b0444e2fc
@ -697,14 +697,15 @@ $ bitcoin-cli gettransaction 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c30
|
||||
----
|
||||
|
||||
[source,json]
|
||||
----
|
||||
++++
|
||||
<screen language="json">
|
||||
{
|
||||
"amount" : 0.05000000,
|
||||
"confirmations" : 1,
|
||||
"blockhash" : "000000000000000051d2e759c63a26e247f185ecb7926ed7a6624bc31c2a717b",
|
||||
"blockhash" : "000000000000000051d2e759c63a26e247f185ecb7926ed7a6624bc31c<?pdf-cr?>2a717b",
|
||||
"blockindex" : 18,
|
||||
"blocktime" : 1392660808,
|
||||
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae3",
|
||||
"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae<?pdf-cr?>3",
|
||||
"time" : 1392660908,
|
||||
"timereceived" : 1392660908,
|
||||
"details" : [
|
||||
@ -716,7 +717,8 @@ $ bitcoin-cli gettransaction 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c30
|
||||
}
|
||||
]
|
||||
}
|
||||
----
|
||||
</screen>
|
||||
++++
|
||||
|
||||
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).
|
||||
|
||||
@ -733,19 +735,21 @@ Commands: +getblock+, +getblockhash+
|
||||
((("bitcoin-cli command line helper","getblock command")))((("bitcoin-cli command line helper","getblockhash command")))((("blocks","exploring")))((("getblock command (bitcoin-cli)")))((("getblockhash command (bitcoin-cli)")))Now that we know which block our transaction was included in, we can query that block. We use the +getblock+ command with the block hash as the parameter:
|
||||
|
||||
|
||||
----
|
||||
$ bitcoin-cli getblock 000000000000000051d2e759c63a26e247f185ecb7926ed7a6624bc31c2a717b true
|
||||
----
|
||||
++++
|
||||
<screen>
|
||||
$ bitcoin-cli getblock 000000000000000051d2e759c63a26e247f185ecb7926ed7a6624b<?pdf-cr?>c31c2a717b true
|
||||
</screen>
|
||||
++++
|
||||
|
||||
[source,json]
|
||||
----
|
||||
++++
|
||||
<screen language="json">
|
||||
{
|
||||
"hash" : "000000000000000051d2e759c63a26e247f185ecb7926ed7a6624bc31c2a717b",
|
||||
"hash" : "000000000000000051d2e759c63a26e247f185ecb7926ed7a6624bc31c2a717<?pdf-cr?>b",
|
||||
"confirmations" : 2,
|
||||
"size" : 248758,
|
||||
"height" : 286384,
|
||||
"version" : 2,
|
||||
"merkleroot" : "9891747e37903016c3b77c7a0ef10acf467c530de52d84735bd55538719f9916",
|
||||
"merkleroot" : "9891747e37903016c3b77c7a0ef10acf467c530de52d84735bd555387<?pdf-cr?>19f9916",
|
||||
"tx" : [
|
||||
"46e130ab3c67d31d2b2c7f8fbc1ca71604a72e6bc504c8a35f777286c6d89bf0",
|
||||
"2d5625725b66d6c1da88b80b41e8c07dc5179ae2553361c96b14bcf1ce2c3868",
|
||||
@ -774,37 +778,42 @@ $ bitcoin-cli getblock 000000000000000051d2e759c63a26e247f185ecb7926ed7a6624bc31
|
||||
"nonce" : 3888130470,
|
||||
"bits" : "19015f53",
|
||||
"difficulty" : 3129573174.52228737,
|
||||
"chainwork" : "000000000000000000000000000000000000000000001931d1658fc04879e466",
|
||||
"previousblockhash" : "0000000000000000177e61d5f6ba6b9450e0dade9f39c257b4d48b4941ac77e7",
|
||||
"nextblockhash" : "0000000000000001239d2c3bf7f4c68a4ca673e434702a57da8fe0d829a92eb6"
|
||||
"chainwork" : "000000000000000000000000000000000000000000001931d1658fc048<?pdf-cr?>79e466",
|
||||
"previousblockhash" : "0000000000000000177e61d5f6ba6b9450e0dade9f39c257b4<?pdf-cr?>d48b4941ac77e7",
|
||||
"nextblockhash" : "0000000000000001239d2c3bf7f4c68a4ca673e434702a57da8fe0<?pdf-cr?>d829a92eb6"
|
||||
}
|
||||
----
|
||||
</screen>
|
||||
++++
|
||||
|
||||
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 block chain.
|
||||
|
||||
We can also retrieve a block by its block height using the +getblockhash+ command, which takes the block height as the parameter and returns the block hash for that block:
|
||||
|
||||
|
||||
----
|
||||
$ bitcoin-cli getblockhash 0
|
||||
000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
|
||||
----
|
||||
++++
|
||||
<screen>
|
||||
$ bitcoin-cli getblockhash 0000000000019d6689c085ae165831e934ff763ae46a2a6c17<?pdf-cr?>2b3f1b60a8ce26f
|
||||
</screen>
|
||||
++++
|
||||
|
||||
Here, we retrieve the block hash of the "genesis block," the first block mined by Satoshi Nakamoto, at height zero. Retrieving this block shows:
|
||||
|
||||
|
||||
----
|
||||
$ bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
|
||||
----
|
||||
[source,json]
|
||||
----
|
||||
++++
|
||||
<screen>
|
||||
$ bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1<?pdf-cr?>b60a8ce26f
|
||||
</screen>
|
||||
++++
|
||||
|
||||
++++
|
||||
<screen language="json">
|
||||
{
|
||||
"hash" : "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
|
||||
"hash" : "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26<?pdf-cr?>f",
|
||||
"confirmations" : 286388,
|
||||
"size" : 285,
|
||||
"height" : 0,
|
||||
"version" : 1,
|
||||
"merkleroot" : "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
|
||||
"merkleroot" : "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7af<?pdf-cr?>deda33b",
|
||||
"tx" : [
|
||||
"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"
|
||||
],
|
||||
@ -812,10 +821,11 @@ $ bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60
|
||||
"nonce" : 2083236893,
|
||||
"bits" : "1d00ffff",
|
||||
"difficulty" : 1.00000000,
|
||||
"chainwork" : "0000000000000000000000000000000000000000000000000000000100010001",
|
||||
"nextblockhash" : "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"
|
||||
"chainwork" : "0000000000000000000000000000000000000000000000000000000100<?pdf-cr?>010001",
|
||||
"nextblockhash" : "00000000839a8e6886ab5951d76f411475428afc90947ee320161b<?pdf-cr?>bf18eb6048"
|
||||
}
|
||||
----
|
||||
</screen>
|
||||
++++
|
||||
|
||||
The +getblock+, +getblockhash+, and +gettransaction+ commands can be used to explore the block chain database, programmatically.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user