Skip to content

Commit 4caac9c

Browse files
committed
f - merge available balances
1 parent 18c7521 commit 4caac9c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lightning/src/ln/channel.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -4148,7 +4148,14 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
41484148
core::iter::once(funding)
41494149
.chain(pending_funding.iter())
41504150
.map(|funding| self.get_available_balances_for_scope(funding, fee_estimator))
4151-
.min_by_key(|balances| balances.next_outbound_htlc_limit_msat)
4151+
.reduce(|acc, e| {
4152+
AvailableBalances {
4153+
inbound_capacity_msat: acc.inbound_capacity_msat.min(e.inbound_capacity_msat),
4154+
outbound_capacity_msat: acc.outbound_capacity_msat.min(e.outbound_capacity_msat),
4155+
next_outbound_htlc_limit_msat: acc.next_outbound_htlc_limit_msat.min(e.next_outbound_htlc_limit_msat),
4156+
next_outbound_htlc_minimum_msat: acc.next_outbound_htlc_minimum_msat.max(e.next_outbound_htlc_minimum_msat),
4157+
}
4158+
})
41524159
.expect("At least one FundingScope is always provided")
41534160
}
41544161

0 commit comments

Comments
 (0)