File tree Expand file tree Collapse file tree 4 files changed +9
-4
lines changed Expand file tree Collapse file tree 4 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -835,8 +835,7 @@ where
835
835
) ;
836
836
let spendable_amount_sats = self
837
837
. wallet
838
- . get_balances ( cur_anchor_reserve_sats)
839
- . map ( |( _, s) | s)
838
+ . get_spendable_amount_sats ( cur_anchor_reserve_sats)
840
839
. unwrap_or ( 0 ) ;
841
840
842
841
let required_amount_sats = if anchor_channels_config
Original file line number Diff line number Diff line change @@ -1030,7 +1030,7 @@ impl Node {
1030
1030
let cur_anchor_reserve_sats =
1031
1031
total_anchor_channels_reserve_sats ( & self . channel_manager , & self . config ) ;
1032
1032
let spendable_amount_sats =
1033
- self . wallet . get_balances ( cur_anchor_reserve_sats) . map ( | ( _ , s ) | s ) . unwrap_or ( 0 ) ;
1033
+ self . wallet . get_spendable_amount_sats ( cur_anchor_reserve_sats) . unwrap_or ( 0 ) ;
1034
1034
1035
1035
// Fail early if we have less than the channel value available.
1036
1036
if spendable_amount_sats < channel_amount_sats {
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ impl OnchainPayment {
54
54
let cur_anchor_reserve_sats =
55
55
crate :: total_anchor_channels_reserve_sats ( & self . channel_manager , & self . config ) ;
56
56
let spendable_amount_sats =
57
- self . wallet . get_balances ( cur_anchor_reserve_sats) . map ( | ( _ , s ) | s ) . unwrap_or ( 0 ) ;
57
+ self . wallet . get_spendable_amount_sats ( cur_anchor_reserve_sats) . unwrap_or ( 0 ) ;
58
58
59
59
if spendable_amount_sats < amount_sats {
60
60
log_error ! ( self . logger,
Original file line number Diff line number Diff line change @@ -179,6 +179,12 @@ where
179
179
Ok ( ( total, spendable) )
180
180
}
181
181
182
+ pub ( crate ) fn get_spendable_amount_sats (
183
+ & self , total_anchor_channels_reserve_sats : u64 ,
184
+ ) -> Result < u64 , Error > {
185
+ self . get_balances ( total_anchor_channels_reserve_sats) . map ( |( _, s) | s)
186
+ }
187
+
182
188
/// Send funds to the given address.
183
189
///
184
190
/// If `amount_msat_or_drain` is `None` the wallet will be drained, i.e., all available funds will be
You can’t perform that action at this time.
0 commit comments