Skip to content

Commit 3fb8b5f

Browse files
committed
fix Minor review changes, error handling and persist flags
1 parent dbe0281 commit 3fb8b5f

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

lightning/src/ln/channel.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8343,15 +8343,11 @@ impl<SP: Deref> FundedChannel<SP> where
83438343
)));
83448344
}
83458345

8346-
if !self.context.is_live() {
8347-
return Err(ChannelError::Warn(format!("Splicing requested on a channel that is not live")));
8348-
}
8349-
83508346
// - If it has received shutdown:
83518347
// MUST send a warning and close the connection or send an error
83528348
// and fail the channel.
8353-
if self.context.channel_state.is_remote_shutdown_sent() {
8354-
return Err(ChannelError::close("Got splice_init when channel was not in an operational state".to_owned()));
8349+
if !self.context.is_live() {
8350+
return Err(ChannelError::Warn(format!("Splicing requested on a channel that is not live")));
83558351
}
83568352

83578353
if their_funding_contribution_satoshis.saturating_add(our_funding_contribution_satoshis) < 0 {

lightning/src/ln/channelmanager.rs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4273,7 +4273,9 @@ where
42734273
/// After completion of splicing, the funding transaction will be replaced by a new one, spending the old funding transaction,
42744274
/// with optional extra inputs (splice-in) and/or extra outputs (splice-out or change).
42754275
/// TODO(splicing): Implementation is currently incomplete.
4276+
///
42764277
/// Note: Currently only splice-in is supported (increase in channel capacity), splice-out is not.
4278+
///
42774279
/// - our_funding_contribution_satoshis: the amount contributed by us to the channel. This will increase our channel balance.
42784280
/// - our_funding_inputs: the funding inputs provided by us. If our contribution is positive, our funding inputs must cover at least that amount.
42794281
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
@@ -9500,17 +9502,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
95009502
), msg.channel_id)),
95019503
hash_map::Entry::Occupied(mut chan_entry) => {
95029504
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
9503-
match chan.splice_init(msg) {
9504-
Ok(splice_ack_msg) => {
9505-
peer_state.pending_msg_events.push(events::MessageSendEvent::SendSpliceAck {
9506-
node_id: *counterparty_node_id,
9507-
msg: splice_ack_msg,
9508-
});
9509-
},
9510-
Err(err) => {
9511-
try_channel_entry!(self, peer_state, Err(err), chan_entry)
9512-
}
9513-
}
9505+
let splice_ack_msg = try_channel_entry!(self, peer_state, chan.splice_init(msg), chan_entry);
9506+
peer_state.pending_msg_events.push(events::MessageSendEvent::SendSpliceAck {
9507+
node_id: *counterparty_node_id,
9508+
msg: splice_ack_msg,
9509+
});
95149510
} else {
95159511
return Err(MsgHandleErrInternal::send_err_msg_no_close("Channel is not funded, cannot be spliced".to_owned(), msg.channel_id));
95169512
}
@@ -9545,12 +9541,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
95459541
), msg.channel_id)),
95469542
hash_map::Entry::Occupied(mut chan_entry) => {
95479543
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
9548-
match chan.splice_ack(msg) {
9549-
Ok(_) => {}
9550-
Err(err) => {
9551-
try_channel_entry!(self, peer_state, Err(err), chan_entry)
9552-
}
9553-
}
9544+
try_channel_entry!(self, peer_state, chan.splice_ack(msg), chan_entry);
95549545
} else {
95559546
return Err(MsgHandleErrInternal::send_err_msg_no_close("Channel is not funded, cannot splice".to_owned(), msg.channel_id));
95569547
}
@@ -11725,7 +11716,7 @@ where
1172511716
let persist = match &res {
1172611717
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
1172711718
Err(_) => NotifyOption::SkipPersistHandleEvents,
11728-
Ok(()) => NotifyOption::SkipPersistNoEvents,
11719+
Ok(()) => NotifyOption::SkipPersistHandleEvents,
1172911720
};
1173011721
let _ = handle_error!(self, res, counterparty_node_id);
1173111722
persist
@@ -11739,7 +11730,7 @@ where
1173911730
let persist = match &res {
1174011731
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
1174111732
Err(_) => NotifyOption::SkipPersistHandleEvents,
11742-
Ok(()) => NotifyOption::SkipPersistNoEvents,
11733+
Ok(()) => NotifyOption::SkipPersistHandleEvents,
1174311734
};
1174411735
let _ = handle_error!(self, res, counterparty_node_id);
1174511736
persist

0 commit comments

Comments
 (0)