Skip to content

Commit c151332

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 0cba149 commit c151332

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
@@ -8812,24 +8812,42 @@ where
88128812
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
88138813
self.get_channel_ready(logger)
88148814
} else if splicing_negotiated {
8815+
let funding_txid = self
8816+
.maybe_get_my_current_funding_locked()
8817+
.filter(|funding| !funding.is_splice())
8818+
.map(|funding| {
8819+
funding.get_funding_txid().expect("funding_txid should always be set")
8820+
});
8821+
88158822
// A node:
88168823
// - if `option_splice` was negotiated and `your_last_funding_locked` is not
88178824
// set in the `channel_reestablish` it received:
88188825
// - MUST retransmit `channel_ready`.
88198826
msg.your_last_funding_locked_txid
88208827
.is_none()
8821-
.then(|| ())
8828+
.then(|| funding_txid)
8829+
.flatten()
88228830
// The sending node:
88238831
// - if `my_current_funding_locked` is included:
88248832
// - if `announce_channel` is set for this channel:
88258833
// - if it has not received `announcement_signatures` for that transaction:
88268834
// - MUST retransmit `channel_ready` or `splice_locked` after exchanging `channel_reestablish`.
88278835
.or_else(|| {
8828-
self.maybe_get_my_current_funding_locked()
8829-
.filter(|funding| !funding.is_splice())
8836+
funding_txid
88308837
.filter(|_| self.context.config.announce_for_forwarding)
88318838
.filter(|_| self.context.announcement_sigs.is_none())
8832-
.map(|_| ())
8839+
})
8840+
// TODO: The language from the spec below should be updated to be in terms of
8841+
// `your_last_funding_locked` received and `my_current_funding_locked` sent rather
8842+
// than other messages received.
8843+
//
8844+
// - if it receives `channel_ready` for that transaction after exchanging `channel_reestablish`:
8845+
// - MUST retransmit `channel_ready` in response, if not already sent since reconnecting.
8846+
.or_else(|| {
8847+
msg.your_last_funding_locked_txid
8848+
.and_then(|last_funding_txid| {
8849+
funding_txid.filter(|funding_txid| last_funding_txid != *funding_txid)
8850+
})
88338851
})
88348852
.and_then(|_| self.get_channel_ready(logger))
88358853
} else { None };

0 commit comments

Comments
 (0)