Skip to content

Commit ae99b62

Browse files
committed
fix Minor fixes, nits, error handling simplifications
1 parent cd0fe0e commit ae99b62

File tree

2 files changed

+16
-38
lines changed

2 files changed

+16
-38
lines changed

lightning/src/ln/channel.rs

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,13 +1783,10 @@ where
17831783
L::Target: Logger,
17841784
{
17851785
let logger = WithChannelContext::from(logger, self.context(), None);
1786-
if let Ok(mut negotiating_channel) = self.as_negotiating_channel() {
1787-
let (commitment_signed, event) =
1788-
negotiating_channel.funding_tx_constructed(signing_session, &&logger)?;
1789-
Ok((commitment_signed, event))
1790-
} else {
1791-
Err(ChannelError::Warn("Got a tx_complete message with no interactive transaction construction expected or in-progress".to_owned()))
1792-
}
1786+
let mut negotiating_channel = self.as_negotiating_channel()?;
1787+
let (commitment_signed, event) =
1788+
negotiating_channel.funding_tx_constructed(signing_session, &&logger)?;
1789+
Ok((commitment_signed, event))
17931790
}
17941791

17951792
pub fn force_shutdown(
@@ -2198,45 +2195,26 @@ impl FundingScope {
21982195
{
21992196
let post_value_to_self_msat_signed = (prev_funding.value_to_self_msat as i64)
22002197
.saturating_add(our_funding_contribution_sats * 1000);
2201-
if post_value_to_self_msat_signed < 0 {
2202-
// Splice out and more than our balance, error
2203-
return Err(ChannelError::Warn(format!(
2204-
"Cannot splice out more than the current balance, {} sats, {} msats",
2205-
post_value_to_self_msat_signed, prev_funding.value_to_self_msat
2206-
)));
2207-
}
22082198
debug_assert!(post_value_to_self_msat_signed >= 0);
22092199
let post_value_to_self_msat = post_value_to_self_msat_signed as u64;
22102200

2211-
let prev_funding_txid = prev_funding
2212-
.channel_transaction_parameters
2213-
.funding_outpoint
2214-
.map(|outpoint| outpoint.txid);
2201+
let prev_funding_txid = prev_funding.get_funding_txid();
22152202
let holder_pubkeys = match &context.holder_signer {
22162203
ChannelSignerType::Ecdsa(ecdsa) => ecdsa.pubkeys(prev_funding_txid, &context.secp_ctx),
22172204
// TODO (taproot|arik)
22182205
#[cfg(taproot)]
22192206
_ => todo!(),
22202207
};
2208+
let channel_parameters = &prev_funding.channel_transaction_parameters;
22212209
let mut post_channel_transaction_parameters = ChannelTransactionParameters {
22222210
holder_pubkeys,
2223-
holder_selected_contest_delay: prev_funding
2224-
.channel_transaction_parameters
2225-
.holder_selected_contest_delay,
2211+
holder_selected_contest_delay: channel_parameters.holder_selected_contest_delay,
22262212
// The 'outbound' attribute doesn't change, even if the splice initiator is the other node
2227-
is_outbound_from_holder: prev_funding
2228-
.channel_transaction_parameters
2229-
.is_outbound_from_holder,
2230-
counterparty_parameters: prev_funding
2231-
.channel_transaction_parameters
2232-
.counterparty_parameters
2233-
.clone(),
2213+
is_outbound_from_holder: channel_parameters.is_outbound_from_holder,
2214+
counterparty_parameters: channel_parameters.counterparty_parameters.clone(),
22342215
funding_outpoint: None, // filled later
22352216
splice_parent_funding_txid: prev_funding_txid,
2236-
channel_type_features: prev_funding
2237-
.channel_transaction_parameters
2238-
.channel_type_features
2239-
.clone(),
2217+
channel_type_features: channel_parameters.channel_type_features.clone(),
22402218
channel_value_satoshis: post_channel_value,
22412219
};
22422220
// Update the splicing 'tweak', this will rotate the keys in the signer
@@ -2897,7 +2875,7 @@ where
28972875
/// Can be produced by:
28982876
/// - [`PendingV2Channel`], at V2 channel open, and
28992877
/// - [`FundedChannel`], when splicing.
2900-
pub struct NegotiatingChannelView<'a, SP: Deref>
2878+
pub(super) struct NegotiatingChannelView<'a, SP: Deref>
29012879
where
29022880
SP::Target: SignerProvider,
29032881
{

lightning/src/ln/channelmanager.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10125,11 +10125,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1012510125
), msg.channel_id)),
1012610126
hash_map::Entry::Occupied(mut chan_entry) => {
1012710127
if let Some(ref mut funded_channel) = chan_entry.get_mut().as_funded_mut() {
10128-
let splice_ack_msg = try_channel_entry!(self, peer_state,
10129-
funded_channel.splice_init(
10130-
msg, our_funding_contribution, &self.signer_provider, &self.entropy_source,
10131-
&self.get_our_node_id(), &self.logger
10132-
), chan_entry);
10128+
let init_res = funded_channel.splice_init(
10129+
msg, our_funding_contribution, &self.signer_provider, &self.entropy_source,
10130+
&self.get_our_node_id(), &self.logger
10131+
);
10132+
let splice_ack_msg = try_channel_entry!(self, peer_state, init_res, chan_entry);
1013310133
peer_state.pending_msg_events.push(MessageSendEvent::SendSpliceAck {
1013410134
node_id: *counterparty_node_id,
1013510135
msg: splice_ack_msg,

0 commit comments

Comments
 (0)