Skip to content

Commit 725be21

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 798bbc4 commit 725be21

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
@@ -8277,7 +8277,8 @@ where
82778277
#[rustfmt::skip]
82788278
pub fn channel_reestablish<L: Deref, NS: Deref>(
82798279
&mut self, msg: &msgs::ChannelReestablish, logger: &L, node_signer: &NS,
8280-
chain_hash: ChainHash, user_config: &UserConfig, best_block: &BestBlock
8280+
chain_hash: ChainHash, features: &InitFeatures, user_config: &UserConfig,
8281+
best_block: &BestBlock,
82818282
) -> Result<ReestablishResponses, ChannelError>
82828283
where
82838284
L::Target: Logger,
@@ -8401,9 +8402,19 @@ where
84018402
let is_awaiting_remote_revoke = self.context.channel_state.is_awaiting_remote_revoke();
84028403
let next_counterparty_commitment_number = INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number + if is_awaiting_remote_revoke { 1 } else { 0 };
84038404

8404-
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number() == 1 {
8405+
let splicing_negotiated = features.supports_splicing();
8406+
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number() == 1 && !splicing_negotiated {
84058407
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
84068408
self.get_channel_ready(logger)
8409+
} else if splicing_negotiated {
8410+
// A node:
8411+
// - if `option_splice` was negotiated and `your_last_funding_locked` is not
8412+
// set in the `channel_reestablish` it received:
8413+
// - MUST retransmit `channel_ready`.
8414+
msg.your_last_funding_locked_txid
8415+
.is_none()
8416+
.then(|| ())
8417+
.and_then(|_| self.get_channel_ready(logger))
84078418
} else { None };
84088419

84098420
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
@@ -10054,12 +10054,13 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1005410054
match peer_state.channel_by_id.entry(msg.channel_id) {
1005510055
hash_map::Entry::Occupied(mut chan_entry) => {
1005610056
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
10057+
let features = &peer_state.latest_features;
1005710058
// Currently, we expect all holding cell update_adds to be dropped on peer
1005810059
// disconnect, so Channel's reestablish will never hand us any holding cell
1005910060
// freed HTLCs to fail backwards. If in the future we no longer drop pending
1006010061
// add-HTLCs on disconnect, we may be handed HTLCs to fail backwards here.
1006110062
let responses = try_channel_entry!(self, peer_state, chan.channel_reestablish(
10062-
msg, &&logger, &self.node_signer, self.chain_hash,
10063+
msg, &&logger, &self.node_signer, self.chain_hash, features,
1006310064
&self.default_configuration, &*self.best_block.read().unwrap()), chan_entry);
1006410065
let mut channel_update = None;
1006510066
if let Some(msg) = responses.shutdown_msg {

0 commit comments

Comments
 (0)