@@ -1127,9 +1127,9 @@ pub(super) enum ChannelPhase<SP: Deref> where SP::Target: SignerProvider {
1127
1127
UnfundedOutboundV1(OutboundV1Channel<SP>),
1128
1128
UnfundedInboundV1(InboundV1Channel<SP>),
1129
1129
#[allow(dead_code)] // TODO(dual_funding): Remove once creating V2 channels is enabled.
1130
- UnfundedOutboundV2(OutboundV2Channel <SP>),
1130
+ UnfundedOutboundV2(PendingV2Channel <SP>),
1131
1131
#[allow(dead_code)] // TODO(dual_funding): Remove once accepting V2 channels is enabled.
1132
- UnfundedInboundV2(InboundV2Channel <SP>),
1132
+ UnfundedInboundV2(PendingV2Channel <SP>),
1133
1133
Funded(Channel<SP>),
1134
1134
}
1135
1135
@@ -1849,25 +1849,7 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
1849
1849
}
1850
1850
}
1851
1851
1852
- impl<SP: Deref> InteractivelyFunded<SP> for OutboundV2Channel<SP> where SP::Target: SignerProvider {
1853
- fn context(&self) -> &ChannelContext<SP> {
1854
- &self.context
1855
- }
1856
- fn context_mut(&mut self) -> &mut ChannelContext<SP> {
1857
- &mut self.context
1858
- }
1859
- fn dual_funding_context(&self) -> &DualFundingChannelContext {
1860
- &self.dual_funding_context
1861
- }
1862
- fn unfunded_context(&self) -> &UnfundedChannelContext {
1863
- &self.unfunded_context
1864
- }
1865
- fn interactive_tx_constructor_mut(&mut self) -> &mut Option<InteractiveTxConstructor> {
1866
- &mut self.interactive_tx_constructor
1867
- }
1868
- }
1869
-
1870
- impl<SP: Deref> InteractivelyFunded<SP> for InboundV2Channel<SP> where SP::Target: SignerProvider {
1852
+ impl<SP: Deref> InteractivelyFunded<SP> for PendingV2Channel<SP> where SP::Target: SignerProvider {
1871
1853
fn context(&self) -> &ChannelContext<SP> {
1872
1854
&self.context
1873
1855
}
@@ -8822,24 +8804,24 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
8822
8804
}
8823
8805
}
8824
8806
8825
- // A not-yet-funded outbound (from holder) channel using V2 channel establishment.
8826
- pub(super) struct OutboundV2Channel <SP: Deref> where SP::Target: SignerProvider {
8807
+ // A not-yet-funded channel using V2 channel establishment.
8808
+ pub(super) struct PendingV2Channel <SP: Deref> where SP::Target: SignerProvider {
8827
8809
pub context: ChannelContext<SP>,
8828
8810
pub unfunded_context: UnfundedChannelContext,
8829
8811
pub dual_funding_context: DualFundingChannelContext,
8830
8812
/// The current interactive transaction construction session under negotiation.
8831
8813
interactive_tx_constructor: Option<InteractiveTxConstructor>,
8832
8814
}
8833
8815
8834
- impl<SP: Deref> OutboundV2Channel <SP> where SP::Target: SignerProvider {
8816
+ impl<SP: Deref> PendingV2Channel <SP> where SP::Target: SignerProvider {
8835
8817
#[allow(dead_code)] // TODO(dual_funding): Remove once creating V2 channels is enabled.
8836
- pub fn new <ES: Deref, F: Deref, L: Deref>(
8818
+ pub fn new_outbound <ES: Deref, F: Deref, L: Deref>(
8837
8819
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
8838
8820
counterparty_node_id: PublicKey, their_features: &InitFeatures, funding_satoshis: u64,
8839
8821
funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>, user_id: u128, config: &UserConfig,
8840
8822
current_chain_height: u32, outbound_scid_alias: u64, funding_confirmation_target: ConfirmationTarget,
8841
8823
logger: L,
8842
- ) -> Result<OutboundV2Channel<SP> , APIError>
8824
+ ) -> Result<Self , APIError>
8843
8825
where ES::Target: EntropySource,
8844
8826
F::Target: FeeEstimator,
8845
8827
L::Target: Logger,
@@ -8911,6 +8893,10 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
8911
8893
}
8912
8894
8913
8895
pub fn get_open_channel_v2(&self, chain_hash: ChainHash) -> msgs::OpenChannelV2 {
8896
+ if !self.context.is_outbound() {
8897
+ debug_assert!(false, "Tried to send open_channel2 for an inbound channel?");
8898
+ }
8899
+
8914
8900
if self.context.have_received_message() {
8915
8901
debug_assert!(false, "Cannot generate an open_channel2 after we've moved forward");
8916
8902
}
@@ -8960,40 +8946,16 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
8960
8946
}
8961
8947
}
8962
8948
8963
- pub fn into_channel(self, signing_session: InteractiveTxSigningSession) -> Result<Channel<SP>, ChannelError>{
8964
- let holder_commitment_point = self.unfunded_context.holder_commitment_point.ok_or(ChannelError::close(
8965
- format!("Expected to have holder commitment points available upon finishing interactive tx construction for channel {}",
8966
- self.context.channel_id())))?;
8967
- let channel = Channel {
8968
- context: self.context,
8969
- interactive_tx_signing_session: Some(signing_session),
8970
- holder_commitment_point,
8971
- };
8972
-
8973
- Ok(channel)
8974
- }
8975
- }
8976
-
8977
- // A not-yet-funded inbound (from counterparty) channel using V2 channel establishment.
8978
- pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
8979
- pub context: ChannelContext<SP>,
8980
- pub unfunded_context: UnfundedChannelContext,
8981
- pub dual_funding_context: DualFundingChannelContext,
8982
- /// The current interactive transaction construction session under negotiation.
8983
- interactive_tx_constructor: Option<InteractiveTxConstructor>,
8984
- }
8985
-
8986
- impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
8987
8949
/// Creates a new dual-funded channel from a remote side's request for one.
8988
8950
/// Assumes chain_hash has already been checked and corresponds with what we expect!
8989
8951
#[allow(dead_code)] // TODO(dual_funding): Remove once V2 channels is enabled.
8990
- pub fn new <ES: Deref, F: Deref, L: Deref>(
8952
+ pub fn new_inbound <ES: Deref, F: Deref, L: Deref>(
8991
8953
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
8992
8954
holder_node_id: PublicKey, counterparty_node_id: PublicKey, our_supported_features: &ChannelTypeFeatures,
8993
8955
their_features: &InitFeatures, msg: &msgs::OpenChannelV2,
8994
8956
funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>, total_witness_weight: Weight,
8995
8957
user_id: u128, config: &UserConfig, current_chain_height: u32, logger: &L,
8996
- ) -> Result<InboundV2Channel<SP> , ChannelError>
8958
+ ) -> Result<Self , ChannelError>
8997
8959
where ES::Target: EntropySource,
8998
8960
F::Target: FeeEstimator,
8999
8961
L::Target: Logger,
0 commit comments