|
| 1 | +--- |
| 2 | +layout: doc |
| 3 | +name: getblock |
| 4 | +elemversion: 23.3.1 |
| 5 | +elemgroup: blockchain |
| 6 | +permalink: /en/doc/23.3.1/rpc/blockchain/getblock/ |
| 7 | +--- |
| 8 | + |
| 9 | +getblock "blockhash" ( verbosity ) |
| 10 | + |
| 11 | +If verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'. |
| 12 | +If verbosity is 1, returns an Object with information about block <hash>. |
| 13 | +If verbosity is 2, returns an Object with information about block <hash> and information about each transaction. |
| 14 | +If verbosity is 3, returns an Object with information about block <hash> and information about each transaction, including prevout information for inputs (only for unpruned blocks in the current best chain). |
| 15 | + |
| 16 | +Arguments: |
| 17 | +1. blockhash (string, required) The block hash |
| 18 | +2. verbosity (numeric, optional, default=1) 0 for hex-encoded data, 1 for a JSON object, 2 for JSON object with transaction data, and 3 for JSON object with transaction data including prevout information for inputs |
| 19 | + |
| 20 | +Result (for verbosity = 0): |
| 21 | +"hex" (string) A string that is serialized, hex-encoded data for block 'hash' |
| 22 | + |
| 23 | +Result (for verbosity = 1): |
| 24 | +{ (json object) |
| 25 | + "hash" : "hex", (string) the block hash (same as provided) |
| 26 | + "confirmations" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain |
| 27 | + "size" : n, (numeric) The block size |
| 28 | + "strippedsize" : n, (numeric) The block size excluding witness data |
| 29 | + "weight" : n, (numeric) The block weight as defined in BIP 141 |
| 30 | + "height" : n, (numeric) The block height or index |
| 31 | + "version" : n, (numeric) The block version |
| 32 | + "versionHex" : "hex", (string) The block version formatted in hexadecimal |
| 33 | + "merkleroot" : "hex", (string) The merkle root |
| 34 | + "tx" : [ (json array) The transaction ids |
| 35 | + "hex", (string) The transaction id |
| 36 | + ... |
| 37 | + ], |
| 38 | + "time" : xxx, (numeric) The block time expressed in UNIX epoch time |
| 39 | + "mediantime" : xxx, (numeric) The median block time expressed in UNIX epoch time |
| 40 | + "nonce" : n, (numeric) The nonce |
| 41 | + "bits" : "hex", (string) The bits |
| 42 | + "difficulty" : n, (numeric) The difficulty |
| 43 | + "chainwork" : "hex", (string) Expected number of hashes required to produce the chain up to this block (in hex) |
| 44 | + "nTx" : n, (numeric) The number of transactions in the block |
| 45 | + "signblock_witness_asm" : "str", (string) ASM of sign block witness data |
| 46 | + "signblock_witness_hex" : "hex", (string) Hex of sign block witness data |
| 47 | + "dynamic_parameters" : { (json object) Dynamic federation parameters in the block, if any |
| 48 | + "current" : { (json object) enforced dynamic federation parameters. The signblockscript is published for each block, while others are published only at epoch start |
| 49 | + "signblockscript" : "hex", (string) signblock script |
| 50 | + "max_block_witness" : n, (numeric) Maximum serialized size of the block witness stack |
| 51 | + "fedpegscript" : "hex", (string) fedpeg script |
| 52 | + "extension_space" : [ (json array) array of hex-encoded strings |
| 53 | + ... |
| 54 | + ] |
| 55 | + }, |
| 56 | + "proposed" : { (json object) Proposed parameters. Uninforced. Must be published in full |
| 57 | + ... same entries as current |
| 58 | + } |
| 59 | + }, |
| 60 | + "previousblockhash" : "hex", (string, optional) The hash of the previous block (if available) |
| 61 | + "nextblockhash" : "hex" (string, optional) The hash of the next block (if available) |
| 62 | +} |
| 63 | + |
| 64 | +Result (for verbosity = 2): |
| 65 | +{ (json object) |
| 66 | + ..., Same output as verbosity = 1 |
| 67 | + "tx" : [ (json array) |
| 68 | + { (json object) |
| 69 | + ..., The transactions in the format of the getrawtransaction RPC. Different from verbosity = 1 "tx" result |
| 70 | + "fee" : n (numeric) The transaction fee in BTC, omitted if block undo data is not available |
| 71 | + }, |
| 72 | + ... |
| 73 | + ] |
| 74 | +} |
| 75 | + |
| 76 | +Result (for verbosity = 3): |
| 77 | +{ (json object) |
| 78 | + ..., Same output as verbosity = 2 |
| 79 | + "tx" : [ (json array) |
| 80 | + { (json object) |
| 81 | + "vin" : [ (json array) |
| 82 | + { (json object) |
| 83 | + ..., The same output as verbosity = 2 |
| 84 | + "prevout" : { (json object) (Only if undo information is available) |
| 85 | + "generated" : true|false, (boolean) Coinbase or not |
| 86 | + "height" : n, (numeric) The height of the prevout |
| 87 | + "value" : n, (numeric) The value in BTC |
| 88 | + "scriptPubKey" : { (json object) |
| 89 | + "asm" : "str", (string) The asm |
| 90 | + "hex" : "str", (string) The hex |
| 91 | + "address" : "str", (string, optional) The Bitcoin address (only if a well-defined address exists) |
| 92 | + "type" : "str" (string) The type (one of: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_scripthash, witness_v0_keyhash, witness_v1_taproot, witness_unknown) |
| 93 | + } |
| 94 | + } |
| 95 | + }, |
| 96 | + ... |
| 97 | + ] |
| 98 | + }, |
| 99 | + ... |
| 100 | + ] |
| 101 | +} |
| 102 | + |
| 103 | +Examples: |
| 104 | +> elements-cli getblock "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09" |
| 105 | +> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getblock", "params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]}' -H 'content-type: text/plain;' http://127.0.0.1:7041/ |
0 commit comments