Skip to content

Commit 8088559

Browse files
committed
Send channel_ready on channel_reestablish
The channel_reestablish protocol supports retransmitting channel_ready messages as needed. Add support for doing such when handling channel_reestablish messages.
1 parent 5ab8676 commit 8088559

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

lightning/src/ln/channel.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8443,24 +8443,42 @@ where
84438443
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
84448444
self.get_channel_ready(logger)
84458445
} else if splicing_negotiated {
8446+
let funding_txid = self
8447+
.maybe_get_my_current_funding_locked(features)
8448+
.filter(|funding| !funding.is_splice())
8449+
.map(|funding| {
8450+
funding.get_funding_txid().expect("funding_txid should always be set")
8451+
});
8452+
84468453
// A node:
84478454
// - if `option_splice` was negotiated and `your_last_funding_locked` is not
84488455
// set in the `channel_reestablish` it received:
84498456
// - MUST retransmit `channel_ready`.
84508457
msg.your_last_funding_locked_txid
84518458
.is_none()
8452-
.then(|| ())
8459+
.then(|| funding_txid)
8460+
.flatten()
84538461
// The sending node:
84548462
// - if `my_current_funding_locked` is included:
84558463
// - if `announce_channel` is set for this channel:
84568464
// - if it has not received `announcement_signatures` for that transaction:
84578465
// - MUST retransmit `channel_ready` or `splice_locked` after exchanging `channel_reestablish`.
84588466
.or_else(|| {
8459-
self.maybe_get_my_current_funding_locked(features)
8460-
.filter(|funding| !funding.is_splice())
8467+
funding_txid
84618468
.filter(|_| self.context.config.announce_for_forwarding)
84628469
.filter(|_| self.context.announcement_sigs.is_none())
8463-
.map(|_| ())
8470+
})
8471+
// TODO: The language from the spec below should be updated to be in terms of
8472+
// `your_last_funding_locked` received and `my_current_funding_locked` sent rather
8473+
// than other messages received.
8474+
//
8475+
// - if it receives `channel_ready` for that transaction after exchanging `channel_reestablish`:
8476+
// - MUST retransmit `channel_ready` in response, if not already sent since reconnecting.
8477+
.or_else(|| {
8478+
msg.your_last_funding_locked_txid
8479+
.and_then(|last_funding_txid| {
8480+
funding_txid.filter(|funding_txid| last_funding_txid != *funding_txid)
8481+
})
84648482
})
84658483
.and_then(|_| self.get_channel_ready(logger))
84668484
} else { None };

0 commit comments

Comments
 (0)