|
3 | 3 | # Distributed under the MIT software license, see the accompanying |
4 | 4 | # file COPYING or http://www.opensource.org/licenses/mit-license.php. |
5 | 5 | """Test descriptor wallet function.""" |
| 6 | +import os |
| 7 | +import sqlite3 |
6 | 8 |
|
7 | 9 | from test_framework.blocktools import COINBASE_MATURITY |
8 | 10 | from test_framework.test_framework import BitcoinTestFramework |
@@ -209,5 +211,15 @@ def run_test(self): |
209 | 211 | imp_addr = imp_rpc.getnewaddress(address_type=addr_type) |
210 | 212 | assert_equal(exp_addr, imp_addr) |
211 | 213 |
|
| 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 | + |
212 | 224 | if __name__ == '__main__': |
213 | 225 | WalletDescriptorTest().main () |
0 commit comments