@@ -1127,9 +1127,9 @@ pub(super) enum ChannelPhase<SP: Deref> where SP::Target: SignerProvider {
11271127 UnfundedOutboundV1(OutboundV1Channel<SP>),
11281128 UnfundedInboundV1(InboundV1Channel<SP>),
11291129 #[allow(dead_code)] // TODO(dual_funding): Remove once creating V2 channels is enabled.
1130- UnfundedOutboundV2(OutboundV2Channel <SP>),
1130+ UnfundedOutboundV2(PendingV2Channel <SP>),
11311131 #[allow(dead_code)] // TODO(dual_funding): Remove once accepting V2 channels is enabled.
1132- UnfundedInboundV2(InboundV2Channel <SP>),
1132+ UnfundedInboundV2(PendingV2Channel <SP>),
11331133 Funded(Channel<SP>),
11341134}
11351135
@@ -1849,25 +1849,7 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
18491849 }
18501850}
18511851
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 {
18711853 fn context(&self) -> &ChannelContext<SP> {
18721854 &self.context
18731855 }
@@ -8822,24 +8804,24 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
88228804 }
88238805}
88248806
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 {
88278809 pub context: ChannelContext<SP>,
88288810 pub unfunded_context: UnfundedChannelContext,
88298811 pub dual_funding_context: DualFundingChannelContext,
88308812 /// The current interactive transaction construction session under negotiation.
88318813 interactive_tx_constructor: Option<InteractiveTxConstructor>,
88328814}
88338815
8834- impl<SP: Deref> OutboundV2Channel <SP> where SP::Target: SignerProvider {
8816+ impl<SP: Deref> PendingV2Channel <SP> where SP::Target: SignerProvider {
88358817 #[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>(
88378819 fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
88388820 counterparty_node_id: PublicKey, their_features: &InitFeatures, funding_satoshis: u64,
88398821 funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>, user_id: u128, config: &UserConfig,
88408822 current_chain_height: u32, outbound_scid_alias: u64, funding_confirmation_target: ConfirmationTarget,
88418823 logger: L,
8842- ) -> Result<OutboundV2Channel<SP> , APIError>
8824+ ) -> Result<Self , APIError>
88438825 where ES::Target: EntropySource,
88448826 F::Target: FeeEstimator,
88458827 L::Target: Logger,
@@ -8911,6 +8893,10 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
89118893 }
89128894
89138895 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+
89148900 if self.context.have_received_message() {
89158901 debug_assert!(false, "Cannot generate an open_channel2 after we've moved forward");
89168902 }
@@ -8960,40 +8946,16 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
89608946 }
89618947 }
89628948
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 {
89878949 /// Creates a new dual-funded channel from a remote side's request for one.
89888950 /// Assumes chain_hash has already been checked and corresponds with what we expect!
89898951 #[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>(
89918953 fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
89928954 holder_node_id: PublicKey, counterparty_node_id: PublicKey, our_supported_features: &ChannelTypeFeatures,
89938955 their_features: &InitFeatures, msg: &msgs::OpenChannelV2,
89948956 funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>, total_witness_weight: Weight,
89958957 user_id: u128, config: &UserConfig, current_chain_height: u32, logger: &L,
8996- ) -> Result<InboundV2Channel<SP> , ChannelError>
8958+ ) -> Result<Self , ChannelError>
89978959 where ES::Target: EntropySource,
89988960 F::Target: FeeEstimator,
89998961 L::Target: Logger,
0 commit comments