test: return full keypair from `getnewdestination` helper
What changed, and why it matters
This is a small test-only code cleanup. A helper function used only in Bitcoin Core's functional test suite now returns the full private/public key pair instead of just the public key, so that future tests can spend coins sent to a generated address. It does not change any production wallet, node, or consensus code, and it does not introduce a security vulnerability.
No security action required; this is a benign test-framework refactor. Reviewers can verify that all callers of `getnewdestination` are updated to the new return shape and that the private key remains within the test process.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies getnewdestination() in test/functional/test_framework/wallet.py to return ((key, pubkey), scriptpubkey, address) rather than (pubkey, scriptpubkey, address). Two test callers (rpc_createmultisig.py and rpc_scantxoutset.py) are updated to unpack the new tuple shape. The private key is generated locally inside the test framework and is not exposed to RPC users, the network, or any production code path. The change is explicitly described as preparatory for a follow-up taproot functional test that runs without the Core wallet compiled in.
Changed components
test/functional/test_framework/wallet.pytest/functional/rpc_createmultisig.pytest/functional/rpc_scantxoutset.pyInspect captured patch +6 / −6
diff --git a/test/functional/rpc_createmultisig.py b/test/functional/rpc_createmultisig.py
index 5ed0b255..faaa7f61 100755
--- a/test/functional/rpc_createmultisig.py
+++ b/test/functional/rpc_createmultisig.py
@@ -189,7 +189,7 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
def test_mixing_uncompressed_and_compressed_keys(self, node):
self.log.info('Mixed compressed and uncompressed multisigs are not allowed')
- pk0, pk1, pk2 = [getnewdestination('bech32')[0].hex() for _ in range(3)]
+ pk0, pk1, pk2 = [getnewdestination('bech32')[0][1].hex() for _ in range(3)]
# decompress pk2
pk_obj = ECPubKey()
diff --git a/test/functional/rpc_scantxoutset.py b/test/functional/rpc_scantxoutset.py
index d59bd31a..75079bc9 100755
--- a/test/functional/rpc_scantxoutset.py
+++ b/test/functional/rpc_scantxoutset.py
@@ -36,9 +36,9 @@ class ScantxoutsetTest(BitcoinTestFramework):
assert_equal(sum(u["coinbase"] for u in self.nodes[0].scantxoutset("start", [self.wallet.get_descriptor()])["unspents"]), 49)
self.log.info("Create UTXOs...")
- pubk1, spk_P2SH_SEGWIT, addr_P2SH_SEGWIT = getnewdestination("p2sh-segwit")
- pubk2, spk_LEGACY, addr_LEGACY = getnewdestination("legacy")
- pubk3, spk_BECH32, addr_BECH32 = getnewdestination("bech32")
+ (_, pubk1), spk_P2SH_SEGWIT, addr_P2SH_SEGWIT = getnewdestination("p2sh-segwit")
+ (_, pubk2), spk_LEGACY, addr_LEGACY = getnewdestination("legacy")
+ (_, pubk3), spk_BECH32, addr_BECH32 = getnewdestination("bech32")
self.sendtodestination(spk_P2SH_SEGWIT, 0.001)
self.sendtodestination(spk_LEGACY, 0.002)
self.sendtodestination(spk_BECH32, 0.004)
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
index fc8b639b..21ff7d09 100644
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -421,7 +421,7 @@ class MiniWallet:
def getnewdestination(address_type='bech32m'):
"""Generate a random destination of the specified type and return the
- corresponding public key, scriptPubKey and address. Supported types are
+ corresponding key pair, scriptPubKey and address. Supported types are
'legacy', 'p2sh-segwit', 'bech32' and 'bech32m'. Can be used when a random
destination is needed, but no compiled wallet is available (e.g. as
replacement to the getnewaddress/getaddressinfo RPCs)."""
@@ -442,4 +442,4 @@ def getnewdestination(address_type='bech32m'):
address = output_key_to_p2tr(pubkey)
else:
assert False
- return pubkey, scriptpubkey, address
+ return (key, pubkey), scriptpubkey, address
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.