Skip to content

Commit 3f0cace

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 269c0ed commit 3f0cace

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

lightning/src/ln/channel.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11882,12 +11882,23 @@ where
1188211882
pub(crate) fn splice_ack<ES: Deref, L: Deref>(
1188311883
&mut self, msg: &msgs::SpliceAck, signer_provider: &SP, entropy_source: &ES,
1188411884
holder_node_id: &PublicKey, logger: &L,
11885-
) -> Result<Option<InteractiveTxMessageSend>, ChannelError>
11885+
) -> Result<Option<InteractiveTxMessageSend>, (ChannelError, SpliceFundingFailed)>
1188611886
where
1188711887
ES::Target: EntropySource,
1188811888
L::Target: Logger,
1188911889
{
11890-
let splice_funding = self.validate_splice_ack(msg)?;
11890+
let splice_funding = self.validate_splice_ack(msg).map_err(|err| {
11891+
let splice_failed = SpliceFundingFailed {
11892+
channel_id: self.context.channel_id,
11893+
counterparty_node_id: self.context.counterparty_node_id,
11894+
user_channel_id: self.context.user_id,
11895+
funding_txo: None,
11896+
channel_type: None,
11897+
contributed_inputs: Vec::new(),
11898+
contributed_outputs: Vec::new(),
11899+
};
11900+
(err, splice_failed)
11901+
})?;
1189111902

1189211903
log_info!(
1189311904
logger,
@@ -11917,10 +11928,20 @@ where
1191711928
holder_node_id.clone(),
1191811929
)
1191911930
.map_err(|err| {
11920-
ChannelError::WarnAndDisconnect(format!(
11931+
let splice_failed = SpliceFundingFailed {
11932+
channel_id: self.context.channel_id,
11933+
counterparty_node_id: self.context.counterparty_node_id,
11934+
user_channel_id: self.context.user_id,
11935+
funding_txo: splice_funding.get_funding_txo().map(|txo| txo.into_bitcoin_outpoint()),
11936+
channel_type: Some(splice_funding.get_channel_type().clone()),
11937+
contributed_inputs: Vec::new(),
11938+
contributed_outputs: Vec::new(),
11939+
};
11940+
let channel_error = ChannelError::WarnAndDisconnect(format!(
1192111941
"Failed to start interactive transaction construction, {:?}",
1192211942
err
11923-
))
11943+
));
11944+
(channel_error, splice_failed)
1192411945
})?;
1192511946
let tx_msg_opt = interactive_tx_constructor.take_initiator_first_message();
1192611947

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)