create_mining_work_unit
create_mining_work_unit "network" "payout_script_pubkey" ( "extranonce_tag" "prev_block_hash" ) Issue a fresh broker-mining work unit. Each call mutates the coinbase (payout output + extranonce_tag) so the merkle root rotates and a distinct header_prefix is returned. The work unit is registered in an in-process tracker keyed by the returned req_id; submit_mining_response(req_id, ...) completes the round trip. Arguments: 1. network (string, required) Network this work unit is for (for example "main", "test", or "regtest"). Must match this node's chain. 2. payout_script_pubkey (string, required) Hex-encoded scriptPubKey for the coinbase payout output. 3. extranonce_tag (string, optional, default="") Hex-encoded extranonce bytes appended to the coinbase scriptSig after the height push. Different tags rotate the merkle root. The final scriptSig is bounded by consensus (2..100 bytes); the request is rejected if exceeded. 4. prev_block_hash (string, optional, default="") Build-ahead parent hash. When set, assemble a coinbase-only child of this specific parent instead of the active tip. The parent must equal getmininginfo.build_ahead_parent_hash. Omit or pass an empty string for normal active-tip mining. Result: { (json object) "req_id" : n, (numeric) bcore-issued work-unit identifier "header_prefix" : "hex", (string) 76-byte serialized block header without nNonce, hex-encoded "target" : "hex", (string) 32-byte target derived from the block nBits "expires_at" : xxx, (numeric) UNIX epoch seconds when this work unit will be evicted "height" : n, (numeric) height of the block being assembled "network" : "str", (string) chain name, matching the request "tip_hash" : "hex" (string) hash of the block this work unit builds on (hashPrevBlock) } Examples: > bitcoin-cli create_mining_work_unit "regtest" "5121...ae" "01" > curl --user myusername --data-binary '{"jsonrpc":"2.0","id":"curltest","method":"create_mining_work_unit","params":["regtest","5121...ae","01"]}' -H 'content-type: application/json' http://127.0.0.1:8332/
Signature
create_mining_work_unit(network: string, payout_script_pubkey: string, extranonce_tag?: string, prev_block_hash?: string) → any Code samples
curl --user "$RPC_USER:$RPC_PASS" \
--data-binary '{"jsonrpc":"1.0","id":"docs","method":"create_mining_work_unit","params":["\"<network>\"","\"<payout_script_pubkey>\"","",""]}' \
-H 'content-type: text/plain;' \
http://127.0.0.1:8332/ Parameters
| Name | Type | Req. | Description |
|---|---|---|---|
| network | string | yes | Network this work unit is for (for example "main", "test", or "regtest"). Must match this node's chain. |
| payout_script_pubkey | string | yes | Hex-encoded scriptPubKey for the coinbase payout output. |
| extranonce_tag | string | — | Hex-encoded extranonce bytes appended to the coinbase scriptSig after the height push. Different tags rotate the merkle root. The final scriptSig is bounded by consensus (2..100 bytes); the request is rejected if exceeded. |
| prev_block_hash | string | — | Build-ahead parent hash. When set, assemble a coinbase-only child of this specific parent instead of the active tip. The parent must equal getmininginfo.build_ahead_parent_hash. Omit or pass an empty string for normal active-tip mining. |
Result
Type: any
{ (json object) "req_id" : n, (numeric) bcore-issued work-unit identifier "header_prefix" : "hex", (string) 76-byte serialized block header without nNonce, hex-encoded "target" : "hex", (string) 32-byte target derived from the block nBits "expires_at" : xxx, (numeric) UNIX epoch seconds when this work unit will be evicted "height" : n, (numeric) height of the block being assembled "network" : "str", (string) chain name, matching the request "tip_hash" : "hex" (string) hash of the block this work unit builds on (hashPrevBlock) }
Source: services/core-node/bcore/src/rpc/mining.cpp:1506
C++ symbol: create_mining_work_unit