Skip to content

Commit 3198e42

Browse files
committed
test: check that loading descriptor wallet with legacy entries throws error
1 parent 349ed2a commit 3198e42

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/functional/wallet_descriptor.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test descriptor wallet function."""
6+
import os
7+
import sqlite3
68

79
from test_framework.blocktools import COINBASE_MATURITY
810
from test_framework.test_framework import BitcoinTestFramework
@@ -209,5 +211,15 @@ def run_test(self):
209211
imp_addr = imp_rpc.getnewaddress(address_type=addr_type)
210212
assert_equal(exp_addr, imp_addr)
211213

214+
self.log.info("Test that loading descriptor wallet containing legacy key types throws error")
215+
self.nodes[0].createwallet(wallet_name="crashme", descriptors=True)
216+
self.nodes[0].unloadwallet("crashme")
217+
wallet_db = os.path.join(self.nodes[0].datadir, self.chain, "wallets", "crashme", self.wallet_data_filename)
218+
with sqlite3.connect(wallet_db) as conn:
219+
# add "cscript" entry: key type is uint160 (20 bytes), value type is CScript (zero-length here)
220+
conn.execute('INSERT INTO main VALUES(?, ?)', (b'\x07cscript' + b'\x00'*20, b'\x00'))
221+
assert_raises_rpc_error(-4, "Unexpected legacy entry in descriptor wallet found.", self.nodes[0].loadwallet, "crashme")
222+
223+
212224
if __name__ == '__main__':
213225
WalletDescriptorTest().main ()

0 commit comments

Comments
 (0)