Skip to content

Commit 2e4406b

Browse files
committed
fix Minor review changes, error handling and persist flags
1 parent a1bbd03 commit 2e4406b

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
@@ -8519,15 +8519,11 @@ impl<SP: Deref> FundedChannel<SP> where
85198519
)));
85208520
}
85218521

8522-
if !self.context.is_live() {
8523-
return Err(ChannelError::Warn(format!("Splicing requested on a channel that is not live")));
8524-
}
8525-
85268522
// - If it has received shutdown:
85278523
// MUST send a warning and close the connection or send an error
85288524
// and fail the channel.
8529-
if self.context.channel_state.is_remote_shutdown_sent() {
8530-
return Err(ChannelError::close("Got splice_init when channel was not in an operational state".to_owned()));
8525+
if !self.context.is_live() {
8526+
return Err(ChannelError::Warn(format!("Splicing requested on a channel that is not live")));
85318527
}
85328528

85338529
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
@@ -4286,7 +4286,9 @@ where
42864286
/// After completion of splicing, the funding transaction will be replaced by a new one, spending the old funding transaction,
42874287
/// with optional extra inputs (splice-in) and/or extra outputs (splice-out or change).
42884288
/// TODO(splicing): Implementation is currently incomplete.
4289+
///
42894290
/// Note: Currently only splice-in is supported (increase in channel capacity), splice-out is not.
4291+
///
42904292
/// - our_funding_contribution_satoshis: the amount contributed by us to the channel. This will increase our channel balance.
42914293
/// - our_funding_inputs: the funding inputs provided by us. If our contribution is positive, our funding inputs must cover at least that amount.
42924294
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
@@ -9556,17 +9558,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
95569558
), msg.channel_id)),
95579559
hash_map::Entry::Occupied(mut chan_entry) => {
95589560
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
9559-
match chan.splice_init(msg) {
9560-
Ok(splice_ack_msg) => {
9561-
peer_state.pending_msg_events.push(events::MessageSendEvent::SendSpliceAck {
9562-
node_id: *counterparty_node_id,
9563-
msg: splice_ack_msg,
9564-
});
9565-
},
9566-
Err(err) => {
9567-
try_channel_entry!(self, peer_state, Err(err), chan_entry)
9568-
}
9569-
}
9561+
let splice_ack_msg = try_channel_entry!(self, peer_state, chan.splice_init(msg), chan_entry);
9562+
peer_state.pending_msg_events.push(events::MessageSendEvent::SendSpliceAck {
9563+
node_id: *counterparty_node_id,
9564+
msg: splice_ack_msg,
9565+
});
95709566
} else {
95719567
return Err(MsgHandleErrInternal::send_err_msg_no_close("Channel is not funded, cannot be spliced".to_owned(), msg.channel_id));
95729568
}
@@ -9601,12 +9597,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
96019597
), msg.channel_id)),
96029598
hash_map::Entry::Occupied(mut chan_entry) => {
96039599
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
9604-
match chan.splice_ack(msg) {
9605-
Ok(_) => {}
9606-
Err(err) => {
9607-
try_channel_entry!(self, peer_state, Err(err), chan_entry)
9608-
}
9609-
}
9600+
try_channel_entry!(self, peer_state, chan.splice_ack(msg), chan_entry);
96109601
} else {
96119602
return Err(MsgHandleErrInternal::send_err_msg_no_close("Channel is not funded, cannot splice".to_owned(), msg.channel_id));
96129603
}
@@ -11903,7 +11894,7 @@ where
1190311894
let persist = match &res {
1190411895
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
1190511896
Err(_) => NotifyOption::SkipPersistHandleEvents,
11906-
Ok(()) => NotifyOption::SkipPersistNoEvents,
11897+
Ok(()) => NotifyOption::SkipPersistHandleEvents,
1190711898
};
1190811899
let _ = handle_error!(self, res, counterparty_node_id);
1190911900
persist
@@ -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

0 commit comments

Comments
 (0)