rpc refactor: stop using deprecated getCoinbaseCommitment method
What changed, and why it matters
This is a small internal code cleanup in Bitcoin Core's mining RPC. It replaces a deprecated helper method with a direct read of the coinbase transaction data. The commit message explicitly says there should be no change in behavior, and the diff shows equivalent logic: it still returns the same witness commitment value under the same JSON key when present.
No security action needed. Treat as normal refactoring review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors getblocktemplate() in src/rpc/mining.cpp. Previously it called block_template->getCoinbaseCommitment() to obtain the default witness commitment scriptPubKey. Now it calls block_template->getCoinbaseTx() and reads coinbase.required_outputs[0].scriptPubKey, asserting there is exactly one required output. The returned JSON key and value are unchanged, and the commit message states there is no behavior change.
Changed components
src/rpc/mining.cppgetblocktemplate RPCInspect captured patch +3 / −2
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index ee80b903..e21d0d13 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -1015,8 +1015,9 @@ static RPCHelpMan getblocktemplate()
result.pushKV("signet_challenge", HexStr(consensusParams.signet_challenge));
}
- if (!block_template->getCoinbaseCommitment().empty()) {
- result.pushKV("default_witness_commitment", HexStr(block_template->getCoinbaseCommitment()));
+ if (auto coinbase{block_template->getCoinbaseTx()}; coinbase.required_outputs.size() > 0) {
+ CHECK_NONFATAL(coinbase.required_outputs.size() == 1); // Only one output is currently expected
+ result.pushKV("default_witness_commitment", HexStr(coinbase.required_outputs[0].scriptPubKey));
}
return result;
Why this scored 13/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.