Skip to content

Commit 32fa245

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 c9c16b5 commit 32fa245

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
@@ -8667,7 +8667,8 @@ where
86678667
#[rustfmt::skip]
86688668
pub fn channel_reestablish<L: Deref, NS: Deref>(
86698669
&mut self, msg: &msgs::ChannelReestablish, logger: &L, node_signer: &NS,
8670-
chain_hash: ChainHash, user_config: &UserConfig, best_block: &BestBlock
8670+
chain_hash: ChainHash, their_features: &InitFeatures, user_config: &UserConfig,
8671+
best_block: &BestBlock,
86718672
) -> Result<ReestablishResponses, ChannelError>
86728673
where
86738674
L::Target: Logger,
@@ -8790,9 +8791,19 @@ where
87908791
let is_awaiting_remote_revoke = self.context.channel_state.is_awaiting_remote_revoke();
87918792
let next_counterparty_commitment_number = INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number + if is_awaiting_remote_revoke { 1 } else { 0 };
87928793

8793-
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number() == 1 {
8794+
let splicing_negotiated = their_features.supports_splicing();
8795+
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number() == 1 && !splicing_negotiated {
87948796
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
87958797
self.get_channel_ready(logger)
8798+
} else if splicing_negotiated {
8799+
// A node:
8800+
// - if `option_splice` was negotiated and `your_last_funding_locked` is not
8801+
// set in the `channel_reestablish` it received:
8802+
// - MUST retransmit `channel_ready`.
8803+
msg.your_last_funding_locked_txid
8804+
.is_none()
8805+
.then(|| ())
8806+
.and_then(|_| self.get_channel_ready(logger))
87968807
} else { None };
87978808

87988809
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
@@ -10983,12 +10983,13 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1098310983
match peer_state.channel_by_id.entry(msg.channel_id) {
1098410984
hash_map::Entry::Occupied(mut chan_entry) => {
1098510985
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
10986+
let features = &peer_state.latest_features;
1098610987
// Currently, we expect all holding cell update_adds to be dropped on peer
1098710988
// disconnect, so Channel's reestablish will never hand us any holding cell
1098810989
// freed HTLCs to fail backwards. If in the future we no longer drop pending
1098910990
// add-HTLCs on disconnect, we may be handed HTLCs to fail backwards here.
1099010991
let responses = try_channel_entry!(self, peer_state, chan.channel_reestablish(
10991-
msg, &&logger, &self.node_signer, self.chain_hash,
10992+
msg, &&logger, &self.node_signer, self.chain_hash, features,
1099210993
&self.default_configuration, &*self.best_block.read().unwrap()), chan_entry);
1099310994
let mut channel_update = None;
1099410995
if let Some(msg) = responses.shutdown_msg {

0 commit comments

Comments
 (0)