mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 05:32:22 +02:00
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:
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user