File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -256,11 +256,21 @@ where
256
256
. enable_rbf ( ) ;
257
257
} ,
258
258
OnchainSendType :: SendAllRetainingReserve { cur_anchor_reserve_sats } => {
259
+ let change_address_info =
260
+ locked_wallet. get_internal_address ( AddressIndex :: Peek ( 0 ) ) . map_err ( |e| {
261
+ log_error ! ( self . logger, "Unable to retrieve address: {}" , e) ;
262
+ e
263
+ } ) ?;
259
264
let spendable_amount_sats =
260
265
self . get_spendable_amount_sats ( cur_anchor_reserve_sats) . unwrap_or ( 0 ) ;
261
266
let mut tmp_tx_builder = locked_wallet. build_tx ( ) ;
262
267
tmp_tx_builder
263
- . add_recipient ( address. script_pubkey ( ) , spendable_amount_sats)
268
+ . drain_wallet ( )
269
+ . drain_to ( address. script_pubkey ( ) )
270
+ . add_recipient (
271
+ change_address_info. address . script_pubkey ( ) ,
272
+ cur_anchor_reserve_sats,
273
+ )
264
274
. fee_rate ( fee_rate)
265
275
. enable_rbf ( ) ;
266
276
let tmp_tx_details = match tmp_tx_builder. finish ( ) {
@@ -275,8 +285,7 @@ where
275
285
} ,
276
286
} ;
277
287
278
- let estimated_tx_fee_sats =
279
- tmp_tx_details. fee . unwrap_or ( 0 ) . max ( FEERATE_FLOOR_SATS_PER_KW as u64 ) ;
288
+ let estimated_tx_fee_sats = tmp_tx_details. fee . unwrap_or ( 0 ) ;
280
289
let estimated_spendable_amount_sats =
281
290
spendable_amount_sats. saturating_sub ( estimated_tx_fee_sats) ;
282
291
You can’t perform that action at this time.
0 commit comments