From 1f57f1cd53b0303fdb5f4089c090a5e208273b3f Mon Sep 17 00:00:00 2001 From: Michael Rotarius Date: Sat, 7 Jan 2017 10:16:06 +0100 Subject: [PATCH] Update getBlock call --- .../devdoc/bitcoin-core/rpcs/quick-ref.md | 2 +- .../devdoc/bitcoin-core/rpcs/rpcs/getblock.md | 80 ++++++++++++------- 2 files changed, 53 insertions(+), 29 deletions(-) diff --git a/_includes/devdoc/bitcoin-core/rpcs/quick-ref.md b/_includes/devdoc/bitcoin-core/rpcs/quick-ref.md index c81f3d96..3bca59e6 100644 --- a/_includes/devdoc/bitcoin-core/rpcs/quick-ref.md +++ b/_includes/devdoc/bitcoin-core/rpcs/quick-ref.md @@ -56,7 +56,7 @@ Use v0.n.n in abbreviation title to prevent autocrossrefing. {% autocrossref %} * [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}} * [GetBlockCount][rpc getblockcount]: {{summary_getBlockCount}} * [GetBlockHash][rpc getblockhash]: {{summary_getBlockHash}} diff --git a/_includes/devdoc/bitcoin-core/rpcs/rpcs/getblock.md b/_includes/devdoc/bitcoin-core/rpcs/rpcs/getblock.md index dd1c73d6..50510dfb 100644 --- a/_includes/devdoc/bitcoin-core/rpcs/rpcs/getblock.md +++ b/_includes/devdoc/bitcoin-core/rpcs/rpcs/getblock.md @@ -66,6 +66,16 @@ The `getblock` RPC {{summary_getBlock}} p: "Required
(exactly 1)" d: "The size of this block in serialized block format, counted in bytes" +- n: "→
`strippedsize`" + t: "number (int)" + p: "Required
(exactly 1)" + d: "*Added in Bitcoin Core 0.13.0*

The size of this block in serialized block format excluding witness data, counted in bytes" + +- n: "→
`weight`" + t: "number (int)" + p: "Required
(exactly 1)" + d: "*Added in Bitcoin Core 0.13.0*

This block's weight as defined in BIP141" + - n: "→
`height`" t: "number (int)" p: "Required
(exactly 1)" @@ -76,6 +86,11 @@ The `getblock` RPC {{summary_getBlock}} p: "Required
(exactly 1)" d: "This block's version number. See [block version numbers][section block versions]" +- n: "→
`versionHex`" + t: "string (hex)" + p: "Required
(exactly 1)" + d: "*Added in Bitcoin Core 0.13.0*

This block's version formatted in hexadecimal" + - n: "→
`merkleroot`" t: "string (hex)" p: "Required
(exactly 1)" @@ -96,6 +111,11 @@ The `getblock` RPC {{summary_getBlock}} p: "Required
(exactly 1)" d: "The value of the *time* field in the block header, indicating approximately when the block was created" +- n: "→
`mediantime`" + t: "number (int)" + p: "Required
(exactly 1)" + d: "*Added in Bitcoin Core 0.12.0*

The median block time in Unix epoch time" + - n: "→
`nonce`" t: "number (int)" p: "Required
(exactly 1)" @@ -128,55 +148,59 @@ The `getblock` RPC {{summary_getBlock}} {% enditemplate %} -*Example from Bitcoin Core 0.10.0* +*Example from Bitcoin Core 0.13.1* Get a block in raw hex: {% highlight bash %} -bitcoin-cli -testnet getblock \ - 000000000fe549a89848c76070d4132872cfb6efe5315d01d7ef77e4900f2d39 \ +bitcoin-cli getblock \ + 00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 \ false {% endhighlight %} Result (wrapped): {% highlight text %} -02000000df11c014a8d798395b5059c722ebdf3171a4217ead71bf6e0e99f4c7\ -000000004a6f6a2db225c81e77773f6f0457bcb05865a94900ed11356d0b7522\ -8efb38c7785d6053ffff001d005d437001010000000100000000000000000000\ -00000000000000000000000000000000000000000000ffffffff0d03b4770301\ -64062f503253482fffffffff0100f9029500000000232103adb7d8ef6b63de74\ -313e0cd4e07670d09a169b13e4eda2d650f529332c47646dac00000000 +010000006fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d61900\ +00000000982051fd1e4ba744bbbe680e1fee14677ba1a3c3540bf7b1cdb606e8\ +57233e0e61bc6649ffff001d01e3629901010000000100000000000000000000\ +00000000000000000000000000000000000000000000ffffffff0704ffff001d\ +0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec1\ +1600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781\ +e62294721166bf621e73a82cbf2342c858eeac00000000 {% endhighlight %} Get the same block in JSON: {% highlight bash %} -bitcoin-cli -testnet getblock \ - 000000000fe549a89848c76070d4132872cfb6efe5315d01d7ef77e4900f2d39 \ - true +bitcoin-cli getblock \ + 00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 {% endhighlight %} Result: {% highlight json %} { - "hash" : "000000000fe549a89848c76070d4132872cfb6efe5315d01d7ef77e4900f2d39", - "confirmations" : 88029, - "size" : 189, - "height" : 227252, - "version" : 2, - "merkleroot" : "c738fb8e22750b6d3511ed0049a96558b0bc57046f3f77771ec825b22d6a6f4a", - "tx" : [ - "c738fb8e22750b6d3511ed0049a96558b0bc57046f3f77771ec825b22d6a6f4a" - ], - "time" : 1398824312, - "nonce" : 1883462912, - "bits" : "1d00ffff", - "difficulty" : 1.00000000, - "chainwork" : "000000000000000000000000000000000000000000000000083ada4a4009841a", - "previousblockhash" : "00000000c7f4990e6ebf71ad7e21a47131dfeb22c759505b3998d7a814c011df", - "nextblockhash" : "00000000afe1928529ac766f1237657819a11cfcc8ca6d67f119e868ed5b6188" + "hash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048", + "confirmations": 447014, + "strippedsize": 215, + "size": 215, + "weight": 860, + "height": 1, + "version": 1, + "versionHex": "00000001", + "merkleroot": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098", + "tx": [ + "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098" + ], + "time": 1231469665, + "mediantime": 1231469665, + "nonce": 2573394689, + "bits": "1d00ffff", + "difficulty": 1, + "chainwork": "0000000000000000000000000000000000000000000000000000000200020002", + "previousblockhash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f", + "nextblockhash": "000000006a625f06636b8bb6ac7b960a8d03705d1ace08b1a19da3fdcc99ddbd" } {% endhighlight %}