Update getBlock call

This commit is contained in:
Michael Rotarius 2017-01-07 10:16:06 +01:00
parent ebdea130ad
commit 1f57f1cd53
2 changed files with 53 additions and 29 deletions

View file

@ -56,7 +56,7 @@ Use v0.n.n in abbreviation title to prevent autocrossrefing.
{% autocrossref %} {% autocrossref %}
* [GetBestBlockHash][rpc getbestblockhash]: {{summary_getBestBlockHash}} * [GetBestBlockHash][rpc getbestblockhash]: {{summary_getBestBlockHash}}
* [GetBlock][rpc getblock]: {{summary_getBlock}} * [GetBlock][rpc getblock]: {{summary_getBlock}} {{UPDATED0_13_0}}
* [GetBlockChainInfo][rpc getblockchaininfo]: {{summary_getBlockChainInfo}} {{UPDATED0_12_1}} * [GetBlockChainInfo][rpc getblockchaininfo]: {{summary_getBlockChainInfo}} {{UPDATED0_12_1}}
* [GetBlockCount][rpc getblockcount]: {{summary_getBlockCount}} * [GetBlockCount][rpc getblockcount]: {{summary_getBlockCount}}
* [GetBlockHash][rpc getblockhash]: {{summary_getBlockHash}} * [GetBlockHash][rpc getblockhash]: {{summary_getBlockHash}}

View file

@ -66,6 +66,16 @@ The `getblock` RPC {{summary_getBlock}}
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
d: "The size of this block in serialized block format, counted in bytes" d: "The size of this block in serialized block format, counted in bytes"
- n: "→<br>`strippedsize`"
t: "number (int)"
p: "Required<br>(exactly 1)"
d: "*Added in Bitcoin Core 0.13.0*<br><br>The size of this block in serialized block format excluding witness data, counted in bytes"
- n: "→<br>`weight`"
t: "number (int)"
p: "Required<br>(exactly 1)"
d: "*Added in Bitcoin Core 0.13.0*<br><br>This block's weight as defined in BIP141"
- n: "→<br>`height`" - n: "→<br>`height`"
t: "number (int)" t: "number (int)"
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
@ -76,6 +86,11 @@ The `getblock` RPC {{summary_getBlock}}
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
d: "This block's version number. See [block version numbers][section block versions]" d: "This block's version number. See [block version numbers][section block versions]"
- n: "→<br>`versionHex`"
t: "string (hex)"
p: "Required<br>(exactly 1)"
d: "*Added in Bitcoin Core 0.13.0*<br><br>This block's version formatted in hexadecimal"
- n: "→<br>`merkleroot`" - n: "→<br>`merkleroot`"
t: "string (hex)" t: "string (hex)"
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
@ -96,6 +111,11 @@ The `getblock` RPC {{summary_getBlock}}
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
d: "The value of the *time* field in the block header, indicating approximately when the block was created" d: "The value of the *time* field in the block header, indicating approximately when the block was created"
- n: "→<br>`mediantime`"
t: "number (int)"
p: "Required<br>(exactly 1)"
d: "*Added in Bitcoin Core 0.12.0*<br><br>The median block time in Unix epoch time"
- n: "→<br>`nonce`" - n: "→<br>`nonce`"
t: "number (int)" t: "number (int)"
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
@ -128,55 +148,59 @@ The `getblock` RPC {{summary_getBlock}}
{% enditemplate %} {% enditemplate %}
*Example from Bitcoin Core 0.10.0* *Example from Bitcoin Core 0.13.1*
Get a block in raw hex: Get a block in raw hex:
{% highlight bash %} {% highlight bash %}
bitcoin-cli -testnet getblock \ bitcoin-cli getblock \
000000000fe549a89848c76070d4132872cfb6efe5315d01d7ef77e4900f2d39 \ 00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 \
false false
{% endhighlight %} {% endhighlight %}
Result (wrapped): Result (wrapped):
{% highlight text %} {% highlight text %}
02000000df11c014a8d798395b5059c722ebdf3171a4217ead71bf6e0e99f4c7\ 010000006fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d61900\
000000004a6f6a2db225c81e77773f6f0457bcb05865a94900ed11356d0b7522\ 00000000982051fd1e4ba744bbbe680e1fee14677ba1a3c3540bf7b1cdb606e8\
8efb38c7785d6053ffff001d005d437001010000000100000000000000000000\ 57233e0e61bc6649ffff001d01e3629901010000000100000000000000000000\
00000000000000000000000000000000000000000000ffffffff0d03b4770301\ 00000000000000000000000000000000000000000000ffffffff0704ffff001d\
64062f503253482fffffffff0100f9029500000000232103adb7d8ef6b63de74\ 0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec1\
313e0cd4e07670d09a169b13e4eda2d650f529332c47646dac00000000 1600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781\
e62294721166bf621e73a82cbf2342c858eeac00000000
{% endhighlight %} {% endhighlight %}
Get the same block in JSON: Get the same block in JSON:
{% highlight bash %} {% highlight bash %}
bitcoin-cli -testnet getblock \ bitcoin-cli getblock \
000000000fe549a89848c76070d4132872cfb6efe5315d01d7ef77e4900f2d39 \ 00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048
true
{% endhighlight %} {% endhighlight %}
Result: Result:
{% highlight json %} {% highlight json %}
{ {
"hash" : "000000000fe549a89848c76070d4132872cfb6efe5315d01d7ef77e4900f2d39", "hash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
"confirmations" : 88029, "confirmations": 447014,
"size" : 189, "strippedsize": 215,
"height" : 227252, "size": 215,
"version" : 2, "weight": 860,
"merkleroot" : "c738fb8e22750b6d3511ed0049a96558b0bc57046f3f77771ec825b22d6a6f4a", "height": 1,
"tx" : [ "version": 1,
"c738fb8e22750b6d3511ed0049a96558b0bc57046f3f77771ec825b22d6a6f4a" "versionHex": "00000001",
], "merkleroot": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
"time" : 1398824312, "tx": [
"nonce" : 1883462912, "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"
"bits" : "1d00ffff", ],
"difficulty" : 1.00000000, "time": 1231469665,
"chainwork" : "000000000000000000000000000000000000000000000000083ada4a4009841a", "mediantime": 1231469665,
"previousblockhash" : "00000000c7f4990e6ebf71ad7e21a47131dfeb22c759505b3998d7a814c011df", "nonce": 2573394689,
"nextblockhash" : "00000000afe1928529ac766f1237657819a11cfcc8ca6d67f119e868ed5b6188" "bits": "1d00ffff",
"difficulty": 1,
"chainwork": "0000000000000000000000000000000000000000000000000000000200020002",
"previousblockhash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
"nextblockhash": "000000006a625f06636b8bb6ac7b960a8d03705d1ace08b1a19da3fdcc99ddbd"
} }
{% endhighlight %} {% endhighlight %}