test: add coverage for importdescriptor with an encrypted wallet
What changed, and why it matters
This commit only adds a new test case to Bitcoin Core's test suite. It checks that trying to import a wallet descriptor into an encrypted wallet fails with a helpful error message when the wallet is still locked. There is no change to production wallet code, no bug fix, and no security vulnerability being addressed.
No action required. This is a benign test-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a single assertion in test/functional/wallet_importdescriptors.py. After creating an encrypted blank wallet, the test now verifies that importdescriptors raises RPC error -13 (‘Please enter the wallet passphrase with walletpassphrase first.’) before the wallet is unlocked. This is purely test-coverage expansion for existing behavior.
Changed components
test/functional/wallet_importdescriptors.pyInspect captured patch +4 / −0
diff --git a/test/functional/wallet_importdescriptors.py b/test/functional/wallet_importdescriptors.py
index 9a3a1802..692d042a 100755
--- a/test/functional/wallet_importdescriptors.py
+++ b/test/functional/wallet_importdescriptors.py
@@ -762,6 +762,10 @@ class ImportDescriptorsTest(BitcoinTestFramework):
self.nodes[0].createwallet("encrypted_wallet", blank=True, passphrase="passphrase")
encrypted_wallet = self.nodes[0].get_wallet_rpc("encrypted_wallet")
+ self.log.info("Wallet must be unlocked to import a descriptor")
+ assert_raises_rpc_error(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.",
+ encrypted_wallet.importdescriptors, [descriptor])
+
descriptor["timestamp"] = 0
descriptor["next_index"] = 0
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.