@@ -2280,8 +2280,8 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22802280 // Add output for funding tx
22812281 let mut funding_outputs = Vec::new();
22822282 let funding_output_value_satoshis = self.funding.get_value_satoshis();
2283- let funding_output_script_pubkey = self.context .get_funding_redeemscript().to_p2wsh();
2284- let expected_remote_shared_funding_output = if self.context .is_outbound() {
2283+ let funding_output_script_pubkey = self.funding .get_funding_redeemscript().to_p2wsh();
2284+ let expected_remote_shared_funding_output = if self.funding .is_outbound() {
22852285 let tx_out = TxOut {
22862286 value: Amount::from_sat(funding_output_value_satoshis),
22872287 script_pubkey: funding_output_script_pubkey,
@@ -2302,7 +2302,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
23022302
23032303 // Optionally add change output
23042304 if let Some(change_value) = calculate_change_output_value(
2305- self.context .is_outbound(), self.dual_funding_context.our_funding_satoshis,
2305+ self.funding .is_outbound(), self.dual_funding_context.our_funding_satoshis,
23062306 &funding_inputs_prev_outputs, &funding_outputs,
23072307 self.dual_funding_context.funding_feerate_sat_per_1000_weight,
23082308 self.context.holder_dust_limit_satoshis,
@@ -2327,7 +2327,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
23272327 counterparty_node_id: self.context.counterparty_node_id,
23282328 channel_id: self.context.channel_id(),
23292329 feerate_sat_per_kw: self.dual_funding_context.funding_feerate_sat_per_1000_weight,
2330- is_initiator: self.context .is_outbound(),
2330+ is_initiator: self.funding .is_outbound(),
23312331 funding_tx_locktime: self.dual_funding_context.funding_tx_locktime,
23322332 inputs_to_contribute: funding_inputs,
23332333 outputs_to_contribute: funding_outputs,
@@ -2507,6 +2507,56 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
25072507 }
25082508}
25092509
2510+ /*
2511+ impl<SP: Deref> InteractivelyFunded<SP> for OutboundV2Channel<SP> where SP::Target: SignerProvider {
2512+ fn context(&self) -> &ChannelContext<SP> {
2513+ &self.context
2514+ }
2515+ fn context_mut(&mut self) -> &mut ChannelContext<SP> {
2516+ &mut self.context
2517+ }
2518+ fn dual_funding_context(&self) -> &DualFundingChannelContext {
2519+ &self.dual_funding_context
2520+ }
2521+ fn dual_funding_context_mut(&mut self) -> &mut DualFundingChannelContext {
2522+ &mut self.dual_funding_context
2523+ }
2524+ fn unfunded_context(&self) -> &UnfundedChannelContext {
2525+ &self.unfunded_context
2526+ }
2527+ fn interactive_tx_constructor_mut(&mut self) -> &mut Option<InteractiveTxConstructor> {
2528+ &mut self.interactive_tx_constructor
2529+ }
2530+ fn is_initiator(&self) -> bool {
2531+ true
2532+ }
2533+ }
2534+
2535+ impl<SP: Deref> InteractivelyFunded<SP> for InboundV2Channel<SP> where SP::Target: SignerProvider {
2536+ fn context(&self) -> &ChannelContext<SP> {
2537+ &self.context
2538+ }
2539+ fn context_mut(&mut self) -> &mut ChannelContext<SP> {
2540+ &mut self.context
2541+ }
2542+ fn dual_funding_context(&self) -> &DualFundingChannelContext {
2543+ &self.dual_funding_context
2544+ }
2545+ fn dual_funding_context_mut(&mut self) -> &mut DualFundingChannelContext {
2546+ &mut self.dual_funding_context
2547+ }
2548+ fn unfunded_context(&self) -> &UnfundedChannelContext {
2549+ &self.unfunded_context
2550+ }
2551+ fn interactive_tx_constructor_mut(&mut self) -> &mut Option<InteractiveTxConstructor> {
2552+ &mut self.interactive_tx_constructor
2553+ }
2554+ fn is_initiator(&self) -> bool {
2555+ false
2556+ }
2557+ }
2558+ */
2559+
25102560impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
25112561 fn new_for_inbound_channel<'a, ES: Deref, F: Deref, L: Deref>(
25122562 fee_estimator: &'a LowerBoundedFeeEstimator<F>,
@@ -4737,38 +4787,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
47374787 self.counterparty_cur_commitment_point = Some(counterparty_cur_commitment_point_override);
47384788 self.get_initial_counterparty_commitment_signature(funding, logger)
47394789 }
4740-
4741- /// Get the splice message that can be sent during splice initiation.
4742- #[cfg(splicing)]
4743- pub fn get_splice_init(&self, our_funding_contribution_satoshis: i64,
4744- funding_feerate_perkw: u32, locktime: u32,
4745- ) -> msgs::SpliceInit {
4746- // Reuse the existing funding pubkey, in spite of the channel value changing
4747- // (though at this point we don't know the new value yet, due tue the optional counterparty contribution)
4748- // Note that channel_keys_id is supposed NOT to change
4749- let funding_pubkey = self.get_holder_pubkeys().funding_pubkey.clone();
4750- msgs::SpliceInit {
4751- channel_id: self.channel_id,
4752- funding_contribution_satoshis: our_funding_contribution_satoshis,
4753- funding_feerate_perkw,
4754- locktime,
4755- funding_pubkey,
4756- require_confirmed_inputs: None,
4757- }
4758- }
4759-
4760- /// Get the splice_ack message that can be sent in response to splice initiation.
4761- #[cfg(splicing)]
4762- pub fn get_splice_ack(&self, our_funding_contribution_satoshis: i64) -> msgs::SpliceAck {
4763- // Reuse the existing funding pubkey, in spite of the channel value changing
4764- let funding_pubkey = self.get_holder_pubkeys().funding_pubkey;
4765- msgs::SpliceAck {
4766- channel_id: self.channel_id,
4767- funding_contribution_satoshis: our_funding_contribution_satoshis,
4768- funding_pubkey,
4769- require_confirmed_inputs: None,
4770- }
4771- }
47724790}
47734791
47744792// Internal utility functions for channels
@@ -4860,7 +4878,6 @@ pub(super) struct DualFundingChannelContext {
48604878 /// The amount in satoshis we will be contributing to the channel.
48614879 pub our_funding_satoshis: u64,
48624880 /// The amount in satoshis our counterparty will be contributing to the channel.
4863- #[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
48644881 pub their_funding_satoshis: Option<u64>,
48654882 /// The funding transaction locktime suggested by the initiator. If set by us, it is always set
48664883 /// to the current block height to align incentives against fee-sniping.
@@ -8578,10 +8595,29 @@ impl<SP: Deref> FundedChannel<SP> where
85788595 our_funding_inputs: funding_inputs,
85798596 });
85808597
8581- let msg = self.context. get_splice_init(our_funding_contribution_satoshis, funding_feerate_perkw, locktime);
8598+ let msg = self.get_splice_init(our_funding_contribution_satoshis, funding_feerate_perkw, locktime);
85828599 Ok(msg)
85838600 }
85848601
8602+ /// Get the splice message that can be sent during splice initiation.
8603+ #[cfg(splicing)]
8604+ pub fn get_splice_init(&self, our_funding_contribution_satoshis: i64,
8605+ funding_feerate_perkw: u32, locktime: u32,
8606+ ) -> msgs::SpliceInit {
8607+ // Reuse the existing funding pubkey, in spite of the channel value changing
8608+ // (though at this point we don't know the new value yet, due tue the optional counterparty contribution)
8609+ // Note that channel_keys_id is supposed NOT to change
8610+ let funding_pubkey = self.funding.get_holder_pubkeys().funding_pubkey.clone();
8611+ msgs::SpliceInit {
8612+ channel_id: self.context.channel_id,
8613+ funding_contribution_satoshis: our_funding_contribution_satoshis,
8614+ funding_feerate_perkw,
8615+ locktime,
8616+ funding_pubkey,
8617+ require_confirmed_inputs: None,
8618+ }
8619+ }
8620+
85858621 /// Handle splice_init
85868622 #[cfg(splicing)]
85878623 pub fn splice_init<ES: Deref, L: Deref>(
@@ -8633,7 +8669,7 @@ impl<SP: Deref> FundedChannel<SP> where
86338669 // Apply start of splice change in the state
86348670 self.splice_start(false, logger);
86358671
8636- let splice_ack_msg = self.context. get_splice_ack(our_funding_contribution_satoshis);
8672+ let splice_ack_msg = self.get_splice_ack(our_funding_contribution_satoshis);
86378673
86388674 // TODO(splicing): start interactive funding negotiation
86398675 // let _msg = self.begin_interactive_funding_tx_construction(signer_provider, entropy_source, holder_node_id)
@@ -8642,6 +8678,19 @@ impl<SP: Deref> FundedChannel<SP> where
86428678 Ok(splice_ack_msg)
86438679 }
86448680
8681+ /// Get the splice_ack message that can be sent in response to splice initiation.
8682+ #[cfg(splicing)]
8683+ pub fn get_splice_ack(&self, our_funding_contribution_satoshis: i64) -> msgs::SpliceAck {
8684+ // Reuse the existing funding pubkey, in spite of the channel value changing
8685+ let funding_pubkey = self.funding.get_holder_pubkeys().funding_pubkey;
8686+ msgs::SpliceAck {
8687+ channel_id: self.context.channel_id,
8688+ funding_contribution_satoshis: our_funding_contribution_satoshis,
8689+ funding_pubkey,
8690+ require_confirmed_inputs: None,
8691+ }
8692+ }
8693+
86458694 /// Handle splice_ack
86468695 #[cfg(splicing)]
86478696 pub fn splice_ack<ES: Deref, L: Deref>(
@@ -8684,7 +8733,7 @@ impl<SP: Deref> FundedChannel<SP> where
86848733 // NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT
86858734 // );
86868735 log_info!(logger, "Splicing process started, old channel value {}, outgoing {}, channel_id {}",
8687- self.funding.channel_value_satoshis , is_outgoing, self.context.channel_id);
8736+ self.funding.get_value_satoshis() , is_outgoing, self.context.channel_id);
86888737 }
86898738
86908739 // Send stuff to our remote peers:
0 commit comments