Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lightning/src/ln/async_signer_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use bitcoin::transaction::Version;

use crate::chain::channelmonitor::LATENCY_GRACE_PERIOD_BLOCKS;
use crate::chain::ChannelMonitorUpdateStatus;
use crate::chain::transaction::OutPoint;
use crate::events::bump_transaction::WalletSource;
use crate::events::{ClosureReason, Event};
use crate::ln::chan_utils::ClosingTransaction;
Expand Down Expand Up @@ -1091,9 +1090,4 @@ fn do_test_closing_signed(extra_closing_signed: bool, reconnect: bool) {
assert!(nodes[1].node.list_channels().is_empty());
check_closed_event!(nodes[0], 1, ClosureReason::LocallyInitiatedCooperativeClosure, [nodes[1].node.get_our_node_id()], 100000);
check_closed_event!(nodes[1], 1, ClosureReason::CounterpartyInitiatedCooperativeClosure, [nodes[0].node.get_our_node_id()], 100000);

// Check that our maps have been updated after async signing channel closure.
let funding_outpoint = OutPoint { txid: funding_tx.compute_txid(), index: 0 };
assert!(nodes[0].node().outpoint_to_peer.lock().unwrap().get(&funding_outpoint).is_none());
assert!(nodes[1].node().outpoint_to_peer.lock().unwrap().get(&funding_outpoint).is_none());
}
29 changes: 21 additions & 8 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3457,6 +3457,18 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
!matches!(self.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::WAITING_FOR_BATCH))
}

fn unset_funding_info(&mut self, funding: &mut FundingScope) {
debug_assert!(
matches!(self.channel_state, ChannelState::FundingNegotiated)
|| matches!(self.channel_state, ChannelState::AwaitingChannelReady(_))
);
funding.channel_transaction_parameters.funding_outpoint = None;
self.channel_id = self.temporary_channel_id.expect(
"temporary_channel_id should be set since unset_funding_info is only called on funded \
channels that were unfunded immediately beforehand"
Comment on lines +3467 to +3468
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, will need to update this message, I guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's still correct-ish? The OutboundV1Channel was funded, it just hadn't transitioned to FundedChannel yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, fair enough!

);
}

fn validate_commitment_signed<L: Deref>(
&self, funding: &FundingScope, holder_commitment_point: &HolderCommitmentPoint,
msg: &msgs::CommitmentSigned, logger: &L,
Expand Down Expand Up @@ -5310,14 +5322,7 @@ impl<SP: Deref> FundedChannel<SP> where
/// Further, the channel must be immediately shut down after this with a call to
/// [`ChannelContext::force_shutdown`].
pub fn unset_funding_info(&mut self) {
debug_assert!(matches!(
self.context.channel_state, ChannelState::AwaitingChannelReady(_)
));
self.funding.channel_transaction_parameters.funding_outpoint = None;
self.context.channel_id = self.context.temporary_channel_id.expect(
"temporary_channel_id should be set since unset_funding_info is only called on funded \
channels that were unfunded immediately beforehand"
);
self.context.unset_funding_info(&mut self.funding);
}

/// Handles a channel_ready message from our peer. If we've already sent our channel_ready
Expand Down Expand Up @@ -9315,6 +9320,14 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
} else { None };
(open_channel, funding_created)
}

/// Unsets the existing funding information.
///
/// The channel must be immediately shut down after this with a call to
/// [`ChannelContext::force_shutdown`].
pub fn unset_funding_info(&mut self) {
self.context.unset_funding_info(&mut self.funding);
}
}

/// A not-yet-funded inbound (from counterparty) channel using V1 channel establishment.
Expand Down
Loading