Skip to content

Commit 440add9

Browse files
jkczyzclaude
andcommitted
Emit SpliceFailed events for splice_ack failures
When splice_ack validation or interactive transaction construction fails, emit Event::SpliceFailed to notify users of the failure. This reuses the SpliceFundingFailed struct introduced for interactive transaction failures, providing consistent failure reporting across all splice operations. The implementation handles two failure scenarios: - Early validation failure: Sets funding_txo and channel_type to None since no splice funding was established - Late construction failure: Includes actual funding information since validation passed but transaction construction failed The SpliceFundingFailed struct provides placeholders for contributed inputs/outputs that can be populated when access to interactive transaction constructor internals becomes available. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent f321396 commit 440add9

File tree

2 files changed

+47
-6
lines changed

2 files changed

+47
-6
lines changed

lightning/src/ln/channel.rs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11935,12 +11935,24 @@ where
1193511935
pub(crate) fn splice_ack<ES: Deref, L: Deref>(
1193611936
&mut self, msg: &msgs::SpliceAck, signer_provider: &SP, entropy_source: &ES,
1193711937
holder_node_id: &PublicKey, logger: &L,
11938-
) -> Result<Option<InteractiveTxMessageSend>, ChannelError>
11938+
) -> Result<Option<InteractiveTxMessageSend>, (ChannelError, SpliceFundingFailed)>
1193911939
where
1194011940
ES::Target: EntropySource,
1194111941
L::Target: Logger,
1194211942
{
11943-
let splice_funding = self.validate_splice_ack(msg)?;
11943+
let splice_funding = self.validate_splice_ack(msg).map_err(|err| {
11944+
let splice_failed = SpliceFundingFailed {
11945+
channel_id: self.context.channel_id,
11946+
counterparty_node_id: self.context.counterparty_node_id,
11947+
user_channel_id: self.context.user_id,
11948+
funding_txo: None,
11949+
channel_type: None,
11950+
// FIXME: Populate these from funding_negotiation_context?
11951+
contributed_inputs: Vec::new(),
11952+
contributed_outputs: Vec::new(),
11953+
};
11954+
(err, splice_failed)
11955+
})?;
1194411956

1194511957
log_info!(
1194611958
logger,
@@ -11970,10 +11982,20 @@ where
1197011982
holder_node_id.clone(),
1197111983
)
1197211984
.map_err(|err| {
11973-
ChannelError::WarnAndDisconnect(format!(
11985+
let splice_failed = SpliceFundingFailed {
11986+
channel_id: self.context.channel_id,
11987+
counterparty_node_id: self.context.counterparty_node_id,
11988+
user_channel_id: self.context.user_id,
11989+
funding_txo: splice_funding.get_funding_txo().map(|txo| txo.into_bitcoin_outpoint()),
11990+
channel_type: Some(splice_funding.get_channel_type().clone()),
11991+
contributed_inputs: err.contributed_inputs,
11992+
contributed_outputs: err.contributed_outputs,
11993+
};
11994+
let channel_error = ChannelError::WarnAndDisconnect(format!(
1197411995
"Failed to start interactive transaction construction, {:?}",
11975-
err
11976-
))
11996+
err.reason
11997+
));
11998+
(channel_error, splice_failed)
1197711999
})?;
1197812000
let tx_msg_opt = interactive_tx_constructor.take_initiator_first_message();
1197912001

lightning/src/ln/channelmanager.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11314,7 +11314,26 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1131411314
msg, &self.signer_provider, &self.entropy_source,
1131511315
&self.get_our_node_id(), &self.logger
1131611316
);
11317-
let tx_msg_opt = try_channel_entry!(self, peer_state, splice_ack_res, chan_entry);
11317+
11318+
// Handle splice_ack failure and emit SpliceFailed event if needed
11319+
let tx_msg_opt = match splice_ack_res {
11320+
Ok(tx_msg_opt) => Ok(tx_msg_opt),
11321+
Err((channel_error, splice_funding_failed)) => {
11322+
let pending_events = &mut self.pending_events.lock().unwrap();
11323+
pending_events.push_back((events::Event::SpliceFailed {
11324+
channel_id: splice_funding_failed.channel_id,
11325+
counterparty_node_id: splice_funding_failed.counterparty_node_id,
11326+
user_channel_id: splice_funding_failed.user_channel_id,
11327+
funding_txo: splice_funding_failed.funding_txo,
11328+
channel_type: splice_funding_failed.channel_type,
11329+
contributed_inputs: splice_funding_failed.contributed_inputs,
11330+
contributed_outputs: splice_funding_failed.contributed_outputs,
11331+
}, None));
11332+
Err(channel_error)
11333+
}
11334+
};
11335+
11336+
let tx_msg_opt = try_channel_entry!(self, peer_state, tx_msg_opt, chan_entry);
1131811337
if let Some(tx_msg) = tx_msg_opt {
1131911338
peer_state.pending_msg_events.push(tx_msg.into_msg_send_event(counterparty_node_id.clone()));
1132011339
}

0 commit comments

Comments
 (0)