Skip to content

Commit cc1f3b9

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 66ec81d commit cc1f3b9

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
@@ -8415,24 +8415,42 @@ where
84158415
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
84168416
self.get_channel_ready(logger)
84178417
} else if splicing_negotiated {
8418+
let funding_txid = self
8419+
.maybe_get_my_current_funding_locked(features)
8420+
.filter(|funding| !funding.is_splice())
8421+
.map(|funding| {
8422+
funding.get_funding_txid().expect("funding_txid should always be set")
8423+
});
8424+
84188425
// A node:
84198426
// - if `option_splice` was negotiated and `your_last_funding_locked` is not
84208427
// set in the `channel_reestablish` it received:
84218428
// - MUST retransmit `channel_ready`.
84228429
msg.your_last_funding_locked_txid
84238430
.is_none()
8424-
.then(|| ())
8431+
.then(|| funding_txid)
8432+
.flatten()
84258433
// The sending node:
84268434
// - if `my_current_funding_locked` is included:
84278435
// - if `announce_channel` is set for this channel:
84288436
// - if it has not received `announcement_signatures` for that transaction:
84298437
// - MUST retransmit `channel_ready` or `splice_locked` after exchanging `channel_reestablish`.
84308438
.or_else(|| {
8431-
self.maybe_get_my_current_funding_locked(features)
8432-
.filter(|funding| !funding.is_splice())
8439+
funding_txid
84338440
.filter(|_| self.context.config.announce_for_forwarding)
84348441
.filter(|_| self.context.announcement_sigs.is_none())
8435-
.map(|_| ())
8442+
})
8443+
// TODO: The language from the spec below should be updated to be in terms of
8444+
// `your_last_funding_locked` received and `my_current_funding_locked` sent rather
8445+
// than other messages received.
8446+
//
8447+
// - if it receives `channel_ready` for that transaction after exchanging `channel_reestablish`:
8448+
// - MUST retransmit `channel_ready` in response, if not already sent since reconnecting.
8449+
.or_else(|| {
8450+
msg.your_last_funding_locked_txid
8451+
.and_then(|last_funding_txid| {
8452+
funding_txid.filter(|funding_txid| last_funding_txid != *funding_txid)
8453+
})
84368454
})
84378455
.and_then(|_| self.get_channel_ready(logger))
84388456
} else { None };

0 commit comments

Comments
 (0)