Skip to content

Commit 7c71c62

Browse files
committed
Setup wallets with descriptors for feature_notifications
1 parent 1f1bef8 commit 7c71c62

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

test/functional/feature_notifications.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
"""Test the -alertnotify, -blocknotify and -walletnotify options."""
66
import os
77

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
910
from test_framework.test_framework import BitcoinTestFramework
1011
from test_framework.util import (
1112
assert_equal,
12-
hex_str_to_bytes,
1313
)
1414

1515
# Linux allow all characters other than \x00
@@ -49,6 +49,31 @@ def setup_network(self):
4949
super().setup_network()
5050

5151
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+
5277
self.log.info("test -blocknotify")
5378
block_count = 10
5479
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):
84109
for tx_file in os.listdir(self.walletnotify_dir):
85110
os.remove(os.path.join(self.walletnotify_dir, tx_file))
86111

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
89114
# triggered by node 1
90115
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])))
92116
self.nodes[0].rescanblockchain()
93117
self.nodes[0].generatetoaddress(100, ADDRESS_BCRT1_UNSPENDABLE)
94118
self.sync_blocks()

0 commit comments

Comments
 (0)