Skip to content

Commit 002ec95

Browse files
committed
Set funding_locked_txid TLVs in channel_reestablish
The previous commit extended the channel_reestablish message with your_last_funding_locked_txid and my_current_funding_locked_txid for use as described there. This commit sets those fields to the funding txid most recently sent/received accordingly.
1 parent efe8314 commit 002ec95

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

lightning/src/ln/channel.rs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9767,6 +9767,13 @@ where
97679767
self.context.latest_inbound_scid_alias.or(self.funding.get_short_channel_id())
97689768
}
97699769

9770+
/// Returns true if their channel_ready has been received
9771+
#[cfg(splicing)]
9772+
pub fn is_their_channel_ready(&self) -> bool {
9773+
matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::THEIR_CHANNEL_READY))
9774+
|| matches!(self.context.channel_state, ChannelState::ChannelReady(_))
9775+
}
9776+
97709777
/// Returns true if our channel_ready has been sent
97719778
pub fn is_our_channel_ready(&self) -> bool {
97729779
matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::OUR_CHANNEL_READY))
@@ -10541,6 +10548,35 @@ where
1054110548
}
1054210549
}
1054310550

10551+
#[cfg(splicing)]
10552+
fn maybe_get_your_last_funding_locked_txid(&self) -> Option<Txid> {
10553+
self.pending_splice
10554+
.as_ref()
10555+
.and_then(|pending_splice| pending_splice.received_funding_txid)
10556+
.or_else(|| {
10557+
self.is_their_channel_ready().then(|| self.funding.get_funding_txid()).flatten()
10558+
})
10559+
}
10560+
#[cfg(not(splicing))]
10561+
fn maybe_get_your_last_funding_locked_txid(&self) -> Option<Txid> {
10562+
None
10563+
}
10564+
10565+
#[cfg(splicing)]
10566+
fn maybe_get_my_current_funding_locked_txid(&self) -> Option<Txid> {
10567+
self.pending_splice
10568+
.as_ref()
10569+
.and_then(|pending_splice| pending_splice.sent_funding_txid)
10570+
.or_else(|| {
10571+
self.is_our_channel_ready().then(|| self.funding.get_funding_txid()).flatten()
10572+
})
10573+
}
10574+
10575+
#[cfg(not(splicing))]
10576+
fn maybe_get_my_current_funding_locked_txid(&self) -> Option<Txid> {
10577+
None
10578+
}
10579+
1054410580
/// May panic if called on a channel that wasn't immediately-previously
1054510581
/// self.remove_uncommitted_htlcs_and_mark_paused()'d
1054610582
#[rustfmt::skip]
@@ -10592,8 +10628,8 @@ where
1059210628
your_last_per_commitment_secret: remote_last_secret,
1059310629
my_current_per_commitment_point: dummy_pubkey,
1059410630
next_funding_txid: self.maybe_get_next_funding_txid(),
10595-
your_last_funding_locked_txid: None,
10596-
my_current_funding_locked_txid: None,
10631+
your_last_funding_locked_txid: self.maybe_get_your_last_funding_locked_txid(),
10632+
my_current_funding_locked_txid: self.maybe_get_my_current_funding_locked_txid(),
1059710633
}
1059810634
}
1059910635

0 commit comments

Comments
 (0)