test: clean up tx resurrection (re-org) test in feature_block.py
What changed, and why it matters
This is a cleanup change to one of Bitcoin Core's own automated tests. It removes an outdated comment about signature quirks and adjusts the test transactions so they follow normal network rules, allowing a special 'accept non-standard transactions' flag to be removed. It does not change any production code that runs on real Bitcoin nodes, so it has no direct security impact on the network or users.
No action needed. This is a test-only refactor with no security relevance to production Bitcoin Core.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies test/functional/feature_block.py, a functional regression test. It removes the -acceptnonstdtxn=1 argument from the test node and replaces unsigned/non-standard OP_TRUE outputs with properly signed P2PK outputs (key_to_p2pk_script) so the resurrected transactions pass standard mempool policy. The consensus behavior being exercised (transaction resurrection after re-org) is unchanged; only the test scaffolding is modernized.
Changed components
test/functional/feature_block.pyInspect captured patch +7 / −14
diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py
index 47b80674..6803bb33 100755
--- a/test/functional/feature_block.py
+++ b/test/functional/feature_block.py
@@ -48,6 +48,7 @@ from test_framework.script import (
sign_input_legacy,
)
from test_framework.script_util import (
+ key_to_p2pk_script,
script_to_p2sh_script,
)
from test_framework.test_framework import BitcoinTestFramework
@@ -90,7 +91,6 @@ class FullBlockTest(BitcoinTestFramework):
self.num_nodes = 1
self.setup_clean_chain = True
self.extra_args = [[
- '-acceptnonstdtxn=1', # This is a consensus block test, we don't care about tx policy
'-testactivationheight=bip34@2',
]]
@@ -1164,31 +1164,24 @@ class FullBlockTest(BitcoinTestFramework):
#
# b78 creates a tx, which is spent in b79. After b82, both should be in mempool
#
- # The tx'es must be unsigned and pass the node's mempool policy. It is unsigned for the
- # rather obscure reason that the Python signature code does not distinguish between
- # Low-S and High-S values (whereas the bitcoin code has custom code which does so);
- # as a result of which, the odds are 50% that the python code will use the right
- # value and the transaction will be accepted into the mempool. Until we modify the
- # test framework to support low-S signing, we are out of luck.
- #
- # To get around this issue, we construct transactions which are not signed and which
- # spend to OP_TRUE. If the standard-ness rules change, this test would need to be
- # updated. (Perhaps to spend to a P2SH OP_TRUE script)
+ # The resurrected transactions must pass the node's mempool policy, so create
+ # and spend standard outputs (P2PK using the coinbase pubkey to keep it simple).
self.log.info("Test transaction resurrection during a re-org")
+ standard_output_script = key_to_p2pk_script(self.coinbase_pubkey)
self.move_tip(76)
self.next_block(77)
- tx77 = self.create_and_sign_transaction(out[24], 10 * COIN)
+ tx77 = self.create_and_sign_transaction(out[24], 10 * COIN, standard_output_script)
b77 = self.update_block(77, [tx77])
self.send_blocks([b77], True)
self.save_spendable_output()
self.next_block(78)
- tx78 = self.create_tx(tx77, 0, 9 * COIN)
+ tx78 = self.create_and_sign_transaction(tx77, 9 * COIN, standard_output_script)
b78 = self.update_block(78, [tx78])
self.send_blocks([b78], True)
self.next_block(79)
- tx79 = self.create_tx(tx78, 0, 8 * COIN)
+ tx79 = self.create_and_sign_transaction(tx78, 8 * COIN, standard_output_script)
b79 = self.update_block(79, [tx79])
self.send_blocks([b79], True)
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.