Skip to content

Commit a8f3f61

Browse files
committed
fix: do not reset seed / mnemonic for descriptor wallets in case of encryption
1 parent 5b4db62 commit a8f3f61

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
724724

725725
// If we are using descriptors, make new descriptors with a new seed
726726
if (IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS) && !IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET)) {
727-
SetupDescriptorScriptPubKeyMans("", "");
727+
// Do nothing for descriptor wallets (keep old seed / mnemonic)
728728
} else if (auto spk_man = GetLegacyScriptPubKeyMan()) {
729729
// if we are not using HD, generate new keypool
730730
if (spk_man->IsHDEnabled()) {

test/functional/wallet_descriptor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def run_test(self):
9191
send_wrpc.walletpassphrase('pass', 10)
9292
addr = send_wrpc.getnewaddress()
9393
info2 = send_wrpc.getaddressinfo(addr)
94-
assert info1['hdmasterfingerprint'] != info2['hdmasterfingerprint']
94+
assert info1['hdmasterfingerprint'] == info2['hdmasterfingerprint']
9595
send_wrpc.walletlock()
9696
assert 'hdmasterfingerprint' in send_wrpc.getaddressinfo(send_wrpc.getnewaddress())
9797
info3 = send_wrpc.getaddressinfo(addr)

test/functional/wallet_mnemonicbits.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,14 @@ def run_test(self):
4646
mnemonic_count += 1
4747
if desc['mnemonic'] == mnemonic_pre:
4848
found_in_encrypted += 1
49-
assert not desc['active']
50-
else:
5149
assert desc['active']
5250
# there should 5 descriptors in total
5351
# one of them imported private key for coinbase without mnemonic
5452
# encryption of descriptor wallet creates new private keys,
5553
# it should be 2 active and 2 inactive mnemonics
5654
assert_equal(found_in_encrypted, 2)
57-
assert_equal(mnemonic_count, 4)
58-
assert_equal(len(descriptors), 5)
55+
assert_equal(mnemonic_count, 2)
56+
assert_equal(len(descriptors), 3)
5957
else:
6058
assert_equal(len(self.nodes[0].dumphdinfo()["mnemonic"].split()), 12) # 12 words by default
6159
# legacy HD wallets could have only one chain

0 commit comments

Comments
 (0)