@@ -2308,6 +2308,62 @@ fn test_bump_fee_drain_wallet() {
2308
2308
assert_eq ! ( sent_received. 0 , Amount :: from_sat( 75_000 ) ) ;
2309
2309
}
2310
2310
2311
+ #[ test]
2312
+ fn test_legacy_bump_fee_drain_wallet ( ) {
2313
+ let ( mut wallet, _) = get_funded_wallet ( get_test_pkh ( ) , None ) ;
2314
+ // receive an extra tx so that our wallet has two utxos.
2315
+ let tx = Transaction {
2316
+ version : transaction:: Version :: ONE ,
2317
+ lock_time : absolute:: LockTime :: ZERO ,
2318
+ input : vec ! [ ] ,
2319
+ output : vec ! [ TxOut {
2320
+ value: Amount :: from_sat( 25_000 ) ,
2321
+ script_pubkey: wallet
2322
+ . next_unused_address( KeychainKind :: External )
2323
+ . script_pubkey( ) ,
2324
+ } ] ,
2325
+ } ;
2326
+ let txid = tx. compute_txid ( ) ;
2327
+ insert_tx ( & mut wallet, tx. clone ( ) ) ;
2328
+ let anchor = ConfirmationBlockTime {
2329
+ block_id : wallet. latest_checkpoint ( ) . block_id ( ) ,
2330
+ confirmation_time : 42_000 ,
2331
+ } ;
2332
+ insert_anchor ( & mut wallet, txid, anchor) ;
2333
+
2334
+ let addr = Address :: from_str ( "2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX" )
2335
+ . unwrap ( )
2336
+ . assume_checked ( ) ;
2337
+
2338
+ let mut builder = wallet. build_tx ( ) ;
2339
+ builder
2340
+ . drain_to ( addr. script_pubkey ( ) )
2341
+ . add_utxo ( OutPoint {
2342
+ txid : tx. compute_txid ( ) ,
2343
+ vout : 0 ,
2344
+ } )
2345
+ . unwrap ( )
2346
+ . manually_selected_only ( ) ;
2347
+ let psbt = builder. finish ( ) . unwrap ( ) ;
2348
+ let tx = psbt. extract_tx ( ) . expect ( "failed to extract tx" ) ;
2349
+ let original_sent_received = wallet. sent_and_received ( & tx) ;
2350
+
2351
+ let txid = tx. compute_txid ( ) ;
2352
+ insert_tx ( & mut wallet, tx) ;
2353
+ assert_eq ! ( original_sent_received. 0 , Amount :: from_sat( 25_000 ) ) ;
2354
+
2355
+ // for the new feerate, it should be enough to reduce the output, but since we specify
2356
+ // `drain_wallet` we expect to spend everything
2357
+ let mut builder = wallet. build_fee_bump ( txid) . unwrap ( ) ;
2358
+ builder
2359
+ . drain_wallet ( )
2360
+ . fee_rate ( FeeRate :: from_sat_per_vb_unchecked ( 5 ) ) ;
2361
+ let psbt = builder. finish ( ) . unwrap ( ) ;
2362
+ let sent_received = wallet. sent_and_received ( & psbt. extract_tx ( ) . expect ( "failed to extract tx" ) ) ;
2363
+
2364
+ assert_eq ! ( sent_received. 0 , Amount :: from_sat( 75_000 ) ) ;
2365
+ }
2366
+
2311
2367
#[ test]
2312
2368
#[ should_panic( expected = "InsufficientFunds" ) ]
2313
2369
fn test_bump_fee_remove_output_manually_selected_only ( ) {
0 commit comments