test: Test a locked wallet rejects an empty importdescriptors request
What changed, and why it matters
This commit only adds new test code to Bitcoin Core. It checks that a locked wallet refuses an empty importdescriptors request, and that an unlocked wallet accepts one. There is no change to production wallet logic, so it does not fix or introduce a security issue on its own.
No security action required; treat as normal test-coverage improvement.
Security signals we found
No production code changed
Adds regression test for locked-wallet RPC behavior
Error message references wallet passphrase requirement
Evidence from the diff
The diff extends test/functional/wallet_importdescriptors.py with two assertions: (1) an encrypted/locked wallet raises RPC error -13 when importdescriptors is called with an empty list, and (2) a blank unencrypted wallet returns an empty list for the same call. The underlying behavior already existed; this merely adds regression test coverage.
Changed components
test/functional/wallet_importdescriptors.pyInspect captured patch +9 / −0
diff --git a/test/functional/wallet_importdescriptors.py b/test/functional/wallet_importdescriptors.py
index f9429079..be6db78a 100755
--- a/test/functional/wallet_importdescriptors.py
+++ b/test/functional/wallet_importdescriptors.py
@@ -843,6 +843,15 @@ class ImportDescriptorsTest(BitcoinTestFramework):
assert_raises_rpc_error(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.",
encrypted_wallet.importdescriptors, [descriptor])
+ self.log.info("A locked wallet rejects an empty importdescriptors request")
+ assert_raises_rpc_error(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.",
+ encrypted_wallet.importdescriptors, [])
+
+ self.log.info("An unlocked wallet accepts an empty importdescriptors request")
+ self.nodes[0].createwallet("unencrypted_wallet", blank=True)
+ unencrypted_wallet = self.nodes[0].get_wallet_rpc("unencrypted_wallet")
+ assert_equal(unencrypted_wallet.importdescriptors([]), [])
+
descriptor["timestamp"] = 0
descriptor["next_index"] = 0
Why this scored 13/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.