Skip to content

Commit 544131f

Browse files
committed
rpc, test: test sendall spends unconfirmed change and unconfirmed inputs when specified
1 parent 65c05db commit 544131f

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/wallet/rpc/spend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ RPCHelpMan sendall()
12921292
{
12931293
return RPCHelpMan{"sendall",
12941294
"EXPERIMENTAL warning: this call may be changed in future releases.\n"
1295-
"\nSpend the value of all (or specific) confirmed UTXOs in the wallet to one or more recipients.\n"
1295+
"\nSpend the value of all (or specific) confirmed UTXOs and unconfirmed change in the wallet to one or more recipients.\n"
12961296
"Unconfirmed inbound UTXOs and locked UTXOs will not be spent. Sendall will respect the avoid_reuse wallet flag.\n"
12971297
"If your wallet contains many small inputs, either because it received tiny payments or as a result of accumulating change, consider using `send_max` to exclude inputs that are worth less than the fees needed to spend them.\n",
12981298
{

test/functional/wallet_sendall.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,27 @@ def sendall_with_maxconf(self):
379379
assert_equal(len(self.wallet.listunspent()), 1)
380380
assert_equal(self.wallet.listunspent()[0]['confirmations'], 6)
381381

382+
@cleanup
383+
def sendall_spends_unconfirmed_change(self):
384+
self.log.info("Test that sendall spends unconfirmed change")
385+
self.add_utxos([17])
386+
self.wallet.sendtoaddress(self.remainder_target, 10)
387+
assert_greater_than(self.wallet.getbalances()["mine"]["trusted"], 6)
388+
self.test_sendall_success(sendall_args = [self.remainder_target])
389+
390+
assert_equal(self.wallet.getbalance(), 0)
391+
392+
@cleanup
393+
def sendall_spends_unconfirmed_inputs_if_specified(self):
394+
self.log.info("Test that sendall spends specified unconfirmed inputs")
395+
self.def_wallet.sendtoaddress(self.wallet.getnewaddress(), 17)
396+
self.wallet.syncwithvalidationinterfacequeue()
397+
assert_equal(self.wallet.getbalances()["mine"]["untrusted_pending"], 17)
398+
unspent = self.wallet.listunspent(minconf=0)[0]
399+
400+
self.wallet.sendall(recipients=[self.remainder_target], inputs=[unspent])
401+
assert_equal(self.wallet.getbalance(), 0)
402+
382403
# This tests needs to be the last one otherwise @cleanup will fail with "Transaction too large" error
383404
def sendall_fails_with_transaction_too_large(self):
384405
self.log.info("Test that sendall fails if resulting transaction is too large")
@@ -460,6 +481,12 @@ def run_test(self):
460481
# Sendall only uses outputs with less than a given number of confirmation when using minconf
461482
self.sendall_with_maxconf()
462483

484+
# Sendall spends unconfirmed change
485+
self.sendall_spends_unconfirmed_change()
486+
487+
# Sendall spends unconfirmed inputs if they are specified
488+
self.sendall_spends_unconfirmed_inputs_if_specified()
489+
463490
# Sendall fails when many inputs result to too large transaction
464491
self.sendall_fails_with_transaction_too_large()
465492

0 commit comments

Comments
 (0)