|
5 | 5 | """Test the -alertnotify, -blocknotify and -walletnotify options."""
|
6 | 6 | import os
|
7 | 7 |
|
8 |
| -from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE, keyhash_to_p2pkh |
| 8 | +from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE |
| 9 | +from test_framework.descriptors import descsum_create |
9 | 10 | from test_framework.test_framework import BitcoinTestFramework
|
10 | 11 | from test_framework.util import (
|
11 | 12 | assert_equal,
|
12 |
| - hex_str_to_bytes, |
13 | 13 | )
|
14 | 14 |
|
15 | 15 | # Linux allow all characters other than \x00
|
@@ -49,6 +49,31 @@ def setup_network(self):
|
49 | 49 | super().setup_network()
|
50 | 50 |
|
51 | 51 | def run_test(self):
|
| 52 | + if self.is_wallet_compiled(): |
| 53 | + # Setup the descriptors to be imported to the wallet |
| 54 | + seed = "cTdGmKFWpbvpKQ7ejrdzqYT2hhjyb3GPHnLAK7wdi5Em67YLwSm9" |
| 55 | + xpriv = "tprv8ZgxMBicQKsPfHCsTwkiM1KT56RXbGGTqvc2hgqzycpwbHqqpcajQeMRZoBD35kW4RtyCemu6j34Ku5DEspmgjKdt2qe4SvRch5Kk8B8A2v" |
| 56 | + desc_imports = [{ |
| 57 | + "desc": descsum_create("wpkh(" + xpriv + "/0/*)"), |
| 58 | + "timestamp": 0, |
| 59 | + "active": True, |
| 60 | + "keypool": True, |
| 61 | + },{ |
| 62 | + "desc": descsum_create("wpkh(" + xpriv + "/1/*)"), |
| 63 | + "timestamp": 0, |
| 64 | + "active": True, |
| 65 | + "keypool": True, |
| 66 | + "internal": True, |
| 67 | + }] |
| 68 | + # Make the wallets and import the descriptors |
| 69 | + # Ensures that node 0 and node 1 share the same wallet for the conflicting transaction tests below. |
| 70 | + for i, name in enumerate(self.wallet_names): |
| 71 | + self.nodes[i].createwallet(wallet_name=name, descriptors=self.options.descriptors, blank=True, load_on_startup=True) |
| 72 | + if self.options.descriptors: |
| 73 | + self.nodes[i].importdescriptors(desc_imports) |
| 74 | + else: |
| 75 | + self.nodes[i].sethdseed(True, seed) |
| 76 | + |
52 | 77 | self.log.info("test -blocknotify")
|
53 | 78 | block_count = 10
|
54 | 79 | blocks = self.nodes[1].generatetoaddress(block_count, self.nodes[1].getnewaddress() if self.is_wallet_compiled() else ADDRESS_BCRT1_UNSPENDABLE)
|
@@ -84,11 +109,10 @@ def run_test(self):
|
84 | 109 | for tx_file in os.listdir(self.walletnotify_dir):
|
85 | 110 | os.remove(os.path.join(self.walletnotify_dir, tx_file))
|
86 | 111 |
|
87 |
| - # Conflicting transactions tests. Give node 0 same wallet seed as |
88 |
| - # node 1, generate spends from node 0, and check notifications |
| 112 | + # Conflicting transactions tests. |
| 113 | + # Generate spends from node 0, and check notifications |
89 | 114 | # triggered by node 1
|
90 | 115 | self.log.info("test -walletnotify with conflicting transactions")
|
91 |
| - self.nodes[0].sethdseed(seed=self.nodes[1].dumpprivkey(keyhash_to_p2pkh(hex_str_to_bytes(self.nodes[1].getwalletinfo()['hdseedid'])[::-1]))) |
92 | 116 | self.nodes[0].rescanblockchain()
|
93 | 117 | self.nodes[0].generatetoaddress(100, ADDRESS_BCRT1_UNSPENDABLE)
|
94 | 118 | self.sync_blocks()
|
|
0 commit comments