Skip to content

Commit 05579c9

Browse files
committed
Always set htlc_maximum_msat
1 parent c8c799f commit 05579c9

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lightning/src/ln/channel.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3131,8 +3131,15 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
31313131
}
31323132

31333133
/// Allowed in any state (including after shutdown)
3134-
pub fn get_our_htlc_maximum_msat(&self) -> Option<u64> {
3135-
self.our_htlc_maximum_msat
3134+
pub fn get_announced_htlc_max_msat(&self) -> u64 {
3135+
let mut result = cmp::min(
3136+
self.channel_value_satoshis * 9 / 10, // upper bound by capacity
3137+
Channel::<ChanSigner>::get_our_max_htlc_value_in_flight_msat(self.channel_value_satoshis)
3138+
);
3139+
if let Some(configured_our_htlc_maximum_msat) = self.our_htlc_maximum_msat {
3140+
result = cmp::min(configured_our_htlc_maximum_msat, result)
3141+
}
3142+
result
31363143
}
31373144

31383145
/// Allowed in any state (including after shutdown)

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,10 +1211,10 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
12111211
chain_hash: self.genesis_hash,
12121212
short_channel_id: short_channel_id,
12131213
timestamp: chan.get_update_time_counter(),
1214-
flags: (!were_node_one) as u16 | ((!chan.is_live() as u16) << 1),
1214+
flags: (!were_node_one) as u16 | ((!chan.is_live() as u16) << 1) | (1 << 8),
12151215
cltv_expiry_delta: CLTV_EXPIRY_DELTA,
12161216
htlc_minimum_msat: chan.get_our_htlc_minimum_msat(),
1217-
htlc_maximum_msat: if chan.get_our_htlc_maximum_msat().is_some() { OptionalField::Present(chan.get_our_htlc_maximum_msat().unwrap()) } else { OptionalField::Absent },
1217+
htlc_maximum_msat: OptionalField::Present(chan.get_announced_htlc_max_msat()),
12181218
fee_base_msat: chan.get_our_fee_base_msat(&self.fee_estimator),
12191219
fee_proportional_millionths: chan.get_fee_proportional_millionths(),
12201220
excess_data: Vec::new(),

0 commit comments

Comments
 (0)