Skip to content

Commit 2613151

Browse files
committed
fixup! Add ReserveType to ChannelDetails
make channel reserve type optional until negotiation determines reserve behavior
1 parent bce4068 commit 2613151

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/types.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,17 +587,19 @@ pub struct ChannelDetails {
587587
pub channel_shutdown_state: Option<ChannelShutdownState>,
588588
/// The type of on-chain reserve maintained for this channel.
589589
///
590+
/// Will be `None` until channel negotiation has completed and determined whether
591+
/// this channel uses anchor or legacy reserve behavior.
592+
///
590593
/// See [`ReserveType`] for details on how reserves differ between anchor and legacy channels.
591-
pub reserve_type: ReserveType,
594+
pub reserve_type: Option<ReserveType>,
592595
}
593596

594597
impl ChannelDetails {
595598
pub(crate) fn from_ldk(
596599
value: LdkChannelDetails, anchor_channels_config: Option<&AnchorChannelsConfig>,
597600
) -> Self {
598-
let reserve_type =
599-
if value.channel_type.as_ref().is_some_and(|ct| ct.supports_anchors_zero_fee_htlc_tx())
600-
{
601+
let reserve_type = value.channel_type.as_ref().map(|channel_type| {
602+
if channel_type.supports_anchors_zero_fee_htlc_tx() {
601603
if let Some(config) = anchor_channels_config {
602604
if config.trusted_peers_no_reserve.contains(&value.counterparty.node_id) {
603605
ReserveType::TrustedPeersNoReserve
@@ -616,7 +618,8 @@ impl ChannelDetails {
616618
}
617619
} else {
618620
ReserveType::Legacy
619-
};
621+
}
622+
});
620623

621624
ChannelDetails {
622625
channel_id: value.channel_id,

0 commit comments

Comments
 (0)