Skip to content

Commit 2d8642a

Browse files
committed
fix Minor review changes, error handling and persist flags
1 parent 6d5edfa commit 2d8642a

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
@@ -8280,15 +8280,11 @@ impl<SP: Deref> FundedChannel<SP> where
82808280
)));
82818281
}
82828282

8283-
if !self.context.is_live() {
8284-
return Err(ChannelError::Warn(format!("Splicing requested on a channel that is not live")));
8285-
}
8286-
82878283
// - If it has received shutdown:
82888284
// MUST send a warning and close the connection or send an error
82898285
// and fail the channel.
8290-
if self.context.channel_state.is_remote_shutdown_sent() {
8291-
return Err(ChannelError::close("Got splice_init when channel was not in an operational state".to_owned()));
8286+
if !self.context.is_live() {
8287+
return Err(ChannelError::Warn(format!("Splicing requested on a channel that is not live")));
82928288
}
82938289

82948290
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
@@ -4272,7 +4272,9 @@ where
42724272
/// After completion of splicing, the funding transaction will be replaced by a new one, spending the old funding transaction,
42734273
/// with optional extra inputs (splice-in) and/or extra outputs (splice-out or change).
42744274
/// TODO(splicing): Implementation is currently incomplete.
4275+
///
42754276
/// Note: Currently only splice-in is supported (increase in channel capacity), splice-out is not.
4277+
///
42764278
/// - our_funding_contribution_satoshis: the amount contributed by us to the channel. This will increase our channel balance.
42774279
/// - our_funding_inputs: the funding inputs provided by us. If our contribution is positive, our funding inputs must cover at least that amount.
42784280
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
@@ -9499,17 +9501,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
94999501
), msg.channel_id)),
95009502
hash_map::Entry::Occupied(mut chan_entry) => {
95019503
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
9502-
match chan.splice_init(msg) {
9503-
Ok(splice_ack_msg) => {
9504-
peer_state.pending_msg_events.push(events::MessageSendEvent::SendSpliceAck {
9505-
node_id: *counterparty_node_id,
9506-
msg: splice_ack_msg,
9507-
});
9508-
},
9509-
Err(err) => {
9510-
try_channel_entry!(self, peer_state, Err(err), chan_entry)
9511-
}
9512-
}
9504+
let splice_ack_msg = try_channel_entry!(self, peer_state, chan.splice_init(msg), chan_entry);
9505+
peer_state.pending_msg_events.push(events::MessageSendEvent::SendSpliceAck {
9506+
node_id: *counterparty_node_id,
9507+
msg: splice_ack_msg,
9508+
});
95139509
} else {
95149510
return Err(MsgHandleErrInternal::send_err_msg_no_close("Channel is not funded, cannot be spliced".to_owned(), msg.channel_id));
95159511
}
@@ -9544,12 +9540,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
95449540
), msg.channel_id)),
95459541
hash_map::Entry::Occupied(mut chan_entry) => {
95469542
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
9547-
match chan.splice_ack(msg) {
9548-
Ok(_) => {}
9549-
Err(err) => {
9550-
try_channel_entry!(self, peer_state, Err(err), chan_entry)
9551-
}
9552-
}
9543+
try_channel_entry!(self, peer_state, chan.splice_ack(msg), chan_entry);
95539544
} else {
95549545
return Err(MsgHandleErrInternal::send_err_msg_no_close("Channel is not funded, cannot splice".to_owned(), msg.channel_id));
95559546
}
@@ -11724,7 +11715,7 @@ where
1172411715
let persist = match &res {
1172511716
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
1172611717
Err(_) => NotifyOption::SkipPersistHandleEvents,
11727-
Ok(()) => NotifyOption::SkipPersistNoEvents,
11718+
Ok(()) => NotifyOption::SkipPersistHandleEvents,
1172811719
};
1172911720
let _ = handle_error!(self, res, counterparty_node_id);
1173011721
persist
@@ -11738,7 +11729,7 @@ where
1173811729
let persist = match &res {
1173911730
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
1174011731
Err(_) => NotifyOption::SkipPersistHandleEvents,
11741-
Ok(()) => NotifyOption::SkipPersistNoEvents,
11732+
Ok(()) => NotifyOption::SkipPersistHandleEvents,
1174211733
};
1174311734
let _ = handle_error!(self, res, counterparty_node_id);
1174411735
persist

0 commit comments

Comments
 (0)