Skip to content

Commit 0188861

Browse files
authored
Merge pull request #2071 from TheBlueMatt/2023-01-fix-fast-extra-ready-panic
Fix panic on receiving `channel_ready` after 1st commitment update
2 parents fac5373 + 7165d6d commit 0188861

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lightning/src/ln/channel.rs

+5
Original file line numberDiff line numberDiff line change
@@ -2484,6 +2484,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
24842484
// If they haven't ever sent an updated point, the point they send should match
24852485
// the current one.
24862486
self.counterparty_cur_commitment_point
2487+
} else if self.cur_counterparty_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 2 {
2488+
// If we've advanced the commitment number once, the second commitment point is
2489+
// at `counterparty_prev_commitment_point`, which is not yet revoked.
2490+
debug_assert!(self.counterparty_prev_commitment_point.is_some());
2491+
self.counterparty_prev_commitment_point
24872492
} else {
24882493
// If they have sent updated points, channel_ready is always supposed to match
24892494
// their "first" point, which we re-derive here.

lightning/src/ln/priv_short_conf_tests.rs

+7
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ fn test_routed_scid_alias() {
242242
check_added_monitors!(nodes[0], 1);
243243

244244
pass_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], 100_000, payment_hash, payment_secret);
245+
246+
as_channel_ready.short_channel_id_alias = Some(0xeadbeef);
247+
nodes[2].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &as_channel_ready);
248+
// Note that we always respond to a channel_ready with a channel_update. Not a lot of reason
249+
// to bother updating that code, so just drop the message here.
250+
get_event_msg!(nodes[2], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
251+
245252
claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], payment_preimage);
246253

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

0 commit comments

Comments
 (0)