Merge PR 'Don't panic on splice txs confirming with empty witnesses' (#5536)
What changed, and why it matters
This patch fixes a crash (panic) in the Lightning Dev Kit's channel handling code. Previously, the code assumed that any outbound funding transaction was built by the user, and it would panic if the transaction had an empty witness. Splice transactions are also outbound but are built internally, so the old assumption was wrong. The fix adds a check to only panic for user-built funding transactions, and instead return a normal processing error for internally-built splice transactions that don't match expectations.
Review whether the empty-witness check should still trigger a force-close or other defensive action for splice transactions, rather than silently allowing confirmation. Confirm that the new `is_user_built_funding` condition correctly covers all non-user-built outbound funding cases. Consider adding regression tests for splice transactions confirming with empty witnesses.
Security signals we found
Denial-of-service vector: unhandled panic on splice transaction confirmation
Incorrect invariant: `is_outbound()` assumed to mean user-built funding transaction
Crash-to-error conversion: panic replaced with graceful closure for splice paths
Witness validation bypass concern: empty witness no longer panics for splice txs
Evidence from the diff
In ChannelContext::funding_transaction_generated (lightning/src/ln/channel.rs), the code used funding.is_outbound() to decide whether to panic on funding transaction mismatch or empty witness. For splice transactions, is_outbound() is true even though the funding transaction is not user-built. The patch introduces is_user_built_funding, defined as outbound with no splice_parent_funding_txid, and uses it instead of is_outbound() for the panic paths. This prevents an internal panic when a splice transaction confirms with an empty witness, converting it into a ClosureReason::ProcessingError.
Changed components
lightning/src/ln/channel.rsChannelContext::funding_transaction_generatedSplice transaction confirmation handlingInspect captured patch +5 / −2
### lightning/src/ln/channel.rs
@@ -7013,6 +7013,9 @@ impl<SP: SignerProvider> ChannelContext<SP> {
},
};
+ let is_user_built_funding = funding.is_outbound()
+ && funding.channel_transaction_parameters.splice_parent_funding_txid.is_none();
+
// Check if the transaction is the expected funding transaction, and if it is,
// check that it pays the right amount to the right script.
if funding.funding_tx_confirmation_height == 0 {
@@ -7021,7 +7024,7 @@ impl<SP: SignerProvider> ChannelContext<SP> {
let txo_idx = funding_txo.index as usize;
if txo_idx >= tx.output.len() || tx.output[txo_idx].script_pubkey != funding.get_funding_redeemscript().to_p2wsh() ||
tx.output[txo_idx].value.to_sat() != funding.get_value_satoshis() {
- if funding.is_outbound() {
+ if is_user_built_funding {
// If we generated the funding transaction and it doesn't match what it
// should, the client is really broken and we should just panic and
// tell them off. That said, because hash collisions happen with high
@@ -7034,7 +7037,7 @@ impl<SP: SignerProvider> ChannelContext<SP> {
let err_reason = "funding tx had wrong script/value or output index";
return Err(ClosureReason::ProcessingError { err: err_reason.to_owned() });
} else {
- if funding.is_outbound() {
+ if is_user_built_funding {
if !tx.is_coinbase() {
for input in tx.input.iter() {
if input.witness.is_empty() {Why this scored 57/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.