@@ -45,10 +45,10 @@ use bitcoin::{
45
45
use std:: ops:: Deref ;
46
46
use std:: sync:: { Arc , Mutex } ;
47
47
48
- pub ( crate ) enum OnchainSendType {
49
- SendRetainingReserve { amount_sats : u64 , cur_anchor_reserve_sats : u64 } ,
50
- SendAllRetainingReserve { cur_anchor_reserve_sats : u64 } ,
51
- SendAllDrainingReserve ,
48
+ pub ( crate ) enum OnchainSendAmount {
49
+ ExactRetainingReserve { amount_sats : u64 , cur_anchor_reserve_sats : u64 } ,
50
+ AllRetainingReserve { cur_anchor_reserve_sats : u64 } ,
51
+ AllDrainingReserve ,
52
52
}
53
53
54
54
pub ( crate ) mod persist;
@@ -242,7 +242,7 @@ where
242
242
}
243
243
244
244
pub ( crate ) fn send_to_address (
245
- & self , address : & bitcoin:: Address , send_amount : OnchainSendType ,
245
+ & self , address : & bitcoin:: Address , send_amount : OnchainSendAmount ,
246
246
) -> Result < Txid , Error > {
247
247
let confirmation_target = ConfirmationTarget :: OnchainPayment ;
248
248
let fee_rate = self . fee_estimator . estimate_fee_rate ( confirmation_target) ;
@@ -252,7 +252,7 @@ where
252
252
253
253
// Prepare the tx_builder. We properly check the reserve requirements (again) further down.
254
254
let tx_builder = match send_amount {
255
- OnchainSendType :: SendRetainingReserve { amount_sats, .. } => {
255
+ OnchainSendAmount :: ExactRetainingReserve { amount_sats, .. } => {
256
256
let mut tx_builder = locked_wallet. build_tx ( ) ;
257
257
let amount = Amount :: from_sat ( amount_sats) ;
258
258
tx_builder
@@ -261,7 +261,7 @@ where
261
261
. enable_rbf ( ) ;
262
262
tx_builder
263
263
} ,
264
- OnchainSendType :: SendAllRetainingReserve { cur_anchor_reserve_sats } => {
264
+ OnchainSendAmount :: AllRetainingReserve { cur_anchor_reserve_sats } => {
265
265
let change_address_info = locked_wallet. peek_address ( KeychainKind :: Internal , 0 ) ;
266
266
let balance = locked_wallet. balance ( ) ;
267
267
let spendable_amount_sats = self
@@ -320,7 +320,7 @@ where
320
320
. enable_rbf ( ) ;
321
321
tx_builder
322
322
} ,
323
- OnchainSendType :: SendAllDrainingReserve => {
323
+ OnchainSendAmount :: AllDrainingReserve => {
324
324
let mut tx_builder = locked_wallet. build_tx ( ) ;
325
325
tx_builder
326
326
. drain_wallet ( )
@@ -344,7 +344,10 @@ where
344
344
345
345
// Check the reserve requirements (again) and return an error if they aren't met.
346
346
match send_amount {
347
- OnchainSendType :: SendRetainingReserve { amount_sats, cur_anchor_reserve_sats } => {
347
+ OnchainSendAmount :: ExactRetainingReserve {
348
+ amount_sats,
349
+ cur_anchor_reserve_sats,
350
+ } => {
348
351
let balance = locked_wallet. balance ( ) ;
349
352
let spendable_amount_sats = self
350
353
. get_balances_inner ( balance, cur_anchor_reserve_sats)
@@ -371,7 +374,7 @@ where
371
374
return Err ( Error :: InsufficientFunds ) ;
372
375
}
373
376
} ,
374
- OnchainSendType :: SendAllRetainingReserve { cur_anchor_reserve_sats } => {
377
+ OnchainSendAmount :: AllRetainingReserve { cur_anchor_reserve_sats } => {
375
378
let balance = locked_wallet. balance ( ) ;
376
379
let spendable_amount_sats = self
377
380
. get_balances_inner ( balance, cur_anchor_reserve_sats)
@@ -420,7 +423,7 @@ where
420
423
let txid = tx. compute_txid ( ) ;
421
424
422
425
match send_amount {
423
- OnchainSendType :: SendRetainingReserve { amount_sats, .. } => {
426
+ OnchainSendAmount :: ExactRetainingReserve { amount_sats, .. } => {
424
427
log_info ! (
425
428
self . logger,
426
429
"Created new transaction {} sending {}sats on-chain to address {}" ,
@@ -429,7 +432,7 @@ where
429
432
address
430
433
) ;
431
434
} ,
432
- OnchainSendType :: SendAllRetainingReserve { cur_anchor_reserve_sats } => {
435
+ OnchainSendAmount :: AllRetainingReserve { cur_anchor_reserve_sats } => {
433
436
log_info ! (
434
437
self . logger,
435
438
"Created new transaction {} sending available on-chain funds retaining a reserve of {}sats to address {}" ,
@@ -438,7 +441,7 @@ where
438
441
address,
439
442
) ;
440
443
} ,
441
- OnchainSendType :: SendAllDrainingReserve => {
444
+ OnchainSendAmount :: AllDrainingReserve => {
442
445
log_info ! (
443
446
self . logger,
444
447
"Created new transaction {} sending all available on-chain funds to address {}" ,
0 commit comments