tests: wizard: add test case for "restore from xpub"
What changed, and why it matters
This commit only adds a new automated test to Electrum's wallet creation wizard. It checks that restoring a standard wallet from an extended public key ('xpub') produces the expected Bitcoin receiving address. No production code was changed, and there is no security fix or vulnerability introduced here.
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 async unit test, test_create_standard_wallet_have_master_key, in tests/test_wizard.py. The test exercises the wizard flow for a ‘standard’ wallet whose keystore is supplied from a master key (zpub). It verifies the wizard transitions from the keystore_type view to the have_master_key view and ultimately derives the expected bech32 address (bc1qq2tmmcngng78nllq2pvrkchcdukemtj56uyue0). The change is purely additive test coverage (+16 lines).
Changed components
tests/test_wizard.pyInspect captured patch +16 / −0
diff --git a/tests/test_wizard.py b/tests/test_wizard.py
index db2bdd2..db26a50 100644
--- a/tests/test_wizard.py
+++ b/tests/test_wizard.py
@@ -337,6 +337,22 @@ class WalletWizardTestCase(WizardTestCase):
v = w.resolve_next(v.view, d)
self._set_password_and_check_address(v=v, w=w, recv_addr="bc1qgvx24uzdv4mapfmtlu8azty5fxdcw9ghxu4pr4")
+ async def test_create_standard_wallet_have_master_key(self):
+ w = self._wizard_for(wallet_type='standard')
+ v = w._current
+ d = v.wizard_data
+ self.assertEqual('keystore_type', v.view)
+
+ d.update({'keystore_type': 'masterkey'})
+ v = w.resolve_next(v.view, d)
+ self.assertEqual('have_master_key', v.view)
+
+ d.update({
+ 'master_key': 'zpub6nAZodjgiMNf9zzX1pTqd6ZVX61ax8azhUDnWRumKVUr1VYATVoqAuqv3qKsb8WJXjxei4wei2p4vnMG9RnpKnen2kmgdhvZUmug2NnHNsr',
+ 'multisig_master_pubkey': 'zpub6nAZodjgiMNf9zzX1pTqd6ZVX61ax8azhUDnWRumKVUr1VYATVoqAuqv3qKsb8WJXjxei4wei2p4vnMG9RnpKnen2kmgdhvZUmug2NnHNsr'})
+ v = w.resolve_next(v.view, d)
+ self._set_password_and_check_address(v=v, w=w, recv_addr="bc1qq2tmmcngng78nllq2pvrkchcdukemtj56uyue0")
+
async def test_create_standard_wallet_haveseed_bip39(self):
w = self._wizard_for(wallet_type='standard')
v = w._current
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.