mining: add submitBlock IPC method to Mining interface

Add a submitBlock method to the Mining IPC interface, similar to the
submitblock RPC. This accepts a fully assembled block, validates it, and
if accepted as new, processes it into chainstate.

This is needed for Stratum v2 Job Declarator Server (JDS), where accepted
solutions may correspond to jobs not tied to a Bitcoin Core BlockTemplate.
JDS receives PushSolution fields and reconstructs full blocks; without an
IPC submitBlock method, final submission requires the submitblock RPC.

The method returns detailed status (reason/debug strings) matching the
checkBlock pattern, giving callers enough information to handle
validation failures.
This commit is contained in:
woltx
2026-02-20 15:30:09 -08:00
committed by w0xlt
parent 813b4a80d7
commit 5b60f69e40
4 changed files with 50 additions and 7 deletions

View File

@@ -60,8 +60,10 @@ public:
* @param[in] nonce nonce block header field
* @param[in] coinbase complete coinbase transaction (including witness)
*
* @note unlike the submitblock RPC, this method does NOT add the
* coinbase witness automatically.
* @note Unlike the submitblock RPC, this method does not call
* UpdateUncommittedBlockStructures to add a missing coinbase witness
* reserved value. Callers must provide a complete coinbase transaction,
* including the witness when a witness commitment is present.
*
* @note for heights <= 16, the BIP34 height push in getCoinbaseTx().script_sig_prefix
* is only one byte long, so the coinbase scriptSig needs at least
@@ -157,6 +159,27 @@ public:
*/
virtual bool checkBlock(const CBlock& block, const node::BlockCheckOptions& options, std::string& reason, std::string& debug) = 0;
/**
* Process a fully assembled block.
*
* Similar to the submitblock RPC. Accepts a complete block, validates
* it, and if accepted as new, processes it into chainstate. Accepted
* blocks may then be announced to peers through normal validation signals.
*
* @param[in] block the complete block to submit
* @param[out] reason failure reason (BIP22)
* @param[out] debug more detailed rejection reason
* @returns true if the block was accepted as a new block. Returns
* false and sets reason if the block is a duplicate or
* the validation result is inconclusive.
*
* @note Unlike the submitblock RPC, this method does not call
* UpdateUncommittedBlockStructures to add a missing coinbase witness
* reserved value. Callers must submit a fully formed block, including
* the coinbase witness when a witness commitment is present.
*/
virtual bool submitBlock(const CBlock& block, std::string& reason, std::string& debug) = 0;
//! Get internal node context. Useful for RPC and testing,
//! but not accessible across processes.
virtual const node::NodeContext* context() { return nullptr; }