Skip to content

Commit 18d7b24

Browse files
committed
Implement From<PendingV2Channel> 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 PendingV2Channel to ChannelPhase (to be renamed Channel).
1 parent 78a492c commit 18d7b24

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lightning/src/ln/channel.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,16 @@ where
13661366
}
13671367
}
13681368

1369+
impl<SP: Deref> From<PendingV2Channel<SP>> for ChannelPhase<SP>
1370+
where
1371+
SP::Target: SignerProvider,
1372+
<SP::Target as SignerProvider>::EcdsaSigner: ChannelSigner,
1373+
{
1374+
fn from(channel: PendingV2Channel<SP>) -> Self {
1375+
ChannelPhase::UnfundedV2(channel)
1376+
}
1377+
}
1378+
13691379
impl<SP: Deref> From<Channel<SP>> for ChannelPhase<SP>
13701380
where
13711381
SP::Target: SignerProvider,

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7713,7 +7713,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
77137713
node_id: channel.context.get_counterparty_node_id(),
77147714
msg: channel.accept_inbound_dual_funded_channel()
77157715
};
7716-
(channel.context.channel_id(), ChannelPhase::UnfundedV2(channel), Some(message_send_event))
7716+
(channel.context.channel_id(), ChannelPhase::from(channel), Some(message_send_event))
77177717
})
77187718
},
77197719
}
@@ -7991,7 +7991,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
79917991
node_id: *counterparty_node_id,
79927992
msg: channel.accept_inbound_dual_funded_channel(),
79937993
};
7994-
(ChannelPhase::UnfundedV2(channel), Some(message_send_event))
7994+
(ChannelPhase::from(channel), Some(message_send_event))
79957995
},
79967996
};
79977997

0 commit comments

Comments
 (0)