Skip to content

Commit 449eaae

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 fdbd4ff commit 449eaae

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ use types::{
181181
Wallet,
182182
};
183183
pub use types::{
184-
ChannelDetails, CustomTlvRecord, PeerDetails, ReserveType, SyncAndAsyncKVStore, UserChannelId,
184+
ChannelCounterparty, ChannelDetails, CustomTlvRecord, PeerDetails, ReserveType,
185+
SyncAndAsyncKVStore, UserChannelId,
185186
};
186187
pub use vss_client;
187188

src/types.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,10 @@ pub struct ChannelCounterparty {
446446
/// payments to us through this channel.
447447
pub forwarding_info: Option<CounterpartyForwardingInfo>,
448448
/// The smallest value HTLC (in msat) the remote peer will accept, for this channel.
449-
pub outbound_htlc_minimum_msat: u64,
449+
///
450+
/// Will be `None` before we have received the `OpenChannel` or `AcceptChannel` message
451+
/// from the remote peer.
452+
pub outbound_htlc_minimum_msat: Option<u64>,
450453
/// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
451454
pub outbound_htlc_maximum_msat: Option<u64>,
452455
}
@@ -696,12 +699,7 @@ impl ChannelDetails {
696699
features: maybe_wrap(value.counterparty.features),
697700
unspendable_punishment_reserve: value.counterparty.unspendable_punishment_reserve,
698701
forwarding_info: value.counterparty.forwarding_info,
699-
// unwrap safety: This value will be `None` for objects serialized with LDK versions
700-
// prior to 0.0.115.
701-
outbound_htlc_minimum_msat: value
702-
.counterparty
703-
.outbound_htlc_minimum_msat
704-
.expect("value is set for objects serialized with LDK v0.0.107+"),
702+
outbound_htlc_minimum_msat: value.counterparty.outbound_htlc_minimum_msat,
705703
outbound_htlc_maximum_msat: value.counterparty.outbound_htlc_maximum_msat,
706704
},
707705
funding_txo: value.funding_txo.map(|o| o.into_bitcoin_outpoint()),

0 commit comments

Comments
 (0)