Skip to content

Commit 90334bf

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 db20e6f commit 90334bf

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
@@ -8807,24 +8807,42 @@ where
88078807
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
88088808
self.get_channel_ready(logger)
88098809
} else if splicing_negotiated {
8810+
let funding_txid = self
8811+
.maybe_get_my_current_funding_locked()
8812+
.filter(|funding| !funding.is_splice())
8813+
.map(|funding| {
8814+
funding.get_funding_txid().expect("funding_txid should always be set")
8815+
});
8816+
88108817
// A node:
88118818
// - if `option_splice` was negotiated and `your_last_funding_locked` is not
88128819
// set in the `channel_reestablish` it received:
88138820
// - MUST retransmit `channel_ready`.
88148821
msg.your_last_funding_locked_txid
88158822
.is_none()
8816-
.then(|| ())
8823+
.then(|| funding_txid)
8824+
.flatten()
88178825
// The sending node:
88188826
// - if `my_current_funding_locked` is included:
88198827
// - if `announce_channel` is set for this channel:
88208828
// - if it has not received `announcement_signatures` for that transaction:
88218829
// - MUST retransmit `channel_ready` or `splice_locked` after exchanging `channel_reestablish`.
88228830
.or_else(|| {
8823-
self.maybe_get_my_current_funding_locked()
8824-
.filter(|funding| !funding.is_splice())
8831+
funding_txid
88258832
.filter(|_| self.context.config.announce_for_forwarding)
88268833
.filter(|_| self.context.announcement_sigs.is_none())
8827-
.map(|_| ())
8834+
})
8835+
// TODO: The language from the spec below should be updated to be in terms of
8836+
// `your_last_funding_locked` received and `my_current_funding_locked` sent rather
8837+
// than other messages received.
8838+
//
8839+
// - if it receives `channel_ready` for that transaction after exchanging `channel_reestablish`:
8840+
// - MUST retransmit `channel_ready` in response, if not already sent since reconnecting.
8841+
.or_else(|| {
8842+
msg.your_last_funding_locked_txid
8843+
.and_then(|last_funding_txid| {
8844+
funding_txid.filter(|funding_txid| last_funding_txid != *funding_txid)
8845+
})
88288846
})
88298847
.and_then(|_| self.get_channel_ready(logger))
88308848
} else { None };

0 commit comments

Comments
 (0)