Skip to content

Instantly share code, notes, and snippets.

@waterson
Created August 1, 2023 19:15
Show Gist options
  • Save waterson/2431e46e2120cb57ed3a3b3610dbd852 to your computer and use it in GitHub Desktop.
Save waterson/2431e46e2120cb57ed3a3b3610dbd852 to your computer and use it in GitHub Desktop.
diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs
index 622cba82..03fe8852 100644
--- a/lightning/src/ln/channel.rs
+++ b/lightning/src/ln/channel.rs
@@ -740,19 +740,6 @@ pub(super) struct ChannelContext<Signer: ChannelSigner> {
#[cfg(not(test))]
closing_fee_limits: Option<(u64, u64)>,
- /// Flag that ensures that `accept_inbound_channel` must be called before `funding_created`
- /// is executed successfully. The reason for this flag is that when the
- /// `UserConfig::manually_accept_inbound_channels` config flag is set to true, inbound channels
- /// are required to be manually accepted by the node operator before the `msgs::AcceptChannel`
- /// message is created and sent out. During the manual accept process, `accept_inbound_channel`
- /// is called by `ChannelManager::accept_inbound_channel`.
- ///
- /// The flag counteracts that a counterparty node could theoretically send a
- /// `msgs::FundingCreated` message before the node operator has manually accepted an inbound
- /// channel request made by the counterparty node. That would execute `funding_created` before
- /// `accept_inbound_channel`, and `funding_created` should therefore not execute successfully.
- inbound_awaiting_accept: bool,
-
/// The hash of the block in which the funding transaction was included.
funding_tx_confirmed_in: Option<BlockHash>,
funding_tx_confirmation_height: u32,
@@ -5649,8 +5636,6 @@ impl<Signer: WriteableEcdsaChannelSigner> OutboundV1Channel<Signer> {
closing_fee_limits: None,
target_closing_feerate_sats_per_kw: None,
- inbound_awaiting_accept: false,
-
funding_tx_confirmed_in: None,
funding_tx_confirmation_height: 0,
short_channel_id: None,
@@ -6291,8 +6276,6 @@ impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {
closing_fee_limits: None,
target_closing_feerate_sats_per_kw: None,
- inbound_awaiting_accept: true,
-
funding_tx_confirmed_in: None,
funding_tx_confirmation_height: 0,
short_channel_id: None,
@@ -6368,13 +6351,10 @@ impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {
Ok(chan)
}
- pub fn is_awaiting_accept(&self) -> bool {
- self.context.inbound_awaiting_accept
- }
-
/// Sets this channel to accepting 0conf, must be done before `get_accept_channel`
pub fn set_0conf(&mut self) {
- assert!(self.context.inbound_awaiting_accept);
+ // Should we assert that the channel is present in the "awaiting accept" table?
+ // assert!(self.context.inbound_awaiting_accept);
self.context.minimum_depth = Some(0);
}
@@ -6392,13 +6372,8 @@ impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {
if self.context.cur_holder_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER {
panic!("Tried to send an accept_channel for a channel that has already advanced");
}
- if !self.context.inbound_awaiting_accept {
- panic!("The inbound channel has already been accepted");
- }
self.context.user_id = user_id;
- self.context.inbound_awaiting_accept = false;
-
self.generate_accept_channel_message()
}
@@ -6493,9 +6468,6 @@ impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {
// channel.
return Err((self, ChannelError::Close("Received funding_created after we got the channel!".to_owned())));
}
- if self.context.inbound_awaiting_accept {
- return Err((self, ChannelError::Close("FundingCreated message received before the channel was accepted".to_owned())));
- }
if self.context.commitment_secrets.get_min_seen_secret() != (1 << 48) ||
self.context.cur_counterparty_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER ||
self.context.cur_holder_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER {
@@ -7395,8 +7367,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
closing_fee_limits: None,
target_closing_feerate_sats_per_kw,
- inbound_awaiting_accept: false,
-
funding_tx_confirmed_in,
funding_tx_confirmation_height,
short_channel_id,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment