@@ -2620,6 +2620,60 @@ fn test_bump_fee_absolute_add_input() {
2620
2620
assert_eq ! ( fee. unwrap_or( Amount :: ZERO ) , Amount :: from_sat( 6_000 ) ) ;
2621
2621
}
2622
2622
2623
+ #[ test]
2624
+ fn test_legacy_bump_fee_absolute_add_input ( ) {
2625
+ let ( mut wallet, _) = get_funded_wallet ( get_test_pkh ( ) , None ) ;
2626
+ receive_output_in_latest_block ( & mut wallet, 25_000 ) ;
2627
+ let addr = Address :: from_str ( "2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX" )
2628
+ . unwrap ( )
2629
+ . assume_checked ( ) ;
2630
+ let mut builder = wallet. build_tx ( ) . coin_selection ( LargestFirstCoinSelection ) ;
2631
+ builder. add_recipient ( addr. script_pubkey ( ) , Amount :: from_sat ( 45_000 ) ) ;
2632
+ let psbt = builder. finish ( ) . unwrap ( ) ;
2633
+ let tx = psbt. extract_tx ( ) . expect ( "failed to extract tx" ) ;
2634
+ let original_sent_received = wallet. sent_and_received ( & tx) ;
2635
+ let txid = tx. compute_txid ( ) ;
2636
+ insert_tx ( & mut wallet, tx) ;
2637
+
2638
+ let mut builder = wallet. build_fee_bump ( txid) . unwrap ( ) ;
2639
+ builder. fee_absolute ( Amount :: from_sat ( 6_000 ) ) ;
2640
+ let psbt = builder. finish ( ) . unwrap ( ) ;
2641
+ let sent_received =
2642
+ wallet. sent_and_received ( & psbt. clone ( ) . extract_tx ( ) . expect ( "failed to extract tx" ) ) ;
2643
+ let fee = check_fee ! ( wallet, psbt) ;
2644
+
2645
+ assert_eq ! (
2646
+ sent_received. 0 ,
2647
+ original_sent_received. 0 + Amount :: from_sat( 25_000 )
2648
+ ) ;
2649
+ assert_eq ! (
2650
+ fee. unwrap_or( Amount :: ZERO ) + sent_received. 1 ,
2651
+ Amount :: from_sat( 30_000 )
2652
+ ) ;
2653
+
2654
+ let tx = & psbt. unsigned_tx ;
2655
+ assert_eq ! ( tx. input. len( ) , 2 ) ;
2656
+ assert_eq ! ( tx. output. len( ) , 2 ) ;
2657
+ assert_eq ! (
2658
+ tx. output
2659
+ . iter( )
2660
+ . find( |txout| txout. script_pubkey == addr. script_pubkey( ) )
2661
+ . unwrap( )
2662
+ . value,
2663
+ Amount :: from_sat( 45_000 )
2664
+ ) ;
2665
+ assert_eq ! (
2666
+ tx. output
2667
+ . iter( )
2668
+ . find( |txout| txout. script_pubkey != addr. script_pubkey( ) )
2669
+ . unwrap( )
2670
+ . value,
2671
+ sent_received. 1
2672
+ ) ;
2673
+
2674
+ assert_eq ! ( fee. unwrap_or( Amount :: ZERO ) , Amount :: from_sat( 6_000 ) ) ;
2675
+ }
2676
+
2623
2677
#[ test]
2624
2678
fn test_bump_fee_no_change_add_input_and_change ( ) {
2625
2679
let ( mut wallet, _) = get_funded_wallet_wpkh ( ) ;
0 commit comments