Skip to content

getblocktemplatelight JSON-RPC command

getblocktemplatelight ( "template_request" "additional_txs" )

If the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.
It returns data needed to construct a block to work on.
For full specification, see the getblocktemplatelight spec in the doc folder, and BIP22/BIP23.

Arguments

1. template_request              (json object, optional) A json object in the following spec
     {
       "mode": "str",            (string, optional) This must be set to "template", "proposal" (see BIP23), or omitted
       "capabilities": [         (json array, optional) A list of strings
         "support",              (string) client side supported feature, 'longpoll', 'coinbasetxn', 'coinbasevalue', 'proposal', 'serverlist', 'workid'
         ...
       ],
       "longpollid": "str",      (string, optional) Enables long-polling mode: specify the current best block hash (hex)
       "checkvalidity": bool,    (boolean, optional, default=true) Specify whether to test the generated block template for validity ("template" mode only)
       "ignorecache": bool,      (boolean, optional, default=false) Specify whether to unconditionally ignore the cached block template
     }
2. additional_txs                (json array, optional, default=[]) Hex encoded transactions to add to the block (each tx must be unique and valid)
     [
       ...
     ]

Result

{
  "version" : n,                    (numeric) The preferred block version
  "previousblockhash" : "xxxx",     (string) The hash of current highest block
  "job_id" : "xxxx",                (string) Job identifier as a hexadecimal hash160, which is to be used as a parameter in a subsequent call to submitblocklight
  "merkle" : [ "xxxx", ... ],       (array) Hashes encoded in little-endian hexadecimal
  "coinbaseaux" : {                 (json object) data that should be included in the coinbase's scriptSig content
      "flags" : "xx"                  (string) key name is to be ignored, and value included in scriptSig
  },
  "coinbasevalue" : n,              (numeric) maximum allowable input to coinbase transaction, including the generation award and transaction fees (in satoshis)
  "coinbasetxn" : { ... },          (json object) information for coinbase transaction
  "target" : "xxxx",                (string) The hash target
  "mintime" : xxx,                  (numeric) The minimum timestamp appropriate for next block time in seconds since epoch (Jan 1 1970 GMT)
  "mutable" : [                     (array of string) list of ways the block template may be changed
     "value"                          (string) A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'
     ,...
  ],
  "noncerange" : "00000000ffffffff",(string) A range of valid nonces
  "sigoplimit" : n,                 (numeric) limit of sigchecks in blocks
  "sizelimit" : n,                  (numeric) limit of block size
  "curtime" : ttt,                  (numeric) current timestamp in seconds since epoch (Jan 1 1970 GMT)
  "bits" : "xxxxxxxx",              (string) compressed target of next block
  "height" : n                      (numeric) The height of the next block
}

Examples

> bitcoin-cli getblocktemplatelight
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblocktemplatelight", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

Bitcoin Cash Node Daemon version v27.1.1-1ce1d89

Documentation on docs.bitcoincashnode.org reflects the current master branch in Git, and may include API changes that are not yet present in the latest release.