Skip to content

Commit e7d1a65

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 d33b2b6 commit e7d1a65

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8794,6 +8794,45 @@ where
87948794
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number() == 1 {
87958795
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
87968796
self.get_channel_ready(logger)
8797+
} else if splicing_negotiated {
8798+
let funding_txid = self
8799+
.maybe_get_my_current_funding_locked()
8800+
.filter(|funding| !funding.is_splice())
8801+
.map(|funding| {
8802+
funding.get_funding_txid().expect("funding_txid should always be set")
8803+
});
8804+
8805+
// A node:
8806+
// - if `option_splice` was negotiated and `your_last_funding_locked` is not
8807+
// set in the `channel_reestablish` it received:
8808+
// - MUST retransmit `channel_ready`.
8809+
msg.your_last_funding_locked_txid
8810+
.is_none()
8811+
.then(|| funding_txid)
8812+
.flatten()
8813+
// The sending node:
8814+
// - if `my_current_funding_locked` is included:
8815+
// - if `announce_channel` is set for this channel:
8816+
// - if it has not received `announcement_signatures` for that transaction:
8817+
// - MUST retransmit `channel_ready` or `splice_locked` after exchanging `channel_reestablish`.
8818+
.or_else(|| {
8819+
funding_txid
8820+
.filter(|_| self.context.config.announce_for_forwarding)
8821+
.filter(|_| self.context.announcement_sigs.is_none())
8822+
})
8823+
// TODO: The language from the spec below should be updated to be in terms of
8824+
// `your_last_funding_locked` received and `my_current_funding_locked` sent rather
8825+
// than other messages received.
8826+
//
8827+
// - if it receives `channel_ready` for that transaction after exchanging `channel_reestablish`:
8828+
// - MUST retransmit `channel_ready` in response, if not already sent since reconnecting.
8829+
.or_else(|| {
8830+
msg.your_last_funding_locked_txid
8831+
.and_then(|last_funding_txid| {
8832+
funding_txid.filter(|funding_txid| last_funding_txid != *funding_txid)
8833+
})
8834+
})
8835+
.and_then(|_| self.get_channel_ready(logger))
87978836
} else { None };
87988837

87998838
let mut commitment_update = None;

0 commit comments

Comments
 (0)