@@ -400,6 +400,43 @@ def sendall_spends_unconfirmed_inputs_if_specified(self):
400400 self .wallet .sendall (recipients = [self .remainder_target ], inputs = [unspent ])
401401 assert_equal (self .wallet .getbalance (), 0 )
402402
403+ @cleanup
404+ def sendall_does_ancestor_aware_funding (self ):
405+ self .log .info ("Test that sendall does ancestor aware funding for unconfirmed inputs" )
406+
407+ # higher parent feerate
408+ self .def_wallet .sendtoaddress (address = self .wallet .getnewaddress (), amount = 17 , fee_rate = 20 )
409+ self .wallet .syncwithvalidationinterfacequeue ()
410+
411+ assert_equal (self .wallet .getbalances ()["mine" ]["untrusted_pending" ], 17 )
412+ unspent = self .wallet .listunspent (minconf = 0 )[0 ]
413+
414+ parent_txid = unspent ["txid" ]
415+ assert_equal (self .wallet .gettransaction (parent_txid )["confirmations" ], 0 )
416+
417+ res_1 = self .wallet .sendall (recipients = [self .def_wallet .getnewaddress ()], inputs = [unspent ], fee_rate = 20 , add_to_wallet = False , lock_unspents = True )
418+ child_hex = res_1 ["hex" ]
419+
420+ child_tx = self .wallet .decoderawtransaction (child_hex )
421+ higher_parent_feerate_amount = child_tx ["vout" ][0 ]["value" ]
422+
423+ # lower parent feerate
424+ self .def_wallet .sendtoaddress (address = self .wallet .getnewaddress (), amount = 17 , fee_rate = 10 )
425+ self .wallet .syncwithvalidationinterfacequeue ()
426+ assert_equal (self .wallet .getbalances ()["mine" ]["untrusted_pending" ], 34 )
427+ unspent = self .wallet .listunspent (minconf = 0 )[0 ]
428+
429+ parent_txid = unspent ["txid" ]
430+ assert_equal (self .wallet .gettransaction (parent_txid )["confirmations" ], 0 )
431+
432+ res_2 = self .wallet .sendall (recipients = [self .def_wallet .getnewaddress ()], inputs = [unspent ], fee_rate = 20 , add_to_wallet = False , lock_unspents = True )
433+ child_hex = res_2 ["hex" ]
434+
435+ child_tx = self .wallet .decoderawtransaction (child_hex )
436+ lower_parent_feerate_amount = child_tx ["vout" ][0 ]["value" ]
437+
438+ assert_greater_than (higher_parent_feerate_amount , lower_parent_feerate_amount )
439+
403440 # This tests needs to be the last one otherwise @cleanup will fail with "Transaction too large" error
404441 def sendall_fails_with_transaction_too_large (self ):
405442 self .log .info ("Test that sendall fails if resulting transaction is too large" )
@@ -487,6 +524,9 @@ def run_test(self):
487524 # Sendall spends unconfirmed inputs if they are specified
488525 self .sendall_spends_unconfirmed_inputs_if_specified ()
489526
527+ # Sendall does ancestor aware funding when spending an unconfirmed UTXO
528+ self .sendall_does_ancestor_aware_funding ()
529+
490530 # Sendall fails when many inputs result to too large transaction
491531 self .sendall_fails_with_transaction_too_large ()
492532
0 commit comments