test: Remove unused feature_segwit.py functions
What changed, and why it matters
This commit simply deletes unused helper functions and an unused variable from a single test file. It does not change any production code, network behavior, or wallet logic. There is no security issue here.
No action needed. This is a routine test-cleanup commit with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch removes four unused imports, one unused module-level dictionary (txs_mined), and three unused methods (mine_and_test_listunspent, p2sh_address_to_script, p2pkh_address_to_script, create_and_mine_tx_from_txids) from test/functional/feature_segwit.py. The commit message explicitly states these are unused after a prior refactor. No runtime code is modified.
Changed components
test/functional/feature_segwit.pyInspect captured patch +0 / −65
diff --git a/test/functional/feature_segwit.py b/test/functional/feature_segwit.py
index dc5dde9c..35c9459c 100755
--- a/test/functional/feature_segwit.py
+++ b/test/functional/feature_segwit.py
@@ -29,11 +29,7 @@ from test_framework.script import (
OP_TRUE,
)
from test_framework.script_util import (
- key_to_p2pk_script,
- key_to_p2wpkh_script,
keys_to_multisig_script,
- script_to_p2sh_script,
- script_to_p2wsh_script,
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
@@ -67,9 +63,6 @@ def find_spendable_utxo(node, min_value):
raise AssertionError(f"Unspent output equal or higher than {min_value} not found")
-txs_mined = {} # txindex from txid to blockhash
-
-
class SegWitTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
@@ -298,64 +291,6 @@ class SegWitTest(BitcoinTestFramework):
# Mine a block to clear the gbt cache again.
self.generate(self.nodes[0], 1)
- def mine_and_test_listunspent(self, script_list, ismine):
- utxo = find_spendable_utxo(self.nodes[0], 50)
- tx = CTransaction()
- tx.vin.append(CTxIn(COutPoint(int('0x' + utxo['txid'], 0), utxo['vout'])))
- for i in script_list:
- tx.vout.append(CTxOut(10000000, i))
- signresults = self.nodes[0].signrawtransactionwithwallet(tx.serialize_without_witness().hex())['hex']
- txid = self.nodes[0].sendrawtransaction(hexstring=signresults, maxfeerate=0)
- txs_mined[txid] = self.generate(self.nodes[0], 1)[0]
- watchcount = 0
- spendcount = 0
- for i in self.nodes[0].listunspent():
- if i['txid'] == txid:
- watchcount += 1
- if i['spendable']:
- spendcount += 1
- if ismine == 2:
- assert_equal(spendcount, len(script_list))
- elif ismine == 1:
- assert_equal(watchcount, len(script_list))
- assert_equal(spendcount, 0)
- else:
- assert_equal(watchcount, 0)
- return txid
-
- def p2sh_address_to_script(self, v):
- bare = CScript(bytes.fromhex(v['hex']))
- p2sh = CScript(bytes.fromhex(v['scriptPubKey']))
- p2wsh = script_to_p2wsh_script(bare)
- p2sh_p2wsh = script_to_p2sh_script(p2wsh)
- return [bare, p2sh, p2wsh, p2sh_p2wsh]
-
- def p2pkh_address_to_script(self, v):
- pubkey = bytes.fromhex(v['pubkey'])
- p2wpkh = key_to_p2wpkh_script(pubkey)
- p2sh_p2wpkh = script_to_p2sh_script(p2wpkh)
- p2pk = key_to_p2pk_script(pubkey)
- p2pkh = CScript(bytes.fromhex(v['scriptPubKey']))
- p2sh_p2pk = script_to_p2sh_script(p2pk)
- p2sh_p2pkh = script_to_p2sh_script(p2pkh)
- p2wsh_p2pk = script_to_p2wsh_script(p2pk)
- p2wsh_p2pkh = script_to_p2wsh_script(p2pkh)
- p2sh_p2wsh_p2pk = script_to_p2sh_script(p2wsh_p2pk)
- p2sh_p2wsh_p2pkh = script_to_p2sh_script(p2wsh_p2pkh)
- return [p2wpkh, p2sh_p2wpkh, p2pk, p2pkh, p2sh_p2pk, p2sh_p2pkh, p2wsh_p2pk, p2wsh_p2pkh, p2sh_p2wsh_p2pk, p2sh_p2wsh_p2pkh]
-
- def create_and_mine_tx_from_txids(self, txids, success=True):
- tx = CTransaction()
- for i in txids:
- txraw = self.nodes[0].getrawtransaction(i, 0, txs_mined[i])
- txtmp = tx_from_hex(txraw)
- for j in range(len(txtmp.vout)):
- tx.vin.append(CTxIn(COutPoint(int('0x' + i, 0), j)))
- tx.vout.append(CTxOut(0, CScript()))
- signresults = self.nodes[0].signrawtransactionwithwallet(tx.serialize_without_witness().hex())['hex']
- self.nodes[0].sendrawtransaction(hexstring=signresults, maxfeerate=0)
- self.generate(self.nodes[0], 1)
-
if __name__ == '__main__':
SegWitTest(__file__).main()
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.