Skip to content

Commit 32a2f21

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 cb0549f commit 32a2f21

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
@@ -8403,24 +8403,42 @@ where
84038403
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
84048404
self.get_channel_ready(logger)
84058405
} else if splicing_negotiated {
8406+
let funding_txid = self
8407+
.maybe_get_my_current_funding_locked(their_features)
8408+
.filter(|funding| !funding.is_splice())
8409+
.map(|funding| {
8410+
funding.get_funding_txid().expect("funding_txid should always be set")
8411+
});
8412+
84068413
// A node:
84078414
// - if `option_splice` was negotiated and `your_last_funding_locked` is not
84088415
// set in the `channel_reestablish` it received:
84098416
// - MUST retransmit `channel_ready`.
84108417
msg.your_last_funding_locked_txid
84118418
.is_none()
8412-
.then(|| ())
8419+
.then(|| funding_txid)
8420+
.flatten()
84138421
// The sending node:
84148422
// - if `my_current_funding_locked` is included:
84158423
// - if `announce_channel` is set for this channel:
84168424
// - if it has not received `announcement_signatures` for that transaction:
84178425
// - MUST retransmit `channel_ready` or `splice_locked` after exchanging `channel_reestablish`.
84188426
.or_else(|| {
8419-
self.maybe_get_my_current_funding_locked(their_features)
8420-
.filter(|funding| !funding.is_splice())
8427+
funding_txid
84218428
.filter(|_| self.context.config.announce_for_forwarding)
84228429
.filter(|_| self.context.announcement_sigs.is_none())
8423-
.map(|_| ())
8430+
})
8431+
// TODO: The language from the spec below should be updated to be in terms of
8432+
// `your_last_funding_locked` received and `my_current_funding_locked` sent rather
8433+
// than other messages received.
8434+
//
8435+
// - if it receives `channel_ready` for that transaction after exchanging `channel_reestablish`:
8436+
// - MUST retransmit `channel_ready` in response, if not already sent since reconnecting.
8437+
.or_else(|| {
8438+
msg.your_last_funding_locked_txid
8439+
.and_then(|last_funding_txid| {
8440+
funding_txid.filter(|funding_txid| last_funding_txid != *funding_txid)
8441+
})
84248442
})
84258443
.and_then(|_| self.get_channel_ready(logger))
84268444
} else { None };

0 commit comments

Comments
 (0)