Work on updating existing Block Chain RPCs

- GetBestBlockHash, GetBlock, GetBlockChainInfo, GetBlockCount,
GetBlockHash
This commit is contained in:
thephez 2017-10-05 10:12:37 -04:00
parent e9ffedbb41
commit 815069243b
5 changed files with 111 additions and 116 deletions

View file

@ -25,16 +25,16 @@ The `getbestblockhash` RPC {{summary_getBestBlockHash}}
{% enditemplate %} {% enditemplate %}
*Example from Bitcoin Core 0.10.0* *Example from Dash Core 0.12.2*
{% highlight bash %} {% highlight bash %}
bitcoin-cli -testnet getbestblockhash dash-cli -testnet getbestblockhash
{% endhighlight %} {% endhighlight %}
Result: Result:
{% highlight text %} {% highlight text %}
0000000000075c58ed39c3e50f99b32183d090aefa0cf8c324a82eea9b01a887 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
{% endhighlight %} {% endhighlight %}
*See also* *See also*

View file

@ -27,9 +27,9 @@ The `getblock` RPC {{summary_getBlock}}
{% itemplate ntpd1 %} {% itemplate ntpd1 %}
- n: "Format" - n: "Format"
t: "number" t: "boolean"
p: "Optional<br>(0, 1 or 2)" p: "Optional<br>(true or false)"
d: "Set to `0` to get the block in serialized block format; set to `1` (the default) to get the decoded block as a JSON object; set to `2` to get the decoded block as a JSON object with verbose transaction decoding" d: "Set to `false` to get the block in serialized block format; set to `true` (the default) to get the decoded block as a JSON object"
{% enditemplate %} {% enditemplate %}
@ -66,16 +66,6 @@ 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)"
@ -86,11 +76,6 @@ 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)"
@ -148,60 +133,63 @@ The `getblock` RPC {{summary_getBlock}}
{% enditemplate %} {% enditemplate %}
*Example from Bitcoin Core 0.13.1* *Example from Dash Core 0.12.2*
Get a block in raw hex: Get a block in raw hex:
{% highlight bash %} {% highlight bash %}
bitcoin-cli getblock \ dash-cli -testnet getblock \
00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 \ 0000000037955fcc39af8b1ae75914ffb422313c0fca7eba96a1ac99c2e57f84 \
false false
{% endhighlight %} {% endhighlight %}
Result (wrapped): Result (wrapped):
{% highlight text %} {% highlight text %}
010000006fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d61900\ 0100002011f5719a0a0c4881ff98b4a68c1c828dc3b10f5b51033f5f93d48dbf\
00000000982051fd1e4ba744bbbe680e1fee14677ba1a3c3540bf7b1cdb606e8\ 000000004b8e38f197d6ee878e160d2bae3ce05ab898a6252458ec67ce770140\
57233e0e61bc6649ffff001d01e3629901010000000100000000000000000000\ 260397c4dd2ed659a1dd001d00636b5601010000000100000000000000000000\
00000000000000000000000000000000000000000000ffffffff0704ffff001d\ 00000000000000000000000000000000000000000000ffffffff4b02041204dd\
0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec1\ 2ed65908fabe6d6d7445746d63506b62572d2d35584853467a765a6748696972\
1600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781\ 30657a3a6f6d656e010000000000000017fffff9020000000d2f6e6f64655374\
e62294721166bf621e73a82cbf2342c858eeac00000000 726174756d2f00000000058028bb13010000001976a914bad55652dffb1af943\
41015c94feea79793442fd88ac40e553b1020000001976a9142b7856de53d4c1\
823090c98f8ad79862842c09b588ac4094dd89000000001976a914c2c29ebc78\
7954ef99d01c5f79115abf7012fb8e88ac4094dd89000000001976a914d7b47d\
4b40a23c389f5a17754d7f60f511c7d0ec88ac4094dd89000000001976a914dc\
3e0793134b081145ec0c67a9c72a7b297df27c88ac00000000
{% endhighlight %} {% endhighlight %}
Get the same block in JSON: Get the same block in JSON:
{% highlight bash %} {% highlight bash %}
bitcoin-cli getblock \ dash-cli -testnet getblock \
00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 0000000037955fcc39af8b1ae75914ffb422313c0fca7eba96a1ac99c2e57f84
{% endhighlight %} {% endhighlight %}
Result: Result:
{% highlight json %} {% highlight json %}
{ {
"hash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048", "hash": "0000000037955fcc39af8b1ae75914ffb422313c0fca7eba96a1ac99c2e57f84",
"confirmations": 447014, "confirmations": 3,
"strippedsize": 215, "size": 377,
"size": 215, "height": 4612,
"weight": 860, "version": 536870913,
"height": 1, "merkleroot": "c4970326400177ce67ec582425a698b85ae03cae2b0d168e87eed697f1388e4b",
"version": 1, "tx": [
"versionHex": "00000001", "c4970326400177ce67ec582425a698b85ae03cae2b0d168e87eed697f1388e4b"
"merkleroot": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098", ],
"tx": [ "time": 1507208925,
"0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098" "mediantime": 1507208645,
], "nonce": 1449878272,
"time": 1231469665, "bits": "1d00dda1",
"mediantime": 1231469665, "difficulty": 1.155066358813473,
"nonce": 2573394689, "chainwork": "000000000000000000000000000000000000000000000000000001c3e86f0f04",
"bits": "1d00ffff", "previousblockhash": "00000000bf8dd4935f3f03515b0fb1c38d821c8ca6b498ff81480c0a9a71f511",
"difficulty": 1, "nextblockhash": "0000000028817c7fce55d802f3647640600535a983d00e16076f284ec6cb001b"
"chainwork": "0000000000000000000000000000000000000000000000000000000200020002",
"previousblockhash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
"nextblockhash": "000000006a625f06636b8bb6ac7b960a8d03705d1ace08b1a19da3fdcc99ddbd"
} }
{% endhighlight %} {% endhighlight %}
*See also* *See also*

View file

@ -52,7 +52,7 @@ The `getblockchaininfo` RPC {{summary_getBlockChainInfo}}
t: "number (int)" t: "number (int)"
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
d: "*Added in Bitcoin Core 0.12.0*<br><br>The median time of the 11 blocks before the most recent block on the blockchain. Used for validating transaction locktime under BIP113" d: "*Added in Bitcoin Core 0.12.0*<br><br>The median time of the 11 blocks before the most recent block on the blockchain. Used for validating transaction locktime under BIP113"
- n: "→<br>`verificationprogress`" - n: "→<br>`verificationprogress`"
t: "number (real)" t: "number (real)"
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
@ -67,12 +67,12 @@ The `getblockchaininfo` RPC {{summary_getBlockChainInfo}}
t: "bool" t: "bool"
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
d: "*Added in Bitcoin Core 0.11.0*<br><br>Indicates if the blocks are subject to pruning" d: "*Added in Bitcoin Core 0.11.0*<br><br>Indicates if the blocks are subject to pruning"
- n: "→<br>`pruneheight`" - n: "→<br>`pruneheight`"
t: "number (int)" t: "number (int)"
p: "Optional<br>(0 or 1)" p: "Optional<br>(0 or 1)"
d: "*Added in Bitcoin Core 0.11.0*<br><br>The lowest-height complete block stored if prunning is activated" d: "*Added in Bitcoin Core 0.11.0*<br><br>The lowest-height complete block stored if pruning is activated"
- n: "→<br>`softforks`" - n: "→<br>`softforks`"
t: "array" t: "array"
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
@ -82,17 +82,17 @@ The `getblockchaininfo` RPC {{summary_getBlockChainInfo}}
t: "object" t: "object"
p: "Required<br>(3 or more)" p: "Required<br>(3 or more)"
d: "A specific softfork" d: "A specific softfork"
- n: "→ → →<br>`id`" - n: "→ → →<br>`id`"
t: "string" t: "string"
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
d: "The name of the softfork" d: "The name of the softfork"
- n: "→ → →<br>`version`" - n: "→ → →<br>`version`"
t: "numeric<br>(int)" t: "numeric<br>(int)"
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
d: "The block version used for the softfork" d: "The block version used for the softfork"
- n: "→ → →<br>`enforce`" - n: "→ → →<br>`enforce`"
t: "string : object" t: "string : object"
p: "Optional<br>(0 or 1)" p: "Optional<br>(0 or 1)"
@ -102,12 +102,12 @@ The `getblockchaininfo` RPC {{summary_getBlockChainInfo}}
t: "bool" t: "bool"
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
d: "Indicates if the threshold was reached" d: "Indicates if the threshold was reached"
- n: "→ → → →<br>`found`" - n: "→ → → →<br>`found`"
t: "numeric<br>(int)" t: "numeric<br>(int)"
p: "Optional<br>(0 or 1)" p: "Optional<br>(0 or 1)"
d: "Number of blocks that support the softfork" d: "Number of blocks that support the softfork"
- n: "→ → → →<br>`required`" - n: "→ → → →<br>`required`"
t: "numeric<br>(int)" t: "numeric<br>(int)"
p: "Optional<br>(0 or 1)" p: "Optional<br>(0 or 1)"
@ -127,12 +127,12 @@ The `getblockchaininfo` RPC {{summary_getBlockChainInfo}}
t: "bool" t: "bool"
p: "Optional<br>(0 or 1)" p: "Optional<br>(0 or 1)"
d: "Indicates if the threshold was reached" d: "Indicates if the threshold was reached"
- n: "→ → → →<br>`found`" - n: "→ → → →<br>`found`"
t: "numeric<br>(int)" t: "numeric<br>(int)"
p: "Optional<br>(0 or 1)" p: "Optional<br>(0 or 1)"
d: "Number of blocks that support the softfork" d: "Number of blocks that support the softfork"
- n: "→ → → →<br>`required`" - n: "→ → → →<br>`required`"
t: "numeric<br>(int)" t: "numeric<br>(int)"
p: "Optional<br>(0 or 1)" p: "Optional<br>(0 or 1)"
@ -142,101 +142,108 @@ The `getblockchaininfo` RPC {{summary_getBlockChainInfo}}
t: "numeric<br>(int)" t: "numeric<br>(int)"
p: "Optional<br>(0 or 1)" p: "Optional<br>(0 or 1)"
d: "The maximum size of examined window of recent blocks" d: "The maximum size of examined window of recent blocks"
- n: "→<br>`bip9_softforks`" - n: "→<br>`bip9_softforks`"
t: "object" t: "object"
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
d: "*Added in Bitcoin Core 0.12.1*<br><br>The status of BIP9 softforks in progress" d: "*Added in Bitcoin Core 0.12.1*<br><br>The status of BIP9 softforks in progress"
- n: "→ →<br>Name" - n: "→ →<br>Name"
t: "string : object" t: "string : object"
p: "Required<br>(2 or more)" p: "Required<br>(2 or more)"
d: "A specific BIP9 softfork" d: "A specific BIP9 softfork"
- n: "→ → →<br>`status`" - n: "→ → →<br>`status`"
t: "string" t: "string"
p: "Required<br>(exactly 1)" p: "Required<br>(exactly 1)"
d: "Set to one of the following reasons:<br>`defined` if voting hasn't started yet<br>`started` if the voting has started <br>`locked_in` if the voting was successful but the softfort hasn't been activated yet<br>`active` if the softfork was activated<br>`failed` if the softfork has not receieved enough votes" d: "Set to one of the following reasons:<br>`defined` if voting hasn't started yet<br>`started` if the voting has started <br>`locked_in` if the voting was successful but the softfort hasn't been activated yet<br>`active` if the softfork was activated<br>`failed` if the softfork has not receieved enough votes"
- n: "→ → →<br>`bit`" - n: "→ → →<br>`bit`"
t: "numeric<br>(int)" t: "numeric<br>(int)"
p: "Optional<br>(0 or 1)" p: "Optional<br>(0 or 1)"
d: "The bit (0-28) in the block version field used to signal this softfork. Field is only shown when status is `started`" d: "The bit (0-28) in the block version field used to signal this softfork. Field is only shown when status is `started`"
- n: "→ → →<br>`startTime`"
t: "numeric<br>(int)"
p: "Required<br>(exactly 1)"
d: "The Unix epoch time when the softfork voting begins"
- n: "→ → →<br>`timeout`"
t: "numeric<br>(int)"
p: "Required<br>(exactly 1)"
d: "The Unix epoch time at which the deployment is considered failed if not yet locked in"
- n: "→ → →<br>`since`"
t: "numeric<br>(int)"
p: "Required<br>(exactly 1)"
d: "*Added in Bitcoin Core 0.14.0*<br><br>The height of the first block to which the status applies"
{% enditemplate %} {% enditemplate %}
*Example from Bitcoin Core 0.14.1* *Example from Dash Core 0.12.2*
{% highlight bash %} {% highlight bash %}
bitcoin-cli getblockchaininfo dash-cli -testnet getblockchaininfo
{% endhighlight %} {% endhighlight %}
Result: Result:
{% highlight json %} {% highlight json %}
{ {
"chain": "main", "chain": "test",
"blocks": 464562, "blocks": 4622,
"headers": 464562, "headers": 4622,
"bestblockhash": "00000000000000000085bd56990c579a36bade6ea427646612f13476edb30ceb", "bestblockhash": "000000007f4141e557309da09911b1c3c65b8e9eed3f5e940f7083aec8999ac7",
"difficulty": 521974519553.6282, "difficulty": 1.380236305048335,
"mediantime": 1493758169, "mediantime": 1507209819,
"verificationprogress": 0.999989733170878, "verificationprogress": 0.9999053826626874,
"chainwork": "00000000000000000000000000000000000000000052c26f32ffa22706efd28c", "chainwork": "000000000000000000000000000000000000000000000000000001d17aeaf58b",
"pruned": false, "pruned": false,
"softforks": [ "softforks": [
{ {
"id": "bip34", "id": "bip34",
"version": 2, "version": 2,
"enforce": {
"status": true,
"found": 100,
"required": 51,
"window": 100
},
"reject": { "reject": {
"status": true "status": true,
"found": 100,
"required": 75,
"window": 100
} }
}, },
{ {
"id": "bip66", "id": "bip66",
"version": 3, "version": 3,
"enforce": {
"status": true,
"found": 100,
"required": 51,
"window": 100
},
"reject": { "reject": {
"status": true "status": true,
"found": 100,
"required": 75,
"window": 100
} }
}, },
{ {
"id": "bip65", "id": "bip65",
"version": 4, "version": 4,
"enforce": {
"status": true,
"found": 100,
"required": 51,
"window": 100
},
"reject": { "reject": {
"status": true "status": true,
"found": 100,
"required": 75,
"window": 100
} }
} }
], ],
"bip9_softforks": { "bip9_softforks": [
"csv": { {
"status": "active", "id": "csv",
"startTime": 1462060800, "status": "started"
"timeout": 1493596800,
"since": 419328
}, },
"segwit": { {
"status": "started", "id": "dip0001",
"bit": 1, "status": "started"
"startTime": 1479168000,
"timeout": 1510704000,
"since": 439488
} }
} ]
} }
{% endhighlight %} {% endhighlight %}

View file

@ -25,16 +25,16 @@ The `getblockcount` RPC {{summary_getBlockCount}}
{% enditemplate %} {% enditemplate %}
*Example from Bitcoin Core 0.10.0* *Example from Dash Core 0.12.2*
{% highlight bash %} {% highlight bash %}
bitcoin-cli -testnet getblockcount dash-cli -testnet getblockcount
{% endhighlight %} {% endhighlight %}
Result: Result:
{% highlight text %} {% highlight text %}
315280 4627
{% endhighlight %} {% endhighlight %}
*See also* *See also*

View file

@ -33,16 +33,16 @@ The `getblockhash` RPC {{summary_getBlockHash}}
{% enditemplate %} {% enditemplate %}
*Example from Bitcoin Core 0.10.0* *Example from Dash Core 0.12.2*
{% highlight bash %} {% highlight bash %}
bitcoin-cli -testnet getblockhash 240886 dash-cli -testnet getblockhash 4000
{% endhighlight %} {% endhighlight %}
Result: Result:
{% highlight text %} {% highlight text %}
00000000a0faf83ab5799354ae9c11da2a2bd6db44058e03c528851dee0a3fff 00000ce22113f3eb8636e225d6a1691e132fdd587aed993e1bc9b07a0235eea4
{% endhighlight %} {% endhighlight %}
*See also* *See also*