test: mining: add coverage for GBT's "coinbasevalue" result field
What changed, and why it matters
This commit only adds a new test to Bitcoin Core's functional test suite. It checks that the getblocktemplate RPC returns a 'coinbasevalue' field equal to the full block reward (subsidy plus fees). There is no change to production code, no bug fix, and no security-relevant behavior change.
No action required. This is a benign test-only commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies test/functional/mining_basic.py to capture the full getblocktemplate response, then asserts that block_template[‘coinbasevalue’] matches the value computed by create_coinbase() for the reported height and accumulated fees. This is purely additional test coverage; no consensus, mining, or RPC implementation code is altered.
Changed components
test/functional/mining_basic.pyInspect captured patch +6 / −1
diff --git a/test/functional/mining_basic.py b/test/functional/mining_basic.py
index 899f8705..53ddb0ed 100755
--- a/test/functional/mining_basic.py
+++ b/test/functional/mining_basic.py
@@ -122,7 +122,8 @@ class MiningTest(BitcoinTestFramework):
tx_d = self.wallet.send_self_transfer(from_node=node,
fee_rate=Decimal("0.00100"))
- block_template_txs = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)['transactions']
+ block_template = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)
+ block_template_txs = block_template['transactions']
block_template_fees = [tx['fee'] for tx in block_template_txs]
assert_equal(block_template_fees, [
@@ -131,6 +132,10 @@ class MiningTest(BitcoinTestFramework):
tx_b["fee"] * COIN,
tx_c["fee"] * COIN
])
+ # verify that coinbasevalue field is set to claim full block reward (subsidy + fees)
+ expected_block_reward = create_coinbase(
+ height=int(block_template["height"]), fees=sum(block_template_fees)).vout[0].nValue
+ assert_equal(block_template["coinbasevalue"], expected_block_reward)
block_template_sigops = [tx['sigops'] for tx in block_template_txs]
assert_equal(block_template_sigops, [0, 4, 4, 4])
Why this scored 15/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.