test: use ExtendedPrivateKey in wallet_keypool.py
What changed, and why it matters
This commit only changes a single test file. It replaces hard-coded example private keys in a test script with freshly generated random keys produced by a helper class. There is no change to the actual Bitcoin Core wallet or node software, and no security vulnerability is introduced or fixed.
No action required. This is a benign test-only refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies test/functional/wallet_keypool.py. It imports ExtendedPrivateKey and descsum_create from the test framework, then replaces six literal descriptor strings containing a fixed tprv extended private key with dynamically generated descriptors using ExtendedPrivateKey.generate().to_string(). This is a test-hygiene improvement to avoid reusing a known private key across test runs; it does not touch production code.
Changed components
test/functional/wallet_keypool.pyInspect captured patch +8 / −6
diff --git a/test/functional/wallet_keypool.py b/test/functional/wallet_keypool.py
index 78c760db..7ec2d353 100755
--- a/test/functional/wallet_keypool.py
+++ b/test/functional/wallet_keypool.py
@@ -7,6 +7,8 @@
from decimal import Decimal
from test_framework.test_framework import BitcoinTestFramework
+from test_framework.descriptors import descsum_create
+from test_framework.extendedkey import ExtendedPrivateKey
from test_framework.util import (
assert_equal,
assert_not_equal,
@@ -32,39 +34,39 @@ class KeyPoolTest(BitcoinTestFramework):
nodes[0].walletpassphrase('test', 10)
nodes[0].importdescriptors([
{
- "desc": "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/0h/*h)#y4dfsj7n",
+ "desc": descsum_create(f"wpkh({ExtendedPrivateKey.generate().to_string()}/0h/*h)"),
"timestamp": "now",
"range": [0,0],
"active": True
},
{
- "desc": "pkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1h/*h)#a0nyvl0k",
+ "desc": descsum_create(f"pkh({ExtendedPrivateKey.generate().to_string()}/1h/*h)"),
"timestamp": "now",
"range": [0,0],
"active": True
},
{
- "desc": "sh(wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/2h/*h))#lmeu2axg",
+ "desc": descsum_create(f"sh(wpkh({ExtendedPrivateKey.generate().to_string()}/2h/*h))"),
"timestamp": "now",
"range": [0,0],
"active": True
},
{
- "desc": "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/3h/*h)#jkl636gm",
+ "desc": descsum_create(f"wpkh({ExtendedPrivateKey.generate().to_string()}/3h/*h)"),
"timestamp": "now",
"range": [0,0],
"active": True,
"internal": True
},
{
- "desc": "pkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/4h/*h)#l3crwaus",
+ "desc": descsum_create(f"pkh({ExtendedPrivateKey.generate().to_string()}/4h/*h)"),
"timestamp": "now",
"range": [0,0],
"active": True,
"internal": True
},
{
- "desc": "sh(wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/5h/*h))#qg8wa75f",
+ "desc": descsum_create(f"sh(wpkh({ExtendedPrivateKey.generate().to_string()}/5h/*h))"),
"timestamp": "now",
"range": [0,0],
"active": 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.