Skip to content

Commit a16db51

Browse files
committed
Include HTLC signatures in initial commitment signed for splices
While we did consider the pending HTLCs when generating the signatures, we did not include them in the resulting `commitment_signed` message sent because we assumed it was only used within a dual-funding context where there are no pending HTLCs.
1 parent f204eee commit a16db51

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

lightning/src/ln/channel.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6121,19 +6121,13 @@ where
61216121
}
61226122
}
61236123

6124-
fn get_initial_counterparty_commitment_signature<L: Deref>(
6124+
fn get_initial_counterparty_commitment_signatures<L: Deref>(
61256125
&self, funding: &FundingScope, logger: &L,
6126-
) -> Option<Signature>
6126+
) -> Option<(Signature, Vec<Signature>)>
61276127
where
61286128
SP::Target: SignerProvider,
61296129
L::Target: Logger,
61306130
{
6131-
let is_quiescent = matches!(
6132-
self.channel_state,
6133-
ChannelState::ChannelReady(f) if f.is_set(ChannelReadyFlags::QUIESCENT)
6134-
);
6135-
debug_assert!(self.channel_state.is_interactive_signing() || is_quiescent);
6136-
61376131
let mut commitment_number = self.counterparty_next_commitment_transaction_number;
61386132
let mut commitment_point = self.counterparty_next_commitment_point.unwrap();
61396133

@@ -6164,7 +6158,6 @@ where
61646158
Vec::new(),
61656159
&self.secp_ctx,
61666160
)
6167-
.map(|(signature, _)| signature)
61686161
.ok()
61696162
},
61706163
// TODO (taproot|arik)
@@ -6180,16 +6173,26 @@ where
61806173
SP::Target: SignerProvider,
61816174
L::Target: Logger,
61826175
{
6183-
let signature = self.get_initial_counterparty_commitment_signature(funding, logger);
6184-
if let Some(signature) = signature {
6176+
let is_quiescent = matches!(
6177+
self.channel_state,
6178+
ChannelState::ChannelReady(f) if f.is_set(ChannelReadyFlags::QUIESCENT)
6179+
);
6180+
debug_assert!(self.channel_state.is_interactive_signing() || is_quiescent);
6181+
6182+
let signatures = self.get_initial_counterparty_commitment_signatures(funding, logger);
6183+
if let Some((signature, htlc_signatures)) = signatures {
61856184
log_info!(
61866185
logger,
61876186
"Generated commitment_signed for peer for channel {}",
61886187
&self.channel_id()
61896188
);
6189+
debug_assert_eq!(
6190+
htlc_signatures.is_empty(),
6191+
self.channel_state.is_interactive_signing()
6192+
);
61906193
Some(msgs::CommitmentSigned {
61916194
channel_id: self.channel_id,
6192-
htlc_signatures: vec![],
6195+
htlc_signatures,
61936196
signature,
61946197
funding_txid: funding.get_funding_txo().map(|funding_txo| funding_txo.txid),
61956198
#[cfg(taproot)]
@@ -6213,7 +6216,7 @@ where
62136216
self.channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
62146217
self.channel_state.set_interactive_signing();
62156218
self.counterparty_next_commitment_point = Some(counterparty_next_commitment_point_override);
6216-
self.get_initial_counterparty_commitment_signature(funding, logger)
6219+
self.get_initial_counterparty_commitment_signatures(funding, logger).map(|(sig, _)| sig)
62176220
}
62186221

62196222
fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {

0 commit comments

Comments
 (0)