Skip to content

Commit 3536ee3

Browse files
committed
fix Minor review changes, error handling and persist flags
1 parent 797ce20 commit 3536ee3

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
@@ -8473,15 +8473,11 @@ impl<SP: Deref> FundedChannel<SP> where
84738473
)));
84748474
}
84758475

8476-
if !self.context.is_live() {
8477-
return Err(ChannelError::Warn(format!("Splicing requested on a channel that is not live")));
8478-
}
8479-
84808476
// - If it has received shutdown:
84818477
// MUST send a warning and close the connection or send an error
84828478
// and fail the channel.
8483-
if self.context.channel_state.is_remote_shutdown_sent() {
8484-
return Err(ChannelError::close("Got splice_init when channel was not in an operational state".to_owned()));
8479+
if !self.context.is_live() {
8480+
return Err(ChannelError::Warn(format!("Splicing requested on a channel that is not live")));
84858481
}
84868482

84878483
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
@@ -4285,7 +4285,9 @@ where
42854285
/// After completion of splicing, the funding transaction will be replaced by a new one, spending the old funding transaction,
42864286
/// with optional extra inputs (splice-in) and/or extra outputs (splice-out or change).
42874287
/// TODO(splicing): Implementation is currently incomplete.
4288+
///
42884289
/// Note: Currently only splice-in is supported (increase in channel capacity), splice-out is not.
4290+
///
42894291
/// - our_funding_contribution_satoshis: the amount contributed by us to the channel. This will increase our channel balance.
42904292
/// - our_funding_inputs: the funding inputs provided by us. If our contribution is positive, our funding inputs must cover at least that amount.
42914293
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
@@ -9566,17 +9568,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
95669568
), msg.channel_id)),
95679569
hash_map::Entry::Occupied(mut chan_entry) => {
95689570
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
9569-
match chan.splice_init(msg) {
9570-
Ok(splice_ack_msg) => {
9571-
peer_state.pending_msg_events.push(events::MessageSendEvent::SendSpliceAck {
9572-
node_id: *counterparty_node_id,
9573-
msg: splice_ack_msg,
9574-
});
9575-
},
9576-
Err(err) => {
9577-
try_channel_entry!(self, peer_state, Err(err), chan_entry)
9578-
}
9579-
}
9571+
let splice_ack_msg = try_channel_entry!(self, peer_state, chan.splice_init(msg), chan_entry);
9572+
peer_state.pending_msg_events.push(events::MessageSendEvent::SendSpliceAck {
9573+
node_id: *counterparty_node_id,
9574+
msg: splice_ack_msg,
9575+
});
95809576
} else {
95819577
return Err(MsgHandleErrInternal::send_err_msg_no_close("Channel is not funded, cannot be spliced".to_owned(), msg.channel_id));
95829578
}
@@ -9611,12 +9607,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
96119607
), msg.channel_id)),
96129608
hash_map::Entry::Occupied(mut chan_entry) => {
96139609
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
9614-
match chan.splice_ack(msg) {
9615-
Ok(_) => {}
9616-
Err(err) => {
9617-
try_channel_entry!(self, peer_state, Err(err), chan_entry)
9618-
}
9619-
}
9610+
try_channel_entry!(self, peer_state, chan.splice_ack(msg), chan_entry);
96209611
} else {
96219612
return Err(MsgHandleErrInternal::send_err_msg_no_close("Channel is not funded, cannot splice".to_owned(), msg.channel_id));
96229613
}
@@ -11917,7 +11908,7 @@ where
1191711908
let persist = match &res {
1191811909
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
1191911910
Err(_) => NotifyOption::SkipPersistHandleEvents,
11920-
Ok(()) => NotifyOption::SkipPersistNoEvents,
11911+
Ok(()) => NotifyOption::SkipPersistHandleEvents,
1192111912
};
1192211913
let _ = handle_error!(self, res, counterparty_node_id);
1192311914
persist
@@ -11931,7 +11922,7 @@ where
1193111922
let persist = match &res {
1193211923
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
1193311924
Err(_) => NotifyOption::SkipPersistHandleEvents,
11934-
Ok(()) => NotifyOption::SkipPersistNoEvents,
11925+
Ok(()) => NotifyOption::SkipPersistHandleEvents,
1193511926
};
1193611927
let _ = handle_error!(self, res, counterparty_node_id);
1193711928
persist

0 commit comments

Comments
 (0)