Implement From<InboundV1Channel> for ChannelPhase

Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, define a conversion from InboundV1Channel
to ChannelPhase (to be renamed Channel).
This commit is contained in:
Jeffrey Czyz 2025-01-08 18:25:00 -06:00
parent 583224f4f9
commit e8c4849dc7
No known key found for this signature in database
GPG Key ID: 912EF12EA67705F5
2 changed files with 12 additions and 2 deletions

View File

@ -1368,6 +1368,16 @@ where
} }
} }
impl<SP: Deref> From<InboundV1Channel<SP>> for ChannelPhase<SP>
where
SP::Target: SignerProvider,
<SP::Target as SignerProvider>::EcdsaSigner: ChannelSigner,
{
fn from(channel: InboundV1Channel<SP>) -> Self {
ChannelPhase::UnfundedInboundV1(channel)
}
}
impl<SP: Deref> From<Channel<SP>> for ChannelPhase<SP> impl<SP: Deref> From<Channel<SP>> for ChannelPhase<SP>
where where
SP::Target: SignerProvider, SP::Target: SignerProvider,

View File

@ -7689,7 +7689,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
msg, msg,
} }
}); });
(*temporary_channel_id, ChannelPhase::UnfundedInboundV1(channel), message_send_event) (*temporary_channel_id, ChannelPhase::from(channel), message_send_event)
}) })
}, },
#[cfg(dual_funding)] #[cfg(dual_funding)]
@ -7977,7 +7977,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
msg, msg,
} }
}); });
(ChannelPhase::UnfundedInboundV1(channel), message_send_event) (ChannelPhase::from(channel), message_send_event)
}, },
#[cfg(dual_funding)] #[cfg(dual_funding)]
OpenChannelMessageRef::V2(msg) => { OpenChannelMessageRef::V2(msg) => {