Skip to content

Commit 185efd2

Browse files
committed
Document supported channel details invariants
Replace the remaining channel-details unwraps with expects that point to the supported LDK Node upgrade boundary. The missing fields only occur in rust-lightning versions older than the ldk-node v0.1.0 baseline. Co-Authored-By: HAL 9000
1 parent 07156ce commit 185efd2

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/types.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ pub struct ChannelDetails {
561561
}
562562

563563
impl From<LdkChannelDetails> for ChannelDetails {
564-
#[allow(clippy::unwrap_used)]
565564
fn from(value: LdkChannelDetails) -> Self {
566565
ChannelDetails {
567566
channel_id: value.channel_id,
@@ -574,9 +573,9 @@ impl From<LdkChannelDetails> for ChannelDetails {
574573
channel_value_sats: value.channel_value_satoshis,
575574
unspendable_punishment_reserve: value.unspendable_punishment_reserve,
576575
user_channel_id: UserChannelId(value.user_channel_id),
577-
// unwrap safety: This value will be `None` for objects serialized with LDK versions
578-
// prior to 0.0.115.
579-
feerate_sat_per_1000_weight: value.feerate_sat_per_1000_weight.unwrap(),
576+
feerate_sat_per_1000_weight: value
577+
.feerate_sat_per_1000_weight
578+
.expect("ldk-node v0.1.0 already required rust-lightning 0.0.115 feerate details"),
580579
outbound_capacity_msat: value.outbound_capacity_msat,
581580
inbound_capacity_msat: value.inbound_capacity_msat,
582581
confirmations_required: value.confirmations_required,
@@ -609,11 +608,14 @@ impl From<LdkChannelDetails> for ChannelDetails {
609608
next_outbound_htlc_limit_msat: value.next_outbound_htlc_limit_msat,
610609
next_outbound_htlc_minimum_msat: value.next_outbound_htlc_minimum_msat,
611610
force_close_spend_delay: value.force_close_spend_delay,
612-
// unwrap safety: This field is only `None` for objects serialized prior to LDK 0.0.107
613-
inbound_htlc_minimum_msat: value.inbound_htlc_minimum_msat.unwrap_or(0),
611+
inbound_htlc_minimum_msat: value.inbound_htlc_minimum_msat.expect(
612+
"ldk-node v0.1.0 already required rust-lightning 0.0.115 inbound HTLC minimums",
613+
),
614614
inbound_htlc_maximum_msat: value.inbound_htlc_maximum_msat,
615-
// unwrap safety: `config` is only `None` for LDK objects serialized prior to 0.0.109.
616-
config: value.config.map(|c| c.into()).unwrap(),
615+
config: value
616+
.config
617+
.map(|c| c.into())
618+
.expect("ldk-node v0.1.0 already required rust-lightning 0.0.115 channel config"),
617619
}
618620
}
619621
}

0 commit comments

Comments
 (0)