File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -256,11 +256,21 @@ where
256256 . enable_rbf ( ) ;
257257 } ,
258258 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+ } ) ?;
259264 let spendable_amount_sats =
260265 self . get_spendable_amount_sats ( cur_anchor_reserve_sats) . unwrap_or ( 0 ) ;
261266 let mut tmp_tx_builder = locked_wallet. build_tx ( ) ;
262267 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+ )
264274 . fee_rate ( fee_rate)
265275 . enable_rbf ( ) ;
266276 let tmp_tx_details = match tmp_tx_builder. finish ( ) {
@@ -275,8 +285,7 @@ where
275285 } ,
276286 } ;
277287
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 ) ;
280289 let estimated_spendable_amount_sats =
281290 spendable_amount_sats. saturating_sub ( estimated_tx_fee_sats) ;
282291
You can’t perform that action at this time.
0 commit comments