Skip to content

Commit e09137b

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 0751efd commit e09137b

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
@@ -11879,12 +11879,23 @@ where
1187911879
pub(crate) fn splice_ack<ES: Deref, L: Deref>(
1188011880
&mut self, msg: &msgs::SpliceAck, signer_provider: &SP, entropy_source: &ES,
1188111881
holder_node_id: &PublicKey, logger: &L,
11882-
) -> Result<Option<InteractiveTxMessageSend>, ChannelError>
11882+
) -> Result<Option<InteractiveTxMessageSend>, (ChannelError, SpliceFundingFailed)>
1188311883
where
1188411884
ES::Target: EntropySource,
1188511885
L::Target: Logger,
1188611886
{
11887-
let splice_funding = self.validate_splice_ack(msg)?;
11887+
let splice_funding = self.validate_splice_ack(msg).map_err(|err| {
11888+
let splice_failed = SpliceFundingFailed {
11889+
channel_id: self.context.channel_id,
11890+
counterparty_node_id: self.context.counterparty_node_id,
11891+
user_channel_id: self.context.user_id,
11892+
funding_txo: None,
11893+
channel_type: None,
11894+
contributed_inputs: Vec::new(),
11895+
contributed_outputs: Vec::new(),
11896+
};
11897+
(err, splice_failed)
11898+
})?;
1188811899

1188911900
log_info!(
1189011901
logger,
@@ -11914,10 +11925,20 @@ where
1191411925
holder_node_id.clone(),
1191511926
)
1191611927
.map_err(|err| {
11917-
ChannelError::WarnAndDisconnect(format!(
11928+
let splice_failed = SpliceFundingFailed {
11929+
channel_id: self.context.channel_id,
11930+
counterparty_node_id: self.context.counterparty_node_id,
11931+
user_channel_id: self.context.user_id,
11932+
funding_txo: splice_funding.get_funding_txo().map(|txo| txo.into_bitcoin_outpoint()),
11933+
channel_type: Some(splice_funding.get_channel_type().clone()),
11934+
contributed_inputs: Vec::new(),
11935+
contributed_outputs: Vec::new(),
11936+
};
11937+
let channel_error = ChannelError::WarnAndDisconnect(format!(
1191811938
"Failed to start interactive transaction construction, {:?}",
1191911939
err
11920-
))
11940+
));
11941+
(channel_error, splice_failed)
1192111942
})?;
1192211943
let tx_msg_opt = interactive_tx_constructor.take_initiator_first_message();
1192311944

lightning/src/ln/channelmanager.rs

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

0 commit comments

Comments
 (0)