@@ -400,6 +400,43 @@ def sendall_spends_unconfirmed_inputs_if_specified(self):
400
400
self .wallet .sendall (recipients = [self .remainder_target ], inputs = [unspent ])
401
401
assert_equal (self .wallet .getbalance (), 0 )
402
402
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
+
403
440
# This tests needs to be the last one otherwise @cleanup will fail with "Transaction too large" error
404
441
def sendall_fails_with_transaction_too_large (self ):
405
442
self .log .info ("Test that sendall fails if resulting transaction is too large" )
@@ -487,6 +524,9 @@ def run_test(self):
487
524
# Sendall spends unconfirmed inputs if they are specified
488
525
self .sendall_spends_unconfirmed_inputs_if_specified ()
489
526
527
+ # Sendall does ancestor aware funding when spending an unconfirmed UTXO
528
+ self .sendall_does_ancestor_aware_funding ()
529
+
490
530
# Sendall fails when many inputs result to too large transaction
491
531
self .sendall_fails_with_transaction_too_large ()
492
532
0 commit comments