Skip to content

Commit 3457679

Browse files
committed
Use separate watchonly wallet for multisig in feature_nulldummy.py
Create and import the multisig into a separate watchonly wallet so that feature_nulldummy.py works with descriptor wallets. blocktools.create_raw_transaction is also updated to use multiple nodes and wallets and to use PSBT so that this test passes.
1 parent a42652e commit 3457679

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

test/functional/feature_nulldummy.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,18 @@ def skip_test_if_missing_module(self):
5151
self.skip_if_no_wallet()
5252

5353
def run_test(self):
54-
self.address = self.nodes[0].getnewaddress()
55-
self.ms_address = self.nodes[0].addmultisigaddress(1, [self.address])['address']
56-
self.wit_address = self.nodes[0].getnewaddress(address_type='p2sh-segwit')
57-
self.wit_ms_address = self.nodes[0].addmultisigaddress(1, [self.address], '', 'p2sh-segwit')['address']
54+
self.nodes[0].createwallet(wallet_name='wmulti', disable_private_keys=True)
55+
wmulti = self.nodes[0].get_wallet_rpc('wmulti')
56+
w0 = self.nodes[0].get_wallet_rpc(self.default_wallet_name)
57+
self.address = w0.getnewaddress()
58+
self.pubkey = w0.getaddressinfo(self.address)['pubkey']
59+
self.ms_address = wmulti.addmultisigaddress(1, [self.pubkey])['address']
60+
self.wit_address = w0.getnewaddress(address_type='p2sh-segwit')
61+
self.wit_ms_address = wmulti.addmultisigaddress(1, [self.pubkey], '', 'p2sh-segwit')['address']
62+
if not self.options.descriptors:
63+
# Legacy wallets need to import these so that they are watched by the wallet. This is unnecssary (and does not need to be tested) for descriptor wallets
64+
wmulti.importaddress(self.ms_address)
65+
wmulti.importaddress(self.wit_ms_address)
5866

5967
self.coinbase_blocks = self.nodes[0].generate(2) # Block 2
6068
coinbase_txid = []

test/functional/test_framework/blocktools.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,8 @@ def create_tx_with_script(prevtx, n, script_sig=b"", *, amount, script_pub_key=C
162162

163163
def create_transaction(node, txid, to_address, *, amount):
164164
""" Return signed transaction spending the first output of the
165-
input txid. Note that the node must be able to sign for the
166-
output that is being spent, and the node must not be running
167-
multiple wallets.
165+
input txid. Note that the node must have a wallet that can
166+
sign for the output that is being spent.
168167
"""
169168
raw_tx = create_raw_transaction(node, txid, to_address, amount=amount)
170169
tx = CTransaction()
@@ -173,14 +172,18 @@ def create_transaction(node, txid, to_address, *, amount):
173172

174173
def create_raw_transaction(node, txid, to_address, *, amount):
175174
""" Return raw signed transaction spending the first output of the
176-
input txid. Note that the node must be able to sign for the
177-
output that is being spent, and the node must not be running
178-
multiple wallets.
175+
input txid. Note that the node must have a wallet that can sign
176+
for the output that is being spent.
179177
"""
180-
rawtx = node.createrawtransaction(inputs=[{"txid": txid, "vout": 0}], outputs={to_address: amount})
181-
signresult = node.signrawtransactionwithwallet(rawtx)
182-
assert_equal(signresult["complete"], True)
183-
return signresult['hex']
178+
psbt = node.createpsbt(inputs=[{"txid": txid, "vout": 0}], outputs={to_address: amount})
179+
for _ in range(2):
180+
for w in node.listwallets():
181+
wrpc = node.get_wallet_rpc(w)
182+
signed_psbt = wrpc.walletprocesspsbt(psbt)
183+
psbt = signed_psbt['psbt']
184+
final_psbt = node.finalizepsbt(psbt)
185+
assert_equal(final_psbt["complete"], True)
186+
return final_psbt['hex']
184187

185188
def get_legacy_sigopcount_block(block, accurate=True):
186189
count = 0

0 commit comments

Comments
 (0)