test: use ExtendedPrivateKey in wallet_createwallet.py
What changed, and why it matters
This is a minor test-only cleanup. It replaces a hardcoded example private key in a Bitcoin Core functional test with a freshly generated one using a test helper. There is no change to production wallet code, no security fix, and no vulnerability.
No action required. This is a benign test refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies test/functional/wallet_createwallet.py to import ExtendedPrivateKey from test_framework.extendedkey and use ExtendedPrivateKey.generate().to_string() instead of a literal tprv… extended private key when constructing descriptor strings for importdescriptors. The previous hardcoded key was presumably a known test vector; the new approach generates a random key per test run. This is purely a test-code hygiene change.
Changed components
test/functional/wallet_createwallet.pyInspect captured patch +5 / −4
diff --git a/test/functional/wallet_createwallet.py b/test/functional/wallet_createwallet.py
index bb7918a9..60f670de 100755
--- a/test/functional/wallet_createwallet.py
+++ b/test/functional/wallet_createwallet.py
@@ -8,6 +8,7 @@ import os
import stat
from test_framework.descriptors import descsum_create
+from test_framework.extendedkey import ExtendedPrivateKey
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
@@ -97,12 +98,12 @@ class CreateWalletTest(BitcoinTestFramework):
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w3.getnewaddress)
# Set the seed
w3.importdescriptors([{
- 'desc': descsum_create('wpkh(tprv8ZgxMBicQKsPcwuZGKp8TeWppSuLMiLe2d9PupB14QpPeQsqoj3LneJLhGHH13xESfvASyd4EFLJvLrG8b7DrLxEuV7hpF9uUc6XruKA1Wq/0h/*)'),
+ 'desc': descsum_create(f'wpkh({ExtendedPrivateKey.generate().to_string()}/0h/*)'),
'timestamp': 'now',
'active': True
},
{
- 'desc': descsum_create('wpkh(tprv8ZgxMBicQKsPcwuZGKp8TeWppSuLMiLe2d9PupB14QpPeQsqoj3LneJLhGHH13xESfvASyd4EFLJvLrG8b7DrLxEuV7hpF9uUc6XruKA1Wq/1h/*)'),
+ 'desc': descsum_create(f'wpkh({ExtendedPrivateKey.generate().to_string()}/1h/*)'),
'timestamp': 'now',
'active': True,
'internal': True
@@ -124,12 +125,12 @@ class CreateWalletTest(BitcoinTestFramework):
with WalletUnlock(w4, "pass"):
# Now set a seed and it should work. Wallet should also be encrypted
w4.importdescriptors([{
- 'desc': descsum_create('wpkh(tprv8ZgxMBicQKsPcwuZGKp8TeWppSuLMiLe2d9PupB14QpPeQsqoj3LneJLhGHH13xESfvASyd4EFLJvLrG8b7DrLxEuV7hpF9uUc6XruKA1Wq/0h/*)'),
+ 'desc': descsum_create(f'wpkh({ExtendedPrivateKey.generate().to_string()}/0h/*)'),
'timestamp': 'now',
'active': True
},
{
- 'desc': descsum_create('wpkh(tprv8ZgxMBicQKsPcwuZGKp8TeWppSuLMiLe2d9PupB14QpPeQsqoj3LneJLhGHH13xESfvASyd4EFLJvLrG8b7DrLxEuV7hpF9uUc6XruKA1Wq/1h/*)'),
+ 'desc': descsum_create(f'wpkh({ExtendedPrivateKey.generate().to_string()}/1h/*)'),
'timestamp': 'now',
'active': True,
'internal': 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.