Skip to content

Commit 21cb2b1

Browse files
committed
fix Minor fixes, nits, error handling simplifications
1 parent 762addf commit 21cb2b1

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
@@ -1781,13 +1781,10 @@ where
17811781
L::Target: Logger,
17821782
{
17831783
let logger = WithChannelContext::from(logger, self.context(), None);
1784-
if let Ok(mut negotiating_channel) = self.as_negotiating_channel() {
1785-
let (commitment_signed, event) =
1786-
negotiating_channel.funding_tx_constructed(signing_session, &&logger)?;
1787-
Ok((commitment_signed, event))
1788-
} else {
1789-
Err(ChannelError::Warn("Got a tx_complete message with no interactive transaction construction expected or in-progress".to_owned()))
1790-
}
1784+
let mut negotiating_channel = self.as_negotiating_channel()?;
1785+
let (commitment_signed, event) =
1786+
negotiating_channel.funding_tx_constructed(signing_session, &&logger)?;
1787+
Ok((commitment_signed, event))
17911788
}
17921789

17931790
pub fn force_shutdown(
@@ -2171,45 +2168,26 @@ impl FundingScope {
21712168
{
21722169
let post_value_to_self_msat_signed = (prev_funding.value_to_self_msat as i64)
21732170
.saturating_add(our_funding_contribution_sats * 1000);
2174-
if post_value_to_self_msat_signed < 0 {
2175-
// Splice out and more than our balance, error
2176-
return Err(ChannelError::Warn(format!(
2177-
"Cannot splice out more than the current balance, {} sats, {} msats",
2178-
post_value_to_self_msat_signed, prev_funding.value_to_self_msat
2179-
)));
2180-
}
21812171
debug_assert!(post_value_to_self_msat_signed >= 0);
21822172
let post_value_to_self_msat = post_value_to_self_msat_signed as u64;
21832173

2184-
let prev_funding_txid = prev_funding
2185-
.channel_transaction_parameters
2186-
.funding_outpoint
2187-
.map(|outpoint| outpoint.txid);
2174+
let prev_funding_txid = prev_funding.get_funding_txid();
21882175
let holder_pubkeys = match &context.holder_signer {
21892176
ChannelSignerType::Ecdsa(ecdsa) => ecdsa.pubkeys(prev_funding_txid, &context.secp_ctx),
21902177
// TODO (taproot|arik)
21912178
#[cfg(taproot)]
21922179
_ => todo!(),
21932180
};
2181+
let channel_parameters = &prev_funding.channel_transaction_parameters;
21942182
let mut post_channel_transaction_parameters = ChannelTransactionParameters {
21952183
holder_pubkeys,
2196-
holder_selected_contest_delay: prev_funding
2197-
.channel_transaction_parameters
2198-
.holder_selected_contest_delay,
2184+
holder_selected_contest_delay: channel_parameters.holder_selected_contest_delay,
21992185
// The 'outbound' attribute doesn't change, even if the splice initiator is the other node
2200-
is_outbound_from_holder: prev_funding
2201-
.channel_transaction_parameters
2202-
.is_outbound_from_holder,
2203-
counterparty_parameters: prev_funding
2204-
.channel_transaction_parameters
2205-
.counterparty_parameters
2206-
.clone(),
2186+
is_outbound_from_holder: channel_parameters.is_outbound_from_holder,
2187+
counterparty_parameters: channel_parameters.counterparty_parameters.clone(),
22072188
funding_outpoint: None, // filled later
22082189
splice_parent_funding_txid: prev_funding_txid,
2209-
channel_type_features: prev_funding
2210-
.channel_transaction_parameters
2211-
.channel_type_features
2212-
.clone(),
2190+
channel_type_features: channel_parameters.channel_type_features.clone(),
22132191
channel_value_satoshis: post_channel_value,
22142192
};
22152193
// Update the splicing 'tweak', this will rotate the keys in the signer
@@ -2870,7 +2848,7 @@ where
28702848
/// Can be produced by:
28712849
/// - [`PendingV2Channel`], at V2 channel open, and
28722850
/// - [`FundedChannel`], when splicing.
2873-
pub struct NegotiatingChannelView<'a, SP: Deref>
2851+
pub(super) struct NegotiatingChannelView<'a, SP: Deref>
28742852
where
28752853
SP::Target: SignerProvider,
28762854
{

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)