mining: add reason and debug output to submitSolution

Add reason and debug output parameters to submitSolution, matching
submitBlock. This relays the specific failure reason (e.g.
"bad-version(...)", "bad-witness-nonce-size", "duplicate") to callers
instead of just a bool.

Use a new capnp ordinal for the updated method and keep the old @7 method
as a deprecated entry point returning an explicit error, so old clients do
not decode corrupt result fields and are directed to update.
This commit is contained in:
w0xlt
2026-02-25 12:24:29 -08:00
parent 83f3bc002d
commit cbaa1696f3
5 changed files with 75 additions and 30 deletions

View File

@@ -917,12 +917,12 @@ public:
return TransactionMerklePath(m_block_template->block, 0);
}
bool submitSolution(uint32_t version, uint32_t timestamp, uint32_t nonce, CTransactionRef coinbase) override
bool submitSolution(uint32_t version, uint32_t timestamp, uint32_t nonce, CTransactionRef coinbase, std::string& reason, std::string& debug) override
{
AddMerkleRootAndCoinbase(m_block_template->block, std::move(coinbase), version, timestamp, nonce);
std::string reason;
std::string debug;
return SubmitBlock(chainman(), std::make_shared<const CBlock>(m_block_template->block), /*new_block=*/nullptr, reason, debug);
bool new_block;
const bool accepted = SubmitBlock(chainman(), std::make_shared<const CBlock>(m_block_template->block), &new_block, reason, debug);
return accepted && new_block && reason.empty();
}
std::unique_ptr<BlockTemplate> waitNext(BlockWaitOptions options) override