Skip to content

Commit 192b9c0

Browse files
committed
Introduce InboundV1Channel & OutboundV1Channel
1 parent f32ab01 commit 192b9c0

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,26 @@ impl<'a, Signer: WriteableEcdsaChannelSigner + 'a> ChannelInterface<'a, Signer>
19001900
}
19011901
}
19021902

1903+
impl<'a, Signer: WriteableEcdsaChannelSigner + 'a> ChannelInterface<'a, Signer> for OutboundV1Channel<Signer> {
1904+
fn get_context(&'a self) -> &'a ChannelContext<Signer> {
1905+
&self.context
1906+
}
1907+
1908+
fn get_context_mut(&'a mut self) -> &'a mut ChannelContext<Signer> {
1909+
&mut self.context
1910+
}
1911+
}
1912+
1913+
impl<'a, Signer: WriteableEcdsaChannelSigner + 'a> ChannelInterface<'a, Signer> for InboundV1Channel<Signer> {
1914+
fn get_context(&'a self) -> &'a ChannelContext<Signer> {
1915+
&self.context
1916+
}
1917+
1918+
fn get_context_mut(&'a mut self) -> &'a mut ChannelContext<Signer> {
1919+
&mut self.context
1920+
}
1921+
}
1922+
19031923
// TODO: We should refactor this to be an Inbound/OutboundChannel until initial setup handshaking
19041924
// has been completed, and then turn into a Channel to get compiler-time enforcement of things like
19051925
// calling channel_id() before we're set up or things like get_outbound_funding_signed on an
@@ -6489,6 +6509,26 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
64896509
}
64906510
}
64916511

6512+
// A not-yet-funded outbound (from holder) channel using V1 channel establishment.
6513+
pub(super) struct OutboundV1Channel<Signer: ChannelSigner> {
6514+
#[cfg(not(test))]
6515+
context: ChannelContext<Signer>,
6516+
#[cfg(test)]
6517+
pub context: ChannelContext<Signer>,
6518+
}
6519+
6520+
impl<Signer: WriteableEcdsaChannelSigner> OutboundV1Channel<Signer> {}
6521+
6522+
// A not-yet-funded inbound (from counterparty) channel using V1 channel establishment.
6523+
pub(super) struct InboundV1Channel<Signer: ChannelSigner> {
6524+
#[cfg(not(test))]
6525+
context: ChannelContext<Signer>,
6526+
#[cfg(test)]
6527+
pub context: ChannelContext<Signer>,
6528+
}
6529+
6530+
impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {}
6531+
64926532
const SERIALIZATION_VERSION: u8 = 3;
64936533
const MIN_SERIALIZATION_VERSION: u8 = 2;
64946534

0 commit comments

Comments
 (0)