mirror of
https://github.com/seigler/dash-docs
synced 2025-07-26 17:26:12 +00:00
Dev Docs: Add REST Documentation
* Uses same basic format as JSON-RPC documentation. Closes #715
This commit is contained in:
parent
4214856cff
commit
5f532c59da
11 changed files with 508 additions and 25 deletions
2
Makefile
2
Makefile
|
@ -180,4 +180,4 @@ manual-update-summaries-file:
|
|||
## future)
|
||||
$S echo "{%comment%}AUTOMATICALLY-GENERATED FILE: DO NOT EDIT THIS FILE" > _includes/helpers/summaries.md
|
||||
$S echo "This file is licensed under the terms of its source texts{%endcomment%}" >> _includes/helpers/summaries.md
|
||||
$S grep -rh --exclude='*summaries.md' 'assign summary_' _includes/ >> _includes/helpers/summaries.md
|
||||
$S grep -rh --exclude='*summaries.md' 'assign summary_' _includes/ | sort >> _includes/helpers/summaries.md
|
||||
|
|
|
@ -267,6 +267,10 @@ script hash:
|
|||
secp256k1:
|
||||
sequence number:
|
||||
sequence numbers: sequence number
|
||||
serialized block: section serialized blocks
|
||||
serialized blocks: section serialized block
|
||||
serialized transaction: raw transaction format
|
||||
serialized transactions: raw transaction format
|
||||
SIGHASH: signature hash
|
||||
'`SIGHASH_ANYONECANPAY`': shacp
|
||||
'`SIGHASH_ALL`': sighash_all
|
||||
|
|
|
@ -81,3 +81,6 @@ This file is licensed under the terms of its source texts{%endcomment%}
|
|||
{% assign summary_getTxOutSetInfo="returns statistics about the confirmed unspent transaction output (UTXO) set. Note that this call may take some time and that it only counts outputs from confirmed transactions---it does not count outputs from the memory pool." %}
|
||||
{% assign summary_getMiningInfo="returns various mining-related information." %}
|
||||
{% assign summary_move="moves a specified amount from one account in your wallet to another using an off-block-chain transaction." %}
|
||||
{% assign summary_restGetBlock="gets a block with a particular header hash from the local block database either as a JSON object or as a serialized block." %}
|
||||
{% assign summary_restGetBlock-noTxDetails="gets a block with a particular header hash from the local block database either as a JSON object or as a serialized block. The JSON object includes TXIDs for transactions within the block rather than the complete transactions [GET block][rest get block] returns." %}
|
||||
{% assign summary_restGetTx="gets a hex-encoded serialized transaction or a JSON object describing the transaction. By default, Bitcoin Core only stores complete transaction data for UTXOs and your own transactions, so this method may fail on historic transactions unless you use the non-default `txindex=1` in your Bitcoin Core startup settings." %}
|
||||
|
|
|
@ -36,29 +36,29 @@ it to account2 with the `move` RPC, account2 will be able to spend those
|
|||
bitcoins even if this parameter is set to `1` or higher.{% endcapture %}
|
||||
|
||||
|
||||
{% capture INCLUDE_DECODE_RAW_TRANSACTION %}| →<br>`txid` | string (hex) | Required<br>(exactly 1) | The transaction's TXID encoded as hex in RPC byte order
|
||||
| →<br>`version` | number (int) | Required<br>(exactly 1) | The transaction format version number
|
||||
| →<br>`locktime` | number (int) | Required<br>(exactly 1) | The transaction's locktime: either a Unix epoch date or block height; see the [Locktime parsing rules][]
|
||||
| →<br>`vin` | array | Required<br>(exactly 1) | An array of objects with each object being an input vector (vin) for this transaction. Input objects will have the same order within the array as they have in the transaction, so the first input listed will be input 0
|
||||
| → →<br>Input | object | Required<br>(1 or more) | An object describing one of this transaction's inputs. May be a regular input or a coinbase
|
||||
| → → →<br>`txid` | string | Optional<br>(0 or 1) | The TXID of the outpoint being spent, encoded as hex in RPC byte order. Not present if this is a coinbase transaction
|
||||
| → → →<br>`vout` | number (int) | Optional<br>(0 or 1) | The output index number (vout) of the outpoint being spent. The first output in a transaction has an index of `0`. Not present if this is a coinbase transaction
|
||||
| → → →<br>`scriptSig` | object | Optional<br>(0 or 1) | An object describing the signature script of this input. Not present if this is a coinbase transaction
|
||||
| → → → →<br>`asm` | string | Required<br>(exactly 1) | The signature script in decoded form with non-data-pushing op codes listed
|
||||
| → → → →<br>`hex` | string (hex) | Required<br>(exactly 1) | The signature script encoded as hex
|
||||
| → → →<br>`coinbase` | string (hex) | Optional<br>(0 or 1) | The coinbase (similar to the hex field of a scriptSig) encoded as hex. Only present if this is a coinbase transaction
|
||||
| → → →<br>`sequence` | number (int) | Required<br>(exactly 1) | The input sequence number
|
||||
| →<br>`vout` | array | Required<br>(exactly 1) | An array of objects each describing an output vector (vout) for this transaction. Output objects will have the same order within the array as they have in the transaction, so the first output listed will be output 0
|
||||
| → →<br>Output | object | Required<br>(1 or more) | An object describing one of this transaction's outputs
|
||||
| → → →<br>`value` | number (bitcoins) | Required<br>(exactly 1) | The number of bitcoins paid to this output. May be `0`
|
||||
| → → →<br>`n` | number (int) | Required<br>(exactly 1) | The output index number of this output within this transaction
|
||||
| → → →<br>`scriptPubKey` | object | Required<br>(exactly 1) | An object describing the pubkey script
|
||||
| → → → →<br>`asm` | string | Required<br>(exactly 1) | The pubkey script in decoded form with non-data-pushing op codes listed
|
||||
| → → → →<br>`hex` | string (hex) | Required<br>(exactly 1) | The pubkey script encoded as hex
|
||||
| → → → →<br>`reqSigs` | number (int) | Optional<br>(0 or 1) | The number of signatures required; this is always `1` for P2PK, P2PKH, and P2SH (including P2SH multisig because the redeem script is not available in the pubkey script). It may be greater than 1 for bare multisig. This value will not be returned for `nulldata` or `nonstandard` script types (see the `type` key below)
|
||||
| → → → →<br>`type` | string | Optional<br>(0 or 1) | The type of script. This will be one of the following:<br>• `pubkey` for a P2PK script<br>• `pubkeyhash` for a P2PKH script<br>• `scripthash` for a P2SH script<br>• `multisig` for a bare multisig script<br>• `nulldata` for nulldata scripts<br>• `nonstandard` for unknown scripts
|
||||
| → → → →<br>`addresses` | string : array | Optional<br>(0 or 1) | The P2PKH or P2SH addresses used in this transaction, or the computed P2PKH address of any pubkeys in this transaction. This array will not be returned for `nulldata` or `nonstandard` script types
|
||||
| → → → → →<br>Address | string | Required<br>(1 or more) | A P2PKH or P2SH address{% endcapture %}
|
||||
{% capture INCLUDE_DECODE_RAW_TRANSACTION %}|{{DEPTH}} →<br>`txid` | string (hex) | Required<br>(exactly 1) | The transaction's TXID encoded as hex in RPC byte order
|
||||
|{{DEPTH}} →<br>`version` | number (int) | Required<br>(exactly 1) | The transaction format version number
|
||||
|{{DEPTH}} →<br>`locktime` | number (int) | Required<br>(exactly 1) | The transaction's locktime: either a Unix epoch date or block height; see the [Locktime parsing rules][]
|
||||
|{{DEPTH}} →<br>`vin` | array | Required<br>(exactly 1) | An array of objects with each object being an input vector (vin) for this transaction. Input objects will have the same order within the array as they have in the transaction, so the first input listed will be input 0
|
||||
|{{DEPTH}} → →<br>Input | object | Required<br>(1 or more) | An object describing one of this transaction's inputs. May be a regular input or a coinbase
|
||||
|{{DEPTH}} → → →<br>`txid` | string | Optional<br>(0 or 1) | The TXID of the outpoint being spent, encoded as hex in RPC byte order. Not present if this is a coinbase transaction
|
||||
|{{DEPTH}} → → →<br>`vout` | number (int) | Optional<br>(0 or 1) | The output index number (vout) of the outpoint being spent. The first output in a transaction has an index of `0`. Not present if this is a coinbase transaction
|
||||
|{{DEPTH}} → → →<br>`scriptSig` | object | Optional<br>(0 or 1) | An object describing the signature script of this input. Not present if this is a coinbase transaction
|
||||
|{{DEPTH}} → → → →<br>`asm` | string | Required<br>(exactly 1) | The signature script in decoded form with non-data-pushing op codes listed
|
||||
|{{DEPTH}} → → → →<br>`hex` | string (hex) | Required<br>(exactly 1) | The signature script encoded as hex
|
||||
|{{DEPTH}} → → →<br>`coinbase` | string (hex) | Optional<br>(0 or 1) | The coinbase (similar to the hex field of a scriptSig) encoded as hex. Only present if this is a coinbase transaction
|
||||
|{{DEPTH}} → → →<br>`sequence` | number (int) | Required<br>(exactly 1) | The input sequence number
|
||||
|{{DEPTH}} →<br>`vout` | array | Required<br>(exactly 1) | An array of objects each describing an output vector (vout) for this transaction. Output objects will have the same order within the array as they have in the transaction, so the first output listed will be output 0
|
||||
|{{DEPTH}} → →<br>Output | object | Required<br>(1 or more) | An object describing one of this transaction's outputs
|
||||
|{{DEPTH}} → → →<br>`value` | number (bitcoins) | Required<br>(exactly 1) | The number of bitcoins paid to this output. May be `0`
|
||||
|{{DEPTH}} → → →<br>`n` | number (int) | Required<br>(exactly 1) | The output index number of this output within this transaction
|
||||
|{{DEPTH}} → → →<br>`scriptPubKey` | object | Required<br>(exactly 1) | An object describing the pubkey script
|
||||
|{{DEPTH}} → → → →<br>`asm` | string | Required<br>(exactly 1) | The pubkey script in decoded form with non-data-pushing op codes listed
|
||||
|{{DEPTH}} → → → →<br>`hex` | string (hex) | Required<br>(exactly 1) | The pubkey script encoded as hex
|
||||
|{{DEPTH}} → → → →<br>`reqSigs` | number (int) | Optional<br>(0 or 1) | The number of signatures required; this is always `1` for P2PK, P2PKH, and P2SH (including P2SH multisig because the redeem script is not available in the pubkey script). It may be greater than 1 for bare multisig. This value will not be returned for `nulldata` or `nonstandard` script types (see the `type` key below)
|
||||
|{{DEPTH}} → → → →<br>`type` | string | Optional<br>(0 or 1) | The type of script. This will be one of the following:<br>• `pubkey` for a P2PK script<br>• `pubkeyhash` for a P2PKH script<br>• `scripthash` for a P2SH script<br>• `multisig` for a bare multisig script<br>• `nulldata` for nulldata scripts<br>• `nonstandard` for unknown scripts
|
||||
|{{DEPTH}} → → → →<br>`addresses` | string : array | Optional<br>(0 or 1) | The P2PKH or P2SH addresses used in this transaction, or the computed P2PKH address of any pubkeys in this transaction. This array will not be returned for `nulldata` or `nonstandard` script types
|
||||
|{{DEPTH}} → → → → →<br>Address | string | Required<br>(1 or more) | A P2PKH or P2SH address{% endcapture %}
|
||||
|
||||
{% assign INCLUDE_WALLET_UNLOCKED="If the wallet has been encrypted either through the GUI or with the `encryptwallet` RPC, it must first be unlocked with the `walletpassphrase` RPC" %}
|
||||
|
||||
|
|
29
_includes/ref/bitcoin-core/rest/intro.md
Normal file
29
_includes/ref/bitcoin-core/rest/intro.md
Normal file
|
@ -0,0 +1,29 @@
|
|||
{% comment %}
|
||||
This file is licensed under the MIT License (MIT) available on
|
||||
http://opensource.org/licenses/MIT.
|
||||
{% endcomment %}
|
||||
{% assign filename="_includes/ref/bitcoin-core/rest/intro.md" %}
|
||||
|
||||
### HTTP REST
|
||||
{% include helpers/subhead-links.md %}
|
||||
|
||||
{% autocrossref %}
|
||||
|
||||
As of [version 0.10.0][bitcoin core 0.10.0], Bitcoin Core provides
|
||||
an **unauthenticated** HTTP REST interface. The interface runs on the
|
||||
same port as the JSON-RPC interface, by default port 8332 for mainnet and
|
||||
port 18332 for testnet. It must be enabled by either starting Bitcoin
|
||||
Core with the `-rest` option or by specifying `rest=1` in the
|
||||
configuration file.
|
||||
|
||||
{{WARNING}} A web browser can access a HTTP REST interface running on
|
||||
localhost, possibly allowing third parties to use cross-site scripting
|
||||
attacks to download your transaction and block data, reducing your
|
||||
privacy. If you have privacy concerns, you should not run a browser on
|
||||
the same computer as a REST-enabled Bicoin Core node.
|
||||
|
||||
The interface uses standard [HTTP status
|
||||
codes](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) and
|
||||
returns a plain-text description of errors for debugging.
|
||||
|
||||
{% endautocrossref %}
|
16
_includes/ref/bitcoin-core/rest/quick-reference.md
Normal file
16
_includes/ref/bitcoin-core/rest/quick-reference.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
{% comment %}
|
||||
This file is licensed under the MIT License (MIT) available on
|
||||
http://opensource.org/licenses/MIT.
|
||||
{% endcomment %}
|
||||
{% assign filename="_includes/ref/bitcoin-core/rest/quick-reference.md" %}
|
||||
|
||||
#### Quick Reference {#rest-quick-reference}
|
||||
{% include helpers/subhead-links.md %}
|
||||
|
||||
{% autocrossref %}
|
||||
|
||||
* [GET Block][rest get block] {{summary_restGetBlock}} {{NEW0_10_0}}
|
||||
* [GET Block/NoTxDetails][rest get block-notxdetails] {{summary_restGetBlock-noTxDetails}} {{NEW0_10_0}}
|
||||
* [GET Tx][rest get tx] {{summary_restGetTx}} {{NEW0_10_0}}
|
||||
|
||||
{% endautocrossref %}
|
|
@ -0,0 +1,113 @@
|
|||
{% comment %}
|
||||
This file is licensed under the MIT License (MIT) available on
|
||||
http://opensource.org/licenses/MIT.
|
||||
{% endcomment %}
|
||||
{% assign filename="_includes/ref/bitcoin-core/rest/requests/get_block-notxdetails.md" %}
|
||||
|
||||
##### GET Block/NoTxDetails
|
||||
{% include helpers/subhead-links.md %}
|
||||
|
||||
{% assign summary_restGetBlock-noTxDetails="gets a block with a particular header hash from the local block database either as a JSON object or as a serialized block. The JSON object includes TXIDs for transactions within the block rather than the complete transactions [GET block][rest get block] returns." %}
|
||||
|
||||
{% autocrossref %}
|
||||
|
||||
The `GET block<!--noref-->/notxdetails` operation {{summary_restGetBlock-noTxDetails}}
|
||||
|
||||
*Request*
|
||||
|
||||
{% highlight text %}
|
||||
GET /block/notxdetails/<hash>.<format>
|
||||
{% endhighlight %}
|
||||
|
||||
*Parameter #1---the header hash of the block to retrieve*
|
||||
|
||||
| Name | Type | Presence | Description
|
||||
|------------------|--------------|-----------------------------|----------------
|
||||
| Header Hash | path (hex) | Required<br>(exactly 1) | The hash of the header of the block to get, encoded as hex in RPC byte order
|
||||
{:.ntpd}
|
||||
|
||||
*Parameter #2---the output format*
|
||||
|
||||
| Name | Type | Presence | Description
|
||||
|------------------|--------------|-----------------------------|----------------
|
||||
| Format | suffix | Required<br>(exactly 1) | Set to `.json` for decoded block contents in JSON, or `.bin` or `hex` for a serialized block in binary or hex
|
||||
{:.ntpd}
|
||||
|
||||
*Response as JSON*
|
||||
|
||||
| Name | Type | Presence | Description
|
||||
|--------------------------|-------------------|-----------------------------|----------------
|
||||
| Result | object | Required<br>(exactly 1) | An object containing the requested block
|
||||
| →<br>`hash` | string (hex) | Required<br>(exactly 1) | The hash of this block's block header encoded as hex in RPC byte order. This is the same as the hash provided in parameter #1
|
||||
| →<br>`confirmations` | number (int) | Required<br>(exactly 1) | The number of confirmations the transactions in this block have, starting at 1 when this block is at the tip of the best block chain. This score will be -1 if the the block is not part of the best block chain
|
||||
| →<br>`size` | number (int) | Required<br>(exactly 1) | The size of this block in serialized block format, counted in bytes
|
||||
| →<br>`height` | number (int) | Required<br>(exactly 1) | The height of this block on its block chain
|
||||
| →<br>`version` | number (int) | Required<br>(exactly 1) | This block's version number. See [block version numbers][section block versions]
|
||||
| →<br>`merkleroot` | string (hex) | Required<br>(exactly 1) | The merkle root for this block, encoded as hex in RPC byte order
|
||||
| →<br>`tx` | array | Required<br>(exactly 1) | An array containing all transactions in this block. The transactions appear in the array in the same order they appear in the serialized block
|
||||
| → →<br>TXID | string (hex) | Required<br>(1 or more) | The TXID of a transaction in this block, encoded as hex in RPC byte order
|
||||
| →<br>`time` | number (int) | Required<br>(exactly 1) | The value of the *time* field in the block header, indicating approximately when the block was created
|
||||
| →<br>`nonce` | number (int) | Required<br>(exactly 1) | The nonce which was successful at turning this particular block into one that could be added to the best block chain
|
||||
| →<br>`bits` | string (hex) | Required<br>(exactly 1) | The value of the *nBits* field in the block header, indicating the target threshold this block's header had to pass
|
||||
| →<br>`difficulty` | number (real) | Required<br>(exactly 1) | The estimated amount of work done to find this block relative to the estimated amount of work done to find block 0
|
||||
| →<br>`chainwork` | string (hex) | Required<br>(exactly 1) | The estimated number of block header hashes miners had to check from the genesis block to this block, encoded as big-endian hex
|
||||
| →<br>`previousblockhash` | string (hex) | Required<br>(exactly 1) | The hash of the header of the previous block, encoded as hex in RPC byte order
|
||||
| →<br>`nextblockhash` | string (hex) | Optional<br>(0 or 1) | The hash of the next block on the best block chain, if known, encoded as hex in RPC byte order
|
||||
{:.ntpd}
|
||||
|
||||
*Examples from Bitcoin Core 0.10.0*
|
||||
|
||||
Request a block in hex-encoded serialized block format:
|
||||
|
||||
{% highlight bash %}
|
||||
curl http://localhost:18332/rest/block/notxdetails/000000000fe549a89848c76070d4132872cfb6efe5315d01d7ef77e4900f2d39.hex
|
||||
{% endhighlight %}
|
||||
|
||||
Result (wrapped):
|
||||
|
||||
{% highlight text %}
|
||||
02000000df11c014a8d798395b5059c722ebdf3171a4217ead71bf6e0e99f4c7\
|
||||
000000004a6f6a2db225c81e77773f6f0457bcb05865a94900ed11356d0b7522\
|
||||
8efb38c7785d6053ffff001d005d437001010000000100000000000000000000\
|
||||
00000000000000000000000000000000000000000000ffffffff0d03b4770301\
|
||||
64062f503253482fffffffff0100f9029500000000232103adb7d8ef6b63de74\
|
||||
313e0cd4e07670d09a169b13e4eda2d650f529332c47646dac00000000
|
||||
{% endhighlight %}
|
||||
|
||||
Get the same block in JSON:
|
||||
|
||||
{% highlight bash %}
|
||||
curl http://localhost:18332/rest/block/notxdetails/000000000fe549a89848c76070d4132872cfb6efe5315d01d7ef77e4900f2d39.json
|
||||
{% endhighlight %}
|
||||
|
||||
Result (whitespaced added):
|
||||
|
||||
{% highlight json %}
|
||||
{
|
||||
"hash": "000000000fe549a89848c76070d4132872cfb6efe5315d01d7ef77e4900f2d39",
|
||||
"confirmations": 91807,
|
||||
"size": 189,
|
||||
"height": 227252,
|
||||
"version": 2,
|
||||
"merkleroot": "c738fb8e22750b6d3511ed0049a96558b0bc57046f3f77771ec825b22d6a6f4a",
|
||||
"tx": [
|
||||
"c738fb8e22750b6d3511ed0049a96558b0bc57046f3f77771ec825b22d6a6f4a"
|
||||
],
|
||||
"time": 1398824312,
|
||||
"nonce": 1883462912,
|
||||
"bits": "1d00ffff",
|
||||
"difficulty": 1.0,
|
||||
"chainwork": "000000000000000000000000000000000000000000000000083ada4a4009841a",
|
||||
"previousblockhash": "00000000c7f4990e6ebf71ad7e21a47131dfeb22c759505b3998d7a814c011df",
|
||||
"nextblockhash": "00000000afe1928529ac766f1237657819a11cfcc8ca6d67f119e868ed5b6188"
|
||||
}
|
||||
{% endhighlight %}
|
||||
|
||||
*See also*
|
||||
|
||||
* [GET Block][rest get block]: {{summary_restGetBlock}}
|
||||
* [GetBlock][rpc getblock] RPC: {{summary_getBlock}}
|
||||
* [GetBlockHash][rpc getblockhash] RPC: {{summary_getBlockHash}}
|
||||
* [GetBestBlockHash][rpc getbestblockhash] RPC: {{summary_getBestBlockHash}}
|
||||
|
||||
{% endautocrossref %}
|
142
_includes/ref/bitcoin-core/rest/requests/get_block.md
Normal file
142
_includes/ref/bitcoin-core/rest/requests/get_block.md
Normal file
|
@ -0,0 +1,142 @@
|
|||
{% comment %}
|
||||
This file is licensed under the MIT License (MIT) available on
|
||||
http://opensource.org/licenses/MIT.
|
||||
{% endcomment %}
|
||||
{% assign filename="_includes/ref/bitcoin-core/rest/requests/get_block.md" %}
|
||||
|
||||
##### GET Block
|
||||
{% include helpers/subhead-links.md %}
|
||||
|
||||
{% assign summary_restGetBlock="gets a block with a particular header hash from the local block database either as a JSON object or as a serialized block." %}
|
||||
|
||||
{% autocrossref %}
|
||||
|
||||
The `GET block` operation {{summary_restGetBlock}}
|
||||
|
||||
*Request*
|
||||
|
||||
{% highlight text %}
|
||||
GET /block/<hash>.<format>
|
||||
{% endhighlight %}
|
||||
|
||||
*Parameter #1---the header hash of the block to retrieve*
|
||||
|
||||
| Name | Type | Presence | Description
|
||||
|------------------|--------------|-----------------------------|----------------
|
||||
| Header Hash | path (hex) | Required<br>(exactly 1) | The hash of the header of the block to get, encoded as hex in RPC byte order
|
||||
{:.ntpd}
|
||||
|
||||
*Parameter #2---the output format*
|
||||
|
||||
| Name | Type | Presence | Description
|
||||
|------------------|--------------|-----------------------------|----------------
|
||||
| Format | suffix | Required<br>(exactly 1) | Set to `.json` for decoded block contents in JSON, or `.bin` or `hex` for a serialized block in binary or hex
|
||||
{:.ntpd}
|
||||
|
||||
*Response as JSON*
|
||||
|
||||
{% assign DEPTH="→ →" %}
|
||||
{% include helpers/vars.md %}
|
||||
|
||||
| Name | Type | Presence | Description
|
||||
|--------------------------|-------------------|-----------------------------|----------------
|
||||
| Result | object | Required<br>(exactly 1) | An object containing the requested block
|
||||
| →<br>`hash` | string (hex) | Required<br>(exactly 1) | The hash of this block's block header encoded as hex in RPC byte order. This is the same as the hash provided in parameter #1
|
||||
| →<br>`confirmations` | number (int) | Required<br>(exactly 1) | The number of confirmations the transactions in this block have, starting at 1 when this block is at the tip of the best block chain. This score will be -1 if the the block is not part of the best block chain
|
||||
| →<br>`size` | number (int) | Required<br>(exactly 1) | The size of this block in serialized block format, counted in bytes
|
||||
| →<br>`height` | number (int) | Required<br>(exactly 1) | The height of this block on its block chain
|
||||
| →<br>`version` | number (int) | Required<br>(exactly 1) | This block's version number. See [block version numbers][section block versions]
|
||||
| →<br>`merkleroot` | string (hex) | Required<br>(exactly 1) | The merkle root for this block, encoded as hex in RPC byte order
|
||||
| →<br>`tx` | array | Required<br>(exactly 1) | An array containing all transactions in this block. The transactions appear in the array in the same order they appear in the serialized block
|
||||
| → →<br>Transaction | object | Required<br>(1 or more) | An object describing a particular transaction within this block
|
||||
{{INCLUDE_DECODE_RAW_TRANSACTION}}
|
||||
| →<br>`time` | number (int) | Required<br>(exactly 1) | The value of the *time* field in the block header, indicating approximately when the block was created
|
||||
| →<br>`nonce` | number (int) | Required<br>(exactly 1) | The nonce which was successful at turning this particular block into one that could be added to the best block chain
|
||||
| →<br>`bits` | string (hex) | Required<br>(exactly 1) | The value of the *nBits* field in the block header, indicating the target threshold this block's header had to pass
|
||||
| →<br>`difficulty` | number (real) | Required<br>(exactly 1) | The estimated amount of work done to find this block relative to the estimated amount of work done to find block 0
|
||||
| →<br>`chainwork` | string (hex) | Required<br>(exactly 1) | The estimated number of block header hashes miners had to check from the genesis block to this block, encoded as big-endian hex
|
||||
| →<br>`previousblockhash` | string (hex) | Required<br>(exactly 1) | The hash of the header of the previous block, encoded as hex in RPC byte order
|
||||
| →<br>`nextblockhash` | string (hex) | Optional<br>(0 or 1) | The hash of the next block on the best block chain, if known, encoded as hex in RPC byte order
|
||||
{:.ntpd}
|
||||
|
||||
*Examples from Bitcoin Core 0.10.0*
|
||||
|
||||
Request a block in hex-encoded serialized block format:
|
||||
|
||||
{% highlight bash %}
|
||||
curl http://localhost:18332/rest/block/000000000fe549a89848c76070d4132872cfb6efe5315d01d7ef77e4900f2d39.hex
|
||||
{% endhighlight %}
|
||||
|
||||
Result (wrapped):
|
||||
|
||||
{% highlight text %}
|
||||
02000000df11c014a8d798395b5059c722ebdf3171a4217ead71bf6e0e99f4c7\
|
||||
000000004a6f6a2db225c81e77773f6f0457bcb05865a94900ed11356d0b7522\
|
||||
8efb38c7785d6053ffff001d005d437001010000000100000000000000000000\
|
||||
00000000000000000000000000000000000000000000ffffffff0d03b4770301\
|
||||
64062f503253482fffffffff0100f9029500000000232103adb7d8ef6b63de74\
|
||||
313e0cd4e07670d09a169b13e4eda2d650f529332c47646dac00000000
|
||||
{% endhighlight %}
|
||||
|
||||
Get the same block in JSON:
|
||||
|
||||
{% highlight bash %}
|
||||
curl http://localhost:18332/rest/block/000000000fe549a89848c76070d4132872cfb6efe5315d01d7ef77e4900f2d39.json
|
||||
{% endhighlight %}
|
||||
|
||||
Result (whitespaced added):
|
||||
|
||||
{% highlight json %}
|
||||
{
|
||||
"hash": "000000000fe549a89848c76070d4132872cfb6efe5315d01d7ef77e4900f2d39",
|
||||
"confirmations": 91785,
|
||||
"size": 189,
|
||||
"height": 227252,
|
||||
"version": 2,
|
||||
"merkleroot": "c738fb8e22750b6d3511ed0049a96558b0bc57046f3f77771ec825b22d6a6f4a",
|
||||
"tx": [
|
||||
{
|
||||
"txid": "c738fb8e22750b6d3511ed0049a96558b0bc57046f3f77771ec825b22d6a6f4a",
|
||||
"version": 1,
|
||||
"locktime": 0,
|
||||
"vin": [
|
||||
{
|
||||
"coinbase": "03b477030164062f503253482f",
|
||||
"sequence": 4294967295
|
||||
}
|
||||
],
|
||||
"vout": [
|
||||
{
|
||||
"value": 25.0,
|
||||
"n": 0,
|
||||
"scriptPubKey": {
|
||||
"asm": "03adb7d8ef6b63de74313e0cd4e07670d09a169b13e4eda2d650f529332c47646d OP_CHECKSIG",
|
||||
"hex": "2103adb7d8ef6b63de74313e0cd4e07670d09a169b13e4eda2d650f529332c47646dac",
|
||||
"reqSigs": 1,
|
||||
"type": "pubkey",
|
||||
"addresses": [
|
||||
"muXeUp1QYscuPRFH3qHtSrHyG6DQpvg7xZ"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"time": 1398824312,
|
||||
"nonce": 1883462912,
|
||||
"bits": "1d00ffff",
|
||||
"difficulty": 1.0,
|
||||
"chainwork": "000000000000000000000000000000000000000000000000083ada4a4009841a",
|
||||
"previousblockhash": "00000000c7f4990e6ebf71ad7e21a47131dfeb22c759505b3998d7a814c011df",
|
||||
"nextblockhash": "00000000afe1928529ac766f1237657819a11cfcc8ca6d67f119e868ed5b6188"
|
||||
}
|
||||
{% endhighlight %}
|
||||
|
||||
*See also*
|
||||
|
||||
* [GET Block/NoTxDetails][rest get block-notxdetails] {{summary_restGetBlock-noTxDetails}}
|
||||
* [GetBlock][rpc getblock] RPC: {{summary_getBlock}}
|
||||
* [GetBlockHash][rpc getblockhash] RPC: {{summary_getBlockHash}}
|
||||
* [GetBestBlockHash][rpc getbestblockhash] RPC: {{summary_getBestBlockHash}}
|
||||
|
||||
{% endautocrossref %}
|
150
_includes/ref/bitcoin-core/rest/requests/get_tx.md
Normal file
150
_includes/ref/bitcoin-core/rest/requests/get_tx.md
Normal file
|
@ -0,0 +1,150 @@
|
|||
{% comment %}
|
||||
This file is licensed under the MIT License (MIT) available on
|
||||
http://opensource.org/licenses/MIT.
|
||||
{% endcomment %}
|
||||
{% assign filename="_includes/ref/bitcoin-core/rest/requests/get_tx.md" %}
|
||||
|
||||
##### GET Tx
|
||||
{% include helpers/subhead-links.md %}
|
||||
|
||||
{% assign summary_restGetTx="gets a hex-encoded serialized transaction or a JSON object describing the transaction. By default, Bitcoin Core only stores complete transaction data for UTXOs and your own transactions, so this method may fail on historic transactions unless you use the non-default `txindex=1` in your Bitcoin Core startup settings." %}
|
||||
|
||||
{% autocrossref %}
|
||||
|
||||
The `GET tx` operation {{summary_restTx}}
|
||||
|
||||
*Request*
|
||||
|
||||
{% highlight text %}
|
||||
GET /tx/<txid>.<format>
|
||||
{% endhighlight %}
|
||||
|
||||
*Parameter #1---the TXID of the transaction to retrieve*
|
||||
|
||||
| Name | Type | Presence | Description
|
||||
|------------------|--------------|-----------------------------|----------------
|
||||
| TXID | path (hex) | Required<br>(exactly 1) | The TXID of the transaction to get, encoded as hex in RPC byte order
|
||||
{:.ntpd}
|
||||
|
||||
*Parameter #2---the output format*
|
||||
|
||||
| Name | Type | Presence | Description
|
||||
|------------------|--------------|-----------------------------|----------------
|
||||
| Format | suffix | Required<br>(exactly 1) | Set to `.json` for decoded transaction contents in JSON, or `.bin` or `hex` for a serialized transaction in binary or hex
|
||||
{:.ntpd}
|
||||
|
||||
*Response as JSON*
|
||||
|
||||
{% assign DEPTH="" %}
|
||||
{% include helpers/vars.md %}
|
||||
|
||||
| Name | Type | Presence | Description
|
||||
|----------------------|-----------------|-----------------------------|----------------
|
||||
| Result | object | Required<br>(exactly 1) | An object describing the request transaction
|
||||
{{INCLUDE_DECODE_RAW_TRANSACTION}}
|
||||
| →<br>`blockhash` | string (hex) | Optional<br>(0 or 1) | If the transaction has been included in a block on the local best block chain, this is the hash of that block encoded as hex in RPC byte order
|
||||
| →<br>`confirmations` | number (int) | Required<br>(exactly 1) | If the transaction has been included in a block on the local best block chain, this is how many confirmations it has. Otherwise, this is `0`
|
||||
| →<br>`time` | number (int) | Optional<br>(0 or 1) | If the transaction has been included in a block on the local best block chain, this is the block header time of that block (may be in the future)
|
||||
| →<br>`blocktime` | number (int) | Optional<br>(0 or 1) | This field is currently identical to the time field described above
|
||||
{:.ntpd}
|
||||
|
||||
*Examples from Bitcoin Core 0.10.0*
|
||||
|
||||
Request a transaction in hex-encoded serialized transaction format:
|
||||
|
||||
{% highlight bash %}
|
||||
curl http://localhost:18332/rest/tx/ef7c0cbf6ba5af68d2ea239bba709b26ff7b0b669839a63bb01c2cb8e8de481e.hex
|
||||
{% endhighlight %}
|
||||
|
||||
Result (wrapped):
|
||||
|
||||
{% highlight text %}
|
||||
0100000001268a9ad7bfb21d3c086f0ff28f73a064964aa069ebb69a9e437da8\
|
||||
5c7e55c7d7000000006b483045022100ee69171016b7dd218491faf6e13f53d4\
|
||||
0d64f4b40123a2de52560feb95de63b902206f23a0919471eaa1e45a0982ed28\
|
||||
8d374397d30dff541b2dd45a4c3d0041acc0012103a7c1fd1fdec50e1cf3f0cc\
|
||||
8cb4378cd8e9a2cee8ca9b3118f3db16cbbcf8f326ffffffff0350ac60020000\
|
||||
00001976a91456847befbd2360df0e35b4e3b77bae48585ae06888ac80969800\
|
||||
000000001976a9142b14950b8d31620c6cc923c5408a701b1ec0a02088ac002d\
|
||||
3101000000001976a9140dfc8bafc8419853b34d5e072ad37d1a5159f58488ac\
|
||||
00000000
|
||||
{% endhighlight %}
|
||||
|
||||
Get the same transaction in JSON:
|
||||
|
||||
{% highlight bash %}
|
||||
curl http://localhost:18332/rest/tx/ef7c0cbf6ba5af68d2ea239bba709b26ff7b0b669839a63bb01c2cb8e8de481e.json
|
||||
{% endhighlight %}
|
||||
|
||||
Result (whitespaced added):
|
||||
|
||||
{% highlight json %}
|
||||
{
|
||||
"txid": "ef7c0cbf6ba5af68d2ea239bba709b26ff7b0b669839a63bb01c2cb8e8de481e",
|
||||
"version": 1,
|
||||
"locktime": 0,
|
||||
"vin": [
|
||||
{
|
||||
"txid": "d7c7557e5ca87d439e9ab6eb69a04a9664a0738ff20f6f083c1db2bfd79a8a26",
|
||||
"vout": 0,
|
||||
"scriptSig": {
|
||||
"asm": "3045022100ee69171016b7dd218491faf6e13f53d40d64f4b40123a2de52560feb95de63b902206f23a0919471eaa1e45a0982ed288d374397d30dff541b2dd45a4c3d0041acc001 03a7c1fd1fdec50e1cf3f0cc8cb4378cd8e9a2cee8ca9b3118f3db16cbbcf8f326",
|
||||
"hex": "483045022100ee69171016b7dd218491faf6e13f53d40d64f4b40123a2de52560feb95de63b902206f23a0919471eaa1e45a0982ed288d374397d30dff541b2dd45a4c3d0041acc0012103a7c1fd1fdec50e1cf3f0cc8cb4378cd8e9a2cee8ca9b3118f3db16cbbcf8f326"
|
||||
},
|
||||
"sequence": 4294967295
|
||||
}
|
||||
],
|
||||
"vout": [
|
||||
{
|
||||
"value": 0.39889999999999998,
|
||||
"n": 0,
|
||||
"scriptPubKey": {
|
||||
"asm": "OP_DUP OP_HASH160 56847befbd2360df0e35b4e3b77bae48585ae068 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"hex": "76a91456847befbd2360df0e35b4e3b77bae48585ae06888ac",
|
||||
"reqSigs": 1,
|
||||
"type": "pubkeyhash",
|
||||
"addresses": [
|
||||
"moQR7i8XM4rSGoNwEsw3h4YEuduuP6mxw7"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"value": 0.10000000000000001,
|
||||
"n": 1,
|
||||
"scriptPubKey": {
|
||||
"asm": "OP_DUP OP_HASH160 2b14950b8d31620c6cc923c5408a701b1ec0a020 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"hex": "76a9142b14950b8d31620c6cc923c5408a701b1ec0a02088ac",
|
||||
"reqSigs": 1,
|
||||
"type": "pubkeyhash",
|
||||
"addresses": [
|
||||
"mjSk1Ny9spzU2fouzYgLqGUD8U41iR35QN"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"value": 0.20000000000000001,
|
||||
"n": 2,
|
||||
"scriptPubKey": {
|
||||
"asm": "OP_DUP OP_HASH160 0dfc8bafc8419853b34d5e072ad37d1a5159f584 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"hex": "76a9140dfc8bafc8419853b34d5e072ad37d1a5159f58488ac",
|
||||
"reqSigs": 1,
|
||||
"type": "pubkeyhash",
|
||||
"addresses": [
|
||||
"mgnucj8nYqdrPFh2JfZSB1NmUThUGnmsqe"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"blockhash": "00000000103e0091b7d27e5dc744a305108f0c752be249893c749e19c1c82317",
|
||||
"confirmations": 91916,
|
||||
"time": 1398734825,
|
||||
"blocktime": 1398734825
|
||||
}
|
||||
{% endhighlight %}
|
||||
|
||||
*See also*
|
||||
|
||||
* [GetRawTransaction][rpc getrawtransaction] RPC: {{summary_getRawTransaction}}
|
||||
* [GetTransaction][rpc gettransaction] RPC: {{summary_getTransaction}}
|
||||
|
||||
{% endautocrossref %}
|
|
@ -290,6 +290,11 @@ http://opensource.org/licenses/MIT.
|
|||
[rpc walletpassphrase]: /en/developer-reference#walletpassphrase
|
||||
[rpc walletpassphrasechange]: /en/developer-reference#walletpassphrasechange
|
||||
|
||||
<!-- REST requests; alphabetical order -->
|
||||
[rest get block]: /en/developer-reference#get-block
|
||||
[rest get block-notxdetails]: /en/developer-reference#get-blocknotxdetails
|
||||
[rest get tx]: /en/developer-reference#get-tx
|
||||
|
||||
<!-- Other internal site links; alphabetical order -->
|
||||
[Bitcoin Core 0.6.0]: /en/release/v0.6.0
|
||||
[Bitcoin Core 0.6.1]: /en/release/v0.6.1
|
||||
|
|
|
@ -48,7 +48,7 @@ title: "Developer Reference - Bitcoin"
|
|||
{{WARNING}} the block chain and memory pool can include arbitrary data
|
||||
which several of the commands below will return in hex format. If you
|
||||
convert this data to another format in an executable context, it could
|
||||
be used in an exploit. For example, displaying an output script as
|
||||
be used in an exploit. For example, displaying a pubkey script as
|
||||
ASCII text in a webpage could add arbitrary Javascript to that page and
|
||||
create a cross-site scripting (XSS) exploit. To avoid problems, please
|
||||
treat block chain and memory pool data as an arbitrary input from an
|
||||
|
@ -216,6 +216,27 @@ untrusted source.
|
|||
|
||||
{% include ref/bitcoin-core/rpcs/rpcs/walletpassphrasechange.md %}
|
||||
|
||||
{% include ref/bitcoin-core/rest/intro.md %}
|
||||
|
||||
{% include ref/bitcoin-core/rest/quick-reference.md %}
|
||||
|
||||
#### Requests
|
||||
<!-- no subhead-links here -->
|
||||
|
||||
{{WARNING}} the block chain and memory pool can include arbitrary data
|
||||
which several of the commands below will return in hex format. If you
|
||||
convert this data to another format in an executable context, it could
|
||||
be used in an exploit. For example, displaying a pubkey script as
|
||||
ASCII text in a webpage could add arbitrary Javascript to that page and
|
||||
create a cross-site scripting (XSS) exploit. To avoid problems, please
|
||||
treat block chain and memory pool data as an arbitrary input from an
|
||||
untrusted source.
|
||||
|
||||
{% include ref/bitcoin-core/rest/requests/get_block.md %}
|
||||
|
||||
{% include ref/bitcoin-core/rest/requests/get_block-notxdetails.md %}
|
||||
|
||||
{% include ref/bitcoin-core/rest/requests/get_tx.md %}
|
||||
|
||||
{% include references.md %}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue