This PR is a follow-up of [PR #35543](https://github.com/bitcoin/bitcoin/pull/35543).
I've updated the tests that were still using hardcoded keys, and used the ExtendedKey classes instead.
test: Replace hardcoded extended keys with ExtendedKey helpers #36710
pull nebula-21 wants to merge 1 commits into bitcoin:master from nebula-21:replace-hardcoded-keys changing 10 files +42 −39-
nebula-21 commented at 3:35 PM on October 30, 2026: contributor
- DrahtBot added the label Tests on Oct 30, 2026
-
DrahtBot commented at 3:35 PM on October 30, 2026: contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
External sites
- Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36710
- Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36710.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36710#author-ralph
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline and AI policy for information on the review process.
Type Reviewers ACK polespinasa If your review is incorrectly listed, please copy-paste <code><!--meta-tag:bot-skip--></code> into the comment that the bot should ignore.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #36990 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36990.svg"></sub> (test: replace hard-coded RPC error codes by l0rinc)
- #36885 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36885.svg"></sub> (wallet, rpc: Add analyzedescriptor for multisig setups by pablomartin4btc)
- #36005 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36005.svg"></sub> (rpc, descriptor: warn when multipath expansion clones single-path key expressions by pythcoiner)
- #32468 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/32468.svg"></sub> (rpc: generateblock to allow multiple outputs with custom payouts by polespinasa)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
- DrahtBot added the label Needs rebase on Oct 31, 2026
- nebula-21 force-pushed on Nov 3, 2026
- nebula-21 marked this as a draft on Nov 3, 2026
- nebula-21 marked this as ready for review on Nov 3, 2026
- DrahtBot removed the label Needs rebase on Nov 3, 2026
-
in test/functional/wallet_miniscript.py:15 in f805f095fd
24 | - "tpubD6NzVbkrYhZ4WsqRzDmkL82SWcu42JzUvKWzrJHQ8EC2vEHRHkXj1De93sD3biLrKd8XGnamXURGjMbYavbszVDXpjXV2cGUERucLJkE6cy", 25 | - "tpubDEFLeBkKTm8aiYkySz8hXAXPVnPSfxMi7Fxhg9sejUrkwJuRWvPdLEiXjTDbhGbjLKCZUDUUibLxTnK5UP1q7qYrSnPqnNe7M8mvAW1STcc", 26 | - "tpubD6NzVbkrYhZ4WR99ygpiJvPMAJiwahjLgGywc5vJx2gUfKUfEPCrbKmQczDPJZmLcyZzRb5Ti6rfUb89S2WFyPH7FDtD6RFDA1hdgTEgEUL", 27 | -] 28 | +TPRVS = [ExtendedPrivateKey.generate().to_string() for _ in range(0, 3)] 29 | +TPUBS = [ExtendedPrivateKey.generate().pubkey().to_string() for _ in range(0, 7)]
polespinasa commented at 6:15 PM on November 4, 2026:in f805f095fd8c8e2b4b7a46490069b5dfa8751586 test: Replace hardcoded extended keys with ExtendedKey helpers
If I am not wrong this can cause some problems when running the test framework with
--randomseed=. As same seed could produce different results, making errors non reproducible. This is because the seed is not applied into the rng before you call a function.A solution to this would be to not use an rng for this test and hardcode some value. For example:
$ git diff diff --git a/test/functional/wallet_miniscript.py b/test/functional/wallet_miniscript.py index 6daf21b9b3..a6d9cb6843 100755 --- a/test/functional/wallet_miniscript.py +++ b/test/functional/wallet_miniscript.py @@ -10,9 +10,8 @@ from test_framework.psbt import PSBT, PSBT_IN_SHA256 from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal -TPRVS = [ExtendedPrivateKey.generate().to_string() for _ in range(0, 3)] -TPUBS = [ExtendedPrivateKey.generate().pubkey().to_string() for _ in range(0, 7)] +TPRVS = [ExtendedPrivateKey.from_seed(f"miniscript-private-{i}".encode()).to_string() for i in range(3)] +TPUBS = [ExtendedPrivateKey.from_seed(f"miniscript-public-{i}".encode()).pubkey().to_string() for i in range(7)] PUBKEYS = [ "02aebf2d10b040eb936a6f02f44ee82f8b34f5c1ccb20ff3949c2b28206b7c1068", "030f64b922aee2fd597f104bc6cb3b670f1ca2c6c49b1071a1a6c010575d94fe5a",polespinasa commented at 6:15 PM on November 4, 2026: membercACK
test: Replace hardcoded extended keys with ExtendedKey helpers 174adf559dnebula-21 force-pushed on Nov 13, 2026nebula-21 commented at 5:08 PM on November 13, 2026: contributor@polespinasa took you suggestion, I was also thinking about generating the keys inside
run_test()instead so the seed would cover them, but that would require a bigger restructuring and maybe not worth it.in test/functional/rpc_psbt.py:16 in 174adf559d
12 | @@ -13,7 +13,7 @@ 13 | MAX_STANDARD_TX_WEIGHT, 14 | ) 15 | from test_framework.descriptors import descsum_create 16 | -from test_framework.extendedkey import hardened 17 | +from test_framework.extendedkey import ExtendedPrivateKey, hardened
polespinasa commented at 8:17 PM on November 25, 2026:nit: this import should go in multiple lines. See https://github.com/bitcoin/bitcoin/tree/master/test/functional#style-guidelines
polespinasa commented at 8:18 PM on November 25, 2026: memberACK 174adf559d8f1852c9362bcbecb0f16c45b2496a
ContributorsLabels
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-12-01 03:51 UTC
More mirrored repositories can be found on mirror.b10c.me