Skip to content

Commit 844fbb9

Browse files
committed
Don't close a funded channel on splice failure
If splicing fails, the previous funding is still usable. Convert any ChannelError::Close to ChannelClose::Warn when this is the case to avoid closing a usable channel.
1 parent 4ee380f commit 844fbb9

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

lightning/src/ln/channel.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,13 +1809,23 @@ where
18091809
{
18101810
let mut signing_session =
18111811
interactive_tx_constructor.into_signing_session();
1812-
let (commitment_signed, event) = chan.context.funding_tx_constructed(
1813-
&mut funding,
1814-
&mut signing_session,
1815-
true,
1816-
chan.holder_commitment_point.transaction_number(),
1817-
&&logger,
1818-
)?;
1812+
let (commitment_signed, event) = chan
1813+
.context
1814+
.funding_tx_constructed(
1815+
&mut funding,
1816+
&mut signing_session,
1817+
true,
1818+
chan.holder_commitment_point.transaction_number(),
1819+
&&logger,
1820+
)
1821+
// Don't close a funded channel if splicing fails
1822+
.map_err(|e| {
1823+
if let ChannelError::Close((message, _)) = e {
1824+
ChannelError::Warn(message)
1825+
} else {
1826+
e
1827+
}
1828+
})?;
18191829

18201830
chan.interactive_tx_signing_session = Some(signing_session);
18211831
pending_splice.funding_negotiation =

lightning/src/ln/channelmanager.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9730,10 +9730,12 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
97309730
peer_state.pending_msg_events.push(msg_send_event);
97319731
};
97329732
if negotiation_complete {
9733-
let (commitment_signed, funding_ready_for_sig_event_opt) = chan_entry
9734-
.get_mut()
9735-
.funding_tx_constructed(&self.logger)
9736-
.map_err(|err| MsgHandleErrInternal::send_err_msg_no_close(format!("{}", err), msg.channel_id))?;
9733+
let (commitment_signed, funding_ready_for_sig_event_opt) = try_channel_entry!(
9734+
self,
9735+
peer_state,
9736+
chan_entry.get_mut().funding_tx_constructed(&self.logger),
9737+
chan_entry
9738+
);
97379739
if let Some(funding_ready_for_sig_event) = funding_ready_for_sig_event_opt {
97389740
let mut pending_events = self.pending_events.lock().unwrap();
97399741
pending_events.push_back((funding_ready_for_sig_event, None));

0 commit comments

Comments
 (0)