Skip to content

Commit f70810d

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 8a61739 commit f70810d

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
@@ -11924,12 +11924,24 @@ where
1192411924
pub(crate) fn splice_ack<ES: Deref, L: Deref>(
1192511925
&mut self, msg: &msgs::SpliceAck, signer_provider: &SP, entropy_source: &ES,
1192611926
holder_node_id: &PublicKey, logger: &L,
11927-
) -> Result<Option<InteractiveTxMessageSend>, ChannelError>
11927+
) -> Result<Option<InteractiveTxMessageSend>, (ChannelError, SpliceFundingFailed)>
1192811928
where
1192911929
ES::Target: EntropySource,
1193011930
L::Target: Logger,
1193111931
{
11932-
let splice_funding = self.validate_splice_ack(msg)?;
11932+
let splice_funding = self.validate_splice_ack(msg).map_err(|err| {
11933+
let splice_failed = SpliceFundingFailed {
11934+
channel_id: self.context.channel_id,
11935+
counterparty_node_id: self.context.counterparty_node_id,
11936+
user_channel_id: self.context.user_id,
11937+
funding_txo: None,
11938+
channel_type: None,
11939+
// FIXME: Populate these from funding_negotiation_context?
11940+
contributed_inputs: Vec::new(),
11941+
contributed_outputs: Vec::new(),
11942+
};
11943+
(err, splice_failed)
11944+
})?;
1193311945

1193411946
log_info!(
1193511947
logger,
@@ -11959,10 +11971,20 @@ where
1195911971
holder_node_id.clone(),
1196011972
)
1196111973
.map_err(|err| {
11962-
ChannelError::WarnAndDisconnect(format!(
11974+
let splice_failed = SpliceFundingFailed {
11975+
channel_id: self.context.channel_id,
11976+
counterparty_node_id: self.context.counterparty_node_id,
11977+
user_channel_id: self.context.user_id,
11978+
funding_txo: splice_funding.get_funding_txo().map(|txo| txo.into_bitcoin_outpoint()),
11979+
channel_type: Some(splice_funding.get_channel_type().clone()),
11980+
contributed_inputs: err.contributed_inputs,
11981+
contributed_outputs: err.contributed_outputs,
11982+
};
11983+
let channel_error = ChannelError::WarnAndDisconnect(format!(
1196311984
"Failed to start interactive transaction construction, {:?}",
11964-
err
11965-
))
11985+
err.reason
11986+
));
11987+
(channel_error, splice_failed)
1196611988
})?;
1196711989
let tx_msg_opt = interactive_tx_constructor.take_initiator_first_message();
1196811990

lightning/src/ln/channelmanager.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11526,7 +11526,26 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1152611526
msg, &self.signer_provider, &self.entropy_source,
1152711527
&self.get_our_node_id(), &self.logger
1152811528
);
11529-
let tx_msg_opt = try_channel_entry!(self, peer_state, splice_ack_res, chan_entry);
11529+
11530+
// Handle splice_ack failure and emit SpliceFailed event if needed
11531+
let tx_msg_opt = match splice_ack_res {
11532+
Ok(tx_msg_opt) => Ok(tx_msg_opt),
11533+
Err((channel_error, splice_funding_failed)) => {
11534+
let pending_events = &mut self.pending_events.lock().unwrap();
11535+
pending_events.push_back((events::Event::SpliceFailed {
11536+
channel_id: splice_funding_failed.channel_id,
11537+
counterparty_node_id: splice_funding_failed.counterparty_node_id,
11538+
user_channel_id: splice_funding_failed.user_channel_id,
11539+
funding_txo: splice_funding_failed.funding_txo,
11540+
channel_type: splice_funding_failed.channel_type,
11541+
contributed_inputs: splice_funding_failed.contributed_inputs,
11542+
contributed_outputs: splice_funding_failed.contributed_outputs,
11543+
}, None));
11544+
Err(channel_error)
11545+
}
11546+
};
11547+
11548+
let tx_msg_opt = try_channel_entry!(self, peer_state, tx_msg_opt, chan_entry);
1153011549
if let Some(tx_msg) = tx_msg_opt {
1153111550
peer_state.pending_msg_events.push(tx_msg.into_msg_send_event(counterparty_node_id.clone()));
1153211551
}

0 commit comments

Comments
 (0)