Skip to content

Commit f3553a3

Browse files
Add outbound min/max to ChannelCounterparty
1 parent 6644ef1 commit f3553a3

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

fuzz/src/router.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
213213
features: InitFeatures::known(),
214214
unspendable_punishment_reserve: 0,
215215
forwarding_info: None,
216+
outbound_htlc_minimum_msat: None,
217+
outbound_htlc_maximum_msat: None,
216218
},
217219
funding_txo: Some(OutPoint { txid: bitcoin::Txid::from_slice(&[0; 32]).unwrap(), index: 0 }),
218220
channel_type: None,

lightning/src/ln/channel.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4347,6 +4347,11 @@ impl<Signer: Sign> Channel<Signer> {
43474347
self.counterparty_htlc_minimum_msat
43484348
}
43494349

4350+
/// Allowed in any state (including after shutdown), but will return none before TheirInitSent
4351+
pub fn get_counterparty_htlc_maximum_msat(&self) -> Option<u64> {
4352+
self.get_htlc_maximum_msat(self.counterparty_max_htlc_value_in_flight_msat)
4353+
}
4354+
43504355
fn get_htlc_maximum_msat(&self, party_max_htlc_value_in_flight_msat: u64) -> Option<u64> {
43514356
self.counterparty_selected_channel_reserve_satoshis.map(|counterparty_reserve| {
43524357
let holder_reserve = self.holder_selected_channel_reserve_satoshis;

lightning/src/ln/channelmanager.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,11 @@ pub struct ChannelCounterparty {
922922
/// Information on the fees and requirements that the counterparty requires when forwarding
923923
/// payments to us through this channel.
924924
pub forwarding_info: Option<CounterpartyForwardingInfo>,
925+
/// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
926+
/// is only `None` for `CounterpartyForwardingInfo` objects serialized prior to LDK 0.0.107
927+
pub outbound_htlc_minimum_msat: Option<u64>,
928+
/// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
929+
pub outbound_htlc_maximum_msat: Option<u64>,
925930
}
926931

927932
/// Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels
@@ -1675,6 +1680,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
16751680
features: InitFeatures::empty(),
16761681
unspendable_punishment_reserve: to_remote_reserve_satoshis,
16771682
forwarding_info: channel.counterparty_forwarding_info(),
1683+
outbound_htlc_minimum_msat: Some(channel.get_counterparty_htlc_minimum_msat()),
1684+
outbound_htlc_maximum_msat: channel.get_counterparty_htlc_maximum_msat(),
16781685
},
16791686
funding_txo: channel.get_funding_txo(),
16801687
// Note that accept_channel (or open_channel) is always the first message, so
@@ -5904,6 +5911,8 @@ impl_writeable_tlv_based!(ChannelCounterparty, {
59045911
(4, features, required),
59055912
(6, unspendable_punishment_reserve, required),
59065913
(8, forwarding_info, option),
5914+
(9, outbound_htlc_minimum_msat, option),
5915+
(11, outbound_htlc_maximum_msat, option),
59075916
});
59085917

59095918
impl_writeable_tlv_based!(ChannelDetails, {

lightning/src/routing/router.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,8 @@ mod tests {
17351735
node_id,
17361736
unspendable_punishment_reserve: 0,
17371737
forwarding_info: None,
1738+
outbound_htlc_minimum_msat: None,
1739+
outbound_htlc_maximum_msat: None,
17381740
},
17391741
funding_txo: Some(OutPoint { txid: bitcoin::Txid::from_slice(&[0; 32]).unwrap(), index: 0 }),
17401742
channel_type: None,
@@ -5458,6 +5460,8 @@ mod benches {
54585460
node_id,
54595461
unspendable_punishment_reserve: 0,
54605462
forwarding_info: None,
5463+
outbound_htlc_minimum_msat: None,
5464+
outbound_htlc_maximum_msat: None,
54615465
},
54625466
funding_txo: Some(OutPoint {
54635467
txid: bitcoin::Txid::from_slice(&[0; 32]).unwrap(), index: 0

0 commit comments

Comments
 (0)