Skip to content

Commit 9d2802e

Browse files
committed
fix Build NegotiatingChannelView locally, to save an error check
1 parent c29a990 commit 9d2802e

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

lightning/src/ln/channel.rs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9236,10 +9236,20 @@ impl<SP: Deref> FundedChannel<SP> where
92369236

92379237
let splice_ack_msg = self.get_splice_ack(our_funding_contribution);
92389238

9239+
// Build NegotiatingChannelView lcoally, simmilar to Channel::as_renegotiating_channel()
9240+
let pending_splice_mut = &mut self.pending_splice.as_mut().unwrap(); // set above
9241+
let mut negotiating_view = NegotiatingChannelView {
9242+
context: &mut self.context,
9243+
funding: &mut pending_splice_mut.funding_scope.as_mut().unwrap(), // set above
9244+
funding_negotiation_context: &mut pending_splice_mut.funding_negotiation_context,
9245+
interactive_tx_constructor: &mut pending_splice_mut.interactive_tx_constructor,
9246+
interactive_tx_signing_session: &mut pending_splice_mut.interactive_tx_signing_session,
9247+
holder_commitment_transaction_number: self.holder_commitment_point.transaction_number(),
9248+
is_splice: true,
9249+
};
9250+
92399251
// Start interactive funding negotiation. No extra input, as we are not the splice initiator
9240-
let mut refunding = self.as_renegotiating_channel()
9241-
.map_err(|err| ChannelError::Warn(err.into()))?;
9242-
let _msg = refunding.begin_interactive_funding_tx_construction(signer_provider, entropy_source, holder_node_id.clone(), false, None, None)
9252+
let _msg = negotiating_view.begin_interactive_funding_tx_construction(signer_provider, entropy_source, holder_node_id.clone(), false, None, None)
92439253
.map_err(|err| ChannelError::Warn(format!("Failed to start interactive transaction construction, {:?}", err)))?;
92449254

92459255
Ok(splice_ack_msg)
@@ -9315,10 +9325,19 @@ impl<SP: Deref> FundedChannel<SP> where
93159325
log_info!(logger, "Splicing process started after splice_ack, new channel value {}, old {}, outgoing {}, channel_id {}",
93169326
post_channel_value, pre_channel_value, true, self.context.channel_id);
93179327

9328+
// Build NegotiatingChannelView lcoally, simmilar to Channel::as_renegotiating_channel()
9329+
let mut negotiating_view = NegotiatingChannelView {
9330+
context: &mut self.context,
9331+
funding: &mut pending_splice_mut.funding_scope.as_mut().unwrap(), // set above
9332+
funding_negotiation_context: &mut pending_splice_mut.funding_negotiation_context,
9333+
interactive_tx_constructor: &mut pending_splice_mut.interactive_tx_constructor,
9334+
interactive_tx_signing_session: &mut pending_splice_mut.interactive_tx_signing_session,
9335+
holder_commitment_transaction_number: self.holder_commitment_point.transaction_number(),
9336+
is_splice: true,
9337+
};
9338+
93189339
// Start interactive funding negotiation, with the previous funding transaction as an extra shared input
9319-
let mut refunding = self.as_renegotiating_channel()
9320-
.map_err(|err| ChannelError::Warn(err.into()))?;
9321-
let tx_msg_opt = refunding.begin_interactive_funding_tx_construction(signer_provider, entropy_source, holder_node_id.clone(), true, None, Some(prev_funding_input))
9340+
let tx_msg_opt = negotiating_view.begin_interactive_funding_tx_construction(signer_provider, entropy_source, holder_node_id.clone(), true, None, Some(prev_funding_input))
93229341
.map_err(|err| ChannelError::Warn(format!("V2 channel rejected due to sender error, {:?}", err)))?;
93239342
Ok(tx_msg_opt)
93249343
}

0 commit comments

Comments
 (0)