Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic on receiving channel_ready after 1st commitment update #2071

Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2426,6 +2426,11 @@ impl<Signer: Sign> Channel<Signer> {
// If they haven't ever sent an updated point, the point they send should match
// the current one.
self.counterparty_cur_commitment_point
} else if self.cur_counterparty_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 2 {
// If we've advanced the commitment number once, the second commitment point is
// at `counterparty_prev_commitment_point`, which is not yet revoked.
debug_assert!(self.counterparty_prev_commitment_point.is_some());
self.counterparty_prev_commitment_point
} else {
// If they have sent updated points, channel_ready is always supposed to match
// their "first" point, which we re-derive here.
Expand Down
7 changes: 7 additions & 0 deletions lightning/src/ln/priv_short_conf_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ fn test_routed_scid_alias() {
check_added_monitors!(nodes[0], 1);

pass_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], 100_000, payment_hash, payment_secret);

as_channel_ready.short_channel_id_alias = Some(0xeadbeef);
nodes[2].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &as_channel_ready);
// Note that we always respond to a channel_ready with a channel_update. Not a lot of reason
// to bother updating that code, so just drop the message here.
get_event_msg!(nodes[2], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());

claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], payment_preimage);

// Now test that if a peer sends us a second channel_ready after the channel is operational we
Expand Down