mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
rpc, test: test sendall spends unconfirmed change and unconfirmed inputs when specified
This commit is contained in:
parent
65c05db660
commit
544131f3fb
2 changed files with 28 additions and 1 deletions
|
@ -1292,7 +1292,7 @@ RPCHelpMan sendall()
|
|||
{
|
||||
return RPCHelpMan{"sendall",
|
||||
"EXPERIMENTAL warning: this call may be changed in future releases.\n"
|
||||
"\nSpend the value of all (or specific) confirmed UTXOs in the wallet to one or more recipients.\n"
|
||||
"\nSpend the value of all (or specific) confirmed UTXOs and unconfirmed change in the wallet to one or more recipients.\n"
|
||||
"Unconfirmed inbound UTXOs and locked UTXOs will not be spent. Sendall will respect the avoid_reuse wallet flag.\n"
|
||||
"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",
|
||||
{
|
||||
|
|
|
@ -379,6 +379,27 @@ class SendallTest(BitcoinTestFramework):
|
|||
assert_equal(len(self.wallet.listunspent()), 1)
|
||||
assert_equal(self.wallet.listunspent()[0]['confirmations'], 6)
|
||||
|
||||
@cleanup
|
||||
def sendall_spends_unconfirmed_change(self):
|
||||
self.log.info("Test that sendall spends unconfirmed change")
|
||||
self.add_utxos([17])
|
||||
self.wallet.sendtoaddress(self.remainder_target, 10)
|
||||
assert_greater_than(self.wallet.getbalances()["mine"]["trusted"], 6)
|
||||
self.test_sendall_success(sendall_args = [self.remainder_target])
|
||||
|
||||
assert_equal(self.wallet.getbalance(), 0)
|
||||
|
||||
@cleanup
|
||||
def sendall_spends_unconfirmed_inputs_if_specified(self):
|
||||
self.log.info("Test that sendall spends specified unconfirmed inputs")
|
||||
self.def_wallet.sendtoaddress(self.wallet.getnewaddress(), 17)
|
||||
self.wallet.syncwithvalidationinterfacequeue()
|
||||
assert_equal(self.wallet.getbalances()["mine"]["untrusted_pending"], 17)
|
||||
unspent = self.wallet.listunspent(minconf=0)[0]
|
||||
|
||||
self.wallet.sendall(recipients=[self.remainder_target], inputs=[unspent])
|
||||
assert_equal(self.wallet.getbalance(), 0)
|
||||
|
||||
# This tests needs to be the last one otherwise @cleanup will fail with "Transaction too large" error
|
||||
def sendall_fails_with_transaction_too_large(self):
|
||||
self.log.info("Test that sendall fails if resulting transaction is too large")
|
||||
|
@ -460,6 +481,12 @@ class SendallTest(BitcoinTestFramework):
|
|||
# Sendall only uses outputs with less than a given number of confirmation when using minconf
|
||||
self.sendall_with_maxconf()
|
||||
|
||||
# Sendall spends unconfirmed change
|
||||
self.sendall_spends_unconfirmed_change()
|
||||
|
||||
# Sendall spends unconfirmed inputs if they are specified
|
||||
self.sendall_spends_unconfirmed_inputs_if_specified()
|
||||
|
||||
# Sendall fails when many inputs result to too large transaction
|
||||
self.sendall_fails_with_transaction_too_large()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue