@@ -2280,8 +2280,8 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2280
2280
// Add output for funding tx
2281
2281
let mut funding_outputs = Vec::new();
2282
2282
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() {
2285
2285
let tx_out = TxOut {
2286
2286
value: Amount::from_sat(funding_output_value_satoshis),
2287
2287
script_pubkey: funding_output_script_pubkey,
@@ -2302,7 +2302,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2302
2302
2303
2303
// Optionally add change output
2304
2304
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,
2306
2306
&funding_inputs_prev_outputs, &funding_outputs,
2307
2307
self.dual_funding_context.funding_feerate_sat_per_1000_weight,
2308
2308
self.context.holder_dust_limit_satoshis,
@@ -2327,7 +2327,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2327
2327
counterparty_node_id: self.context.counterparty_node_id,
2328
2328
channel_id: self.context.channel_id(),
2329
2329
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(),
2331
2331
funding_tx_locktime: self.dual_funding_context.funding_tx_locktime,
2332
2332
inputs_to_contribute: funding_inputs,
2333
2333
outputs_to_contribute: funding_outputs,
@@ -2507,6 +2507,56 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2507
2507
}
2508
2508
}
2509
2509
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
+
2510
2560
impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2511
2561
fn new_for_inbound_channel<'a, ES: Deref, F: Deref, L: Deref>(
2512
2562
fee_estimator: &'a LowerBoundedFeeEstimator<F>,
@@ -4737,38 +4787,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
4737
4787
self.counterparty_cur_commitment_point = Some(counterparty_cur_commitment_point_override);
4738
4788
self.get_initial_counterparty_commitment_signature(funding, logger)
4739
4789
}
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
- }
4772
4790
}
4773
4791
4774
4792
// Internal utility functions for channels
@@ -4860,7 +4878,6 @@ pub(super) struct DualFundingChannelContext {
4860
4878
/// The amount in satoshis we will be contributing to the channel.
4861
4879
pub our_funding_satoshis: u64,
4862
4880
/// 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.
4864
4881
pub their_funding_satoshis: Option<u64>,
4865
4882
/// The funding transaction locktime suggested by the initiator. If set by us, it is always set
4866
4883
/// to the current block height to align incentives against fee-sniping.
@@ -8578,10 +8595,29 @@ impl<SP: Deref> FundedChannel<SP> where
8578
8595
our_funding_inputs: funding_inputs,
8579
8596
});
8580
8597
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);
8582
8599
Ok(msg)
8583
8600
}
8584
8601
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
+
8585
8621
/// Handle splice_init
8586
8622
#[cfg(splicing)]
8587
8623
pub fn splice_init<ES: Deref, L: Deref>(
@@ -8633,7 +8669,7 @@ impl<SP: Deref> FundedChannel<SP> where
8633
8669
// Apply start of splice change in the state
8634
8670
self.splice_start(false, logger);
8635
8671
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);
8637
8673
8638
8674
// TODO(splicing): start interactive funding negotiation
8639
8675
// 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
8642
8678
Ok(splice_ack_msg)
8643
8679
}
8644
8680
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
+
8645
8694
/// Handle splice_ack
8646
8695
#[cfg(splicing)]
8647
8696
pub fn splice_ack<ES: Deref, L: Deref>(
@@ -8684,7 +8733,7 @@ impl<SP: Deref> FundedChannel<SP> where
8684
8733
// NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT
8685
8734
// );
8686
8735
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);
8688
8737
}
8689
8738
8690
8739
// Send stuff to our remote peers:
0 commit comments