Skip to content

Commit 100df55

Browse files
committed
f Rename OnchainSendType to OnchainSendAmount
1 parent 5b16b24 commit 100df55

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

src/payment/onchain.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::config::Config;
1111
use crate::error::Error;
1212
use crate::logger::{log_info, FilesystemLogger, Logger};
1313
use crate::types::{ChannelManager, Wallet};
14-
use crate::wallet::OnchainSendType;
14+
use crate::wallet::OnchainSendAmount;
1515

1616
use bitcoin::{Address, Txid};
1717

@@ -62,7 +62,7 @@ impl OnchainPayment {
6262
let cur_anchor_reserve_sats =
6363
crate::total_anchor_channels_reserve_sats(&self.channel_manager, &self.config);
6464
let send_amount =
65-
OnchainSendType::SendRetainingReserve { amount_sats, cur_anchor_reserve_sats };
65+
OnchainSendAmount::ExactRetainingReserve { amount_sats, cur_anchor_reserve_sats };
6666
self.wallet.send_to_address(address, send_amount)
6767
}
6868

@@ -89,9 +89,9 @@ impl OnchainPayment {
8989
let send_amount = if retain_reserves {
9090
let cur_anchor_reserve_sats =
9191
crate::total_anchor_channels_reserve_sats(&self.channel_manager, &self.config);
92-
OnchainSendType::SendAllRetainingReserve { cur_anchor_reserve_sats }
92+
OnchainSendAmount::AllRetainingReserve { cur_anchor_reserve_sats }
9393
} else {
94-
OnchainSendType::SendAllDrainingReserve
94+
OnchainSendAmount::AllDrainingReserve
9595
};
9696

9797
self.wallet.send_to_address(address, send_amount)

src/wallet/mod.rs

+16-13
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ use bitcoin::{
4545
use std::ops::Deref;
4646
use std::sync::{Arc, Mutex};
4747

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,
5252
}
5353

5454
pub(crate) mod persist;
@@ -242,7 +242,7 @@ where
242242
}
243243

244244
pub(crate) fn send_to_address(
245-
&self, address: &bitcoin::Address, send_amount: OnchainSendType,
245+
&self, address: &bitcoin::Address, send_amount: OnchainSendAmount,
246246
) -> Result<Txid, Error> {
247247
let confirmation_target = ConfirmationTarget::OnchainPayment;
248248
let fee_rate = self.fee_estimator.estimate_fee_rate(confirmation_target);
@@ -252,7 +252,7 @@ where
252252

253253
// Prepare the tx_builder. We properly check the reserve requirements (again) further down.
254254
let tx_builder = match send_amount {
255-
OnchainSendType::SendRetainingReserve { amount_sats, .. } => {
255+
OnchainSendAmount::ExactRetainingReserve { amount_sats, .. } => {
256256
let mut tx_builder = locked_wallet.build_tx();
257257
let amount = Amount::from_sat(amount_sats);
258258
tx_builder
@@ -261,7 +261,7 @@ where
261261
.enable_rbf();
262262
tx_builder
263263
},
264-
OnchainSendType::SendAllRetainingReserve { cur_anchor_reserve_sats } => {
264+
OnchainSendAmount::AllRetainingReserve { cur_anchor_reserve_sats } => {
265265
let change_address_info = locked_wallet.peek_address(KeychainKind::Internal, 0);
266266
let balance = locked_wallet.balance();
267267
let spendable_amount_sats = self
@@ -320,7 +320,7 @@ where
320320
.enable_rbf();
321321
tx_builder
322322
},
323-
OnchainSendType::SendAllDrainingReserve => {
323+
OnchainSendAmount::AllDrainingReserve => {
324324
let mut tx_builder = locked_wallet.build_tx();
325325
tx_builder
326326
.drain_wallet()
@@ -344,7 +344,10 @@ where
344344

345345
// Check the reserve requirements (again) and return an error if they aren't met.
346346
match send_amount {
347-
OnchainSendType::SendRetainingReserve { amount_sats, cur_anchor_reserve_sats } => {
347+
OnchainSendAmount::ExactRetainingReserve {
348+
amount_sats,
349+
cur_anchor_reserve_sats,
350+
} => {
348351
let balance = locked_wallet.balance();
349352
let spendable_amount_sats = self
350353
.get_balances_inner(balance, cur_anchor_reserve_sats)
@@ -371,7 +374,7 @@ where
371374
return Err(Error::InsufficientFunds);
372375
}
373376
},
374-
OnchainSendType::SendAllRetainingReserve { cur_anchor_reserve_sats } => {
377+
OnchainSendAmount::AllRetainingReserve { cur_anchor_reserve_sats } => {
375378
let balance = locked_wallet.balance();
376379
let spendable_amount_sats = self
377380
.get_balances_inner(balance, cur_anchor_reserve_sats)
@@ -420,7 +423,7 @@ where
420423
let txid = tx.compute_txid();
421424

422425
match send_amount {
423-
OnchainSendType::SendRetainingReserve { amount_sats, .. } => {
426+
OnchainSendAmount::ExactRetainingReserve { amount_sats, .. } => {
424427
log_info!(
425428
self.logger,
426429
"Created new transaction {} sending {}sats on-chain to address {}",
@@ -429,7 +432,7 @@ where
429432
address
430433
);
431434
},
432-
OnchainSendType::SendAllRetainingReserve { cur_anchor_reserve_sats } => {
435+
OnchainSendAmount::AllRetainingReserve { cur_anchor_reserve_sats } => {
433436
log_info!(
434437
self.logger,
435438
"Created new transaction {} sending available on-chain funds retaining a reserve of {}sats to address {}",
@@ -438,7 +441,7 @@ where
438441
address,
439442
);
440443
},
441-
OnchainSendType::SendAllDrainingReserve => {
444+
OnchainSendAmount::AllDrainingReserve => {
442445
log_info!(
443446
self.logger,
444447
"Created new transaction {} sending all available on-chain funds to address {}",

0 commit comments

Comments
 (0)