Skip to content

Commit f7e39f8

Browse files
committed
Update channel_reestablish logic for channel_ready
When splicing is negotiated, channel_ready must be retransmitted when your_last_funding_locked is not set. Further, the current logic for retransmitting channel_ready is only applicable when splicing is not negotiated.
1 parent af99c2d commit f7e39f8

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lightning/src/ln/channel.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8672,7 +8672,8 @@ where
86728672
#[rustfmt::skip]
86738673
pub fn channel_reestablish<L: Deref, NS: Deref>(
86748674
&mut self, msg: &msgs::ChannelReestablish, logger: &L, node_signer: &NS,
8675-
chain_hash: ChainHash, user_config: &UserConfig, best_block: &BestBlock
8675+
chain_hash: ChainHash, their_features: &InitFeatures, user_config: &UserConfig,
8676+
best_block: &BestBlock,
86768677
) -> Result<ReestablishResponses, ChannelError>
86778678
where
86788679
L::Target: Logger,
@@ -8795,9 +8796,19 @@ where
87958796
let is_awaiting_remote_revoke = self.context.channel_state.is_awaiting_remote_revoke();
87968797
let next_counterparty_commitment_number = INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number + if is_awaiting_remote_revoke { 1 } else { 0 };
87978798

8798-
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number() == 1 {
8799+
let splicing_negotiated = their_features.supports_splicing();
8800+
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number() == 1 && !splicing_negotiated {
87998801
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
88008802
self.get_channel_ready(logger)
8803+
} else if splicing_negotiated {
8804+
// A node:
8805+
// - if `option_splice` was negotiated and `your_last_funding_locked` is not
8806+
// set in the `channel_reestablish` it received:
8807+
// - MUST retransmit `channel_ready`.
8808+
msg.your_last_funding_locked_txid
8809+
.is_none()
8810+
.then(|| ())
8811+
.and_then(|_| self.get_channel_ready(logger))
88018812
} else { None };
88028813

88038814
if msg.next_local_commitment_number == next_counterparty_commitment_number {

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10786,12 +10786,13 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1078610786
match peer_state.channel_by_id.entry(msg.channel_id) {
1078710787
hash_map::Entry::Occupied(mut chan_entry) => {
1078810788
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
10789+
let features = &peer_state.latest_features;
1078910790
// Currently, we expect all holding cell update_adds to be dropped on peer
1079010791
// disconnect, so Channel's reestablish will never hand us any holding cell
1079110792
// freed HTLCs to fail backwards. If in the future we no longer drop pending
1079210793
// add-HTLCs on disconnect, we may be handed HTLCs to fail backwards here.
1079310794
let responses = try_channel_entry!(self, peer_state, chan.channel_reestablish(
10794-
msg, &&logger, &self.node_signer, self.chain_hash,
10795+
msg, &&logger, &self.node_signer, self.chain_hash, features,
1079510796
&self.default_configuration, &*self.best_block.read().unwrap()), chan_entry);
1079610797
let mut channel_update = None;
1079710798
if let Some(msg) = responses.shutdown_msg {

0 commit comments

Comments
 (0)