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

@@ -1023,6 +1023,17 @@ public:
return state.IsValid();
}
bool submitBlock(const CBlock& block_in, std::string& reason, std::string& debug) override
{
auto block = std::make_shared<const CBlock>(block_in);
bool new_block;
const bool accepted = SubmitBlock(chainman(), block, &new_block, reason, debug);
// ProcessNewBlock() can accept and store a block before it is checked
// for validity. Treat duplicates as errors for mining clients, and only
// return success when validation completed without setting a reason.
return accepted && new_block && reason.empty();
}
const NodeContext* context() override { return &m_node; }
ChainstateManager& chainman() { return *Assert(m_node.chainman); }
KernelNotifications& notifications() { return *Assert(m_node.notifications); }