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