Skip to content

Commit f32a783

Browse files
committed
fixup! Expose per-channel features in ChannelDetails
Make `outbound_htlc_minimum_msat` an `Option<u64>` This field is `None` before receiving `OpenChannel`/`AcceptChannel`, so expecting it could panic when `list_channels` is called during early channel negotiation. Pass through the `Option` directly instead. Also re-export `ChannelCounterparty` in `lib.rs` so Rust consumers can name the type.
1 parent c36bfe9 commit f32a783

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ use types::{
179179
HRNResolver, KeysManager, OnionMessenger, PaymentStore, PeerManager, Router, Scorer, Sweeper,
180180
Wallet,
181181
};
182-
pub use types::{ChannelDetails, CustomTlvRecord, PeerDetails, ReserveType, UserChannelId};
182+
pub use types::{
183+
ChannelCounterparty, ChannelDetails, CustomTlvRecord, PeerDetails, ReserveType, UserChannelId,
184+
};
183185
pub use vss_client;
184186

185187
use crate::ffi::maybe_wrap;

src/types.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ pub struct ChannelCounterparty {
372372
/// payments to us through this channel.
373373
pub forwarding_info: Option<CounterpartyForwardingInfo>,
374374
/// The smallest value HTLC (in msat) the remote peer will accept, for this channel.
375-
pub outbound_htlc_minimum_msat: u64,
375+
///
376+
/// Will be `None` before we have received the `OpenChannel` or `AcceptChannel` message
377+
/// from the remote peer.
378+
pub outbound_htlc_minimum_msat: Option<u64>,
376379
/// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
377380
pub outbound_htlc_maximum_msat: Option<u64>,
378381
}
@@ -622,12 +625,7 @@ impl ChannelDetails {
622625
features: maybe_wrap(value.counterparty.features),
623626
unspendable_punishment_reserve: value.counterparty.unspendable_punishment_reserve,
624627
forwarding_info: value.counterparty.forwarding_info,
625-
// unwrap safety: This value will be `None` for objects serialized with LDK versions
626-
// prior to 0.0.115.
627-
outbound_htlc_minimum_msat: value
628-
.counterparty
629-
.outbound_htlc_minimum_msat
630-
.expect("value is set for objects serialized with LDK v0.0.107+"),
628+
outbound_htlc_minimum_msat: value.counterparty.outbound_htlc_minimum_msat,
631629
outbound_htlc_maximum_msat: value.counterparty.outbound_htlc_maximum_msat,
632630
},
633631
funding_txo: value.funding_txo.map(|o| o.into_bitcoin_outpoint()),

0 commit comments

Comments
 (0)