Skip to content

Commit 708b72b

Browse files
committed
test: Test that sendall works with watchonly spending specific utxos
1 parent 6bcd7e2 commit 708b72b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/functional/wallet_sendall.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,33 @@ def sendall_fails_on_high_fee(self):
276276
recipients=[self.remainder_target],
277277
fee_rate=100000)
278278

279+
@cleanup
280+
def sendall_watchonly_specific_inputs(self):
281+
self.log.info("Test sendall with a subset of UTXO pool in a watchonly wallet")
282+
self.add_utxos([17, 4])
283+
utxo = self.wallet.listunspent()[0]
284+
285+
self.nodes[0].createwallet(wallet_name="watching", disable_private_keys=True)
286+
watchonly = self.nodes[0].get_wallet_rpc("watching")
287+
288+
import_req = [{
289+
"desc": utxo["desc"],
290+
"timestamp": 0,
291+
}]
292+
if self.options.descriptors:
293+
watchonly.importdescriptors(import_req)
294+
else:
295+
watchonly.importmulti(import_req)
296+
297+
sendall_tx_receipt = watchonly.sendall(recipients=[self.remainder_target], options={"inputs": [utxo]})
298+
psbt = sendall_tx_receipt["psbt"]
299+
decoded = self.nodes[0].decodepsbt(psbt)
300+
assert_equal(len(decoded["inputs"]), 1)
301+
assert_equal(len(decoded["outputs"]), 1)
302+
assert_equal(decoded["tx"]["vin"][0]["txid"], utxo["txid"])
303+
assert_equal(decoded["tx"]["vin"][0]["vout"], utxo["vout"])
304+
assert_equal(decoded["tx"]["vout"][0]["scriptPubKey"]["address"], self.remainder_target)
305+
279306
# This tests needs to be the last one otherwise @cleanup will fail with "Transaction too large" error
280307
def sendall_fails_with_transaction_too_large(self):
281308
self.log.info("Test that sendall fails if resulting transaction is too large")
@@ -341,6 +368,9 @@ def run_test(self):
341368
# Sendall fails when providing a fee that is too high
342369
self.sendall_fails_on_high_fee()
343370

371+
# Sendall succeeds with watchonly wallets spending specific UTXOs
372+
self.sendall_watchonly_specific_inputs()
373+
344374
# Sendall fails when many inputs result to too large transaction
345375
self.sendall_fails_with_transaction_too_large()
346376

0 commit comments

Comments
 (0)