Skip to content

Commit 9b2e748

Browse files
committed
f - echo tx_abort even if no SpliceFailed event is generated
1 parent 4dc9f8b commit 9b2e748

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

lightning/src/ln/channel.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,7 @@ where
18151815

18161816
pub fn tx_abort<L: Deref>(
18171817
&mut self, msg: &msgs::TxAbort, logger: &L,
1818-
) -> Result<Option<(msgs::TxAbort, SpliceFundingFailed)>, ChannelError>
1818+
) -> Result<(Option<msgs::TxAbort>, Option<SpliceFundingFailed>), ChannelError>
18191819
where
18201820
L::Target: Logger,
18211821
{
@@ -1862,20 +1862,18 @@ where
18621862
},
18631863
};
18641864

1865-
let result = if should_ack {
1865+
let tx_abort = should_ack.then(|| {
18661866
let logger = WithChannelContext::from(logger, &self.context(), None);
18671867
let reason =
18681868
types::string::UntrustedString(String::from_utf8_lossy(&msg.data).to_string());
18691869
log_info!(logger, "Counterparty failed interactive transaction negotiation: {reason}");
1870-
let tx_abort_response = msgs::TxAbort {
1870+
msgs::TxAbort {
18711871
channel_id: msg.channel_id,
18721872
data: "Acknowledged tx_abort".to_string().into_bytes(),
1873-
};
1874-
splice_funding_failed.map(|failed| (tx_abort_response, failed))
1875-
} else {
1876-
None
1877-
};
1878-
Ok(result)
1873+
}
1874+
});
1875+
1876+
Ok((tx_abort, splice_funding_failed))
18791877
}
18801878

18811879
#[rustfmt::skip]

lightning/src/ln/channelmanager.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10505,10 +10505,22 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1050510505
match peer_state.channel_by_id.entry(msg.channel_id) {
1050610506
hash_map::Entry::Occupied(mut chan_entry) => {
1050710507
let res = chan_entry.get_mut().tx_abort(msg, &self.logger);
10508-
let tx_abort_and_splice_failed = try_channel_entry!(self, peer_state, res, chan_entry);
10508+
let (tx_abort, splice_failed) = try_channel_entry!(self, peer_state, res, chan_entry);
1050910509

10510-
// Emit SpliceFailed event and send TxAbort response if we had an active splice negotiation
10511-
if let Some((tx_abort_msg, splice_funding_failed)) = tx_abort_and_splice_failed {
10510+
let persist = if tx_abort.is_some() || splice_failed.is_some() {
10511+
NotifyOption::DoPersist
10512+
} else {
10513+
NotifyOption::SkipPersistNoEvents
10514+
};
10515+
10516+
if let Some(tx_abort_msg) = tx_abort {
10517+
peer_state.pending_msg_events.push(MessageSendEvent::SendTxAbort {
10518+
node_id: *counterparty_node_id,
10519+
msg: tx_abort_msg,
10520+
});
10521+
}
10522+
10523+
if let Some(splice_funding_failed) = splice_failed {
1051210524
let pending_events = &mut self.pending_events.lock().unwrap();
1051310525
pending_events.push_back((events::Event::SpliceFailed {
1051410526
channel_id: msg.channel_id,
@@ -10519,15 +10531,9 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1051910531
contributed_inputs: splice_funding_failed.contributed_inputs,
1052010532
contributed_outputs: splice_funding_failed.contributed_outputs,
1052110533
}, None));
10522-
10523-
peer_state.pending_msg_events.push(MessageSendEvent::SendTxAbort {
10524-
node_id: *counterparty_node_id,
10525-
msg: tx_abort_msg,
10526-
});
10527-
Ok(NotifyOption::DoPersist)
10528-
} else {
10529-
Ok(NotifyOption::SkipPersistNoEvents)
1053010534
}
10535+
10536+
Ok(persist)
1053110537
},
1053210538
hash_map::Entry::Vacant(_) => {
1053310539
Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", counterparty_node_id), msg.channel_id))

0 commit comments

Comments
 (0)