@@ -1612,6 +1612,10 @@ pub(super) struct FundingScope {
16121612
16131613 /// The late-bound funding outpoint
16141614 funding_outpoint: Option<OutPoint>,
1615+
1616+ /// The transaction which funds this channel. Note that for manually-funded channels (i.e.,
1617+ /// [`ChannelContext::is_manual_broadcast`] is true) this will be a dummy empty transaction.
1618+ funding_transaction: Option<Transaction>,
16151619}
16161620
16171621impl FundingScope {
@@ -1833,9 +1837,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
18331837 counterparty_forwarding_info: Option<CounterpartyForwardingInfo>,
18341838
18351839 pub(super) channel_transaction_parameters: ChannelTransactionParameters,
1836- /// The transaction which funds this channel. Note that for manually-funded channels (i.e.,
1837- /// is_manual_broadcast is true) this will be a dummy empty transaction.
1838- funding_transaction: Option<Transaction>,
18391840 /// This flag indicates that it is the user's responsibility to validated and broadcast the
18401841 /// funding transaction.
18411842 is_manual_broadcast: bool,
@@ -2250,7 +2251,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22502251 let commitment_signed = self.context.get_initial_commitment_signed(&self.funding, logger);
22512252 let commitment_signed = match commitment_signed {
22522253 Ok(commitment_signed) => {
2253- self.context .funding_transaction = Some(signing_session.unsigned_tx.build_unsigned_tx());
2254+ self.funding .funding_transaction = Some(signing_session.unsigned_tx.build_unsigned_tx());
22542255 commitment_signed
22552256 },
22562257 Err(err) => {
@@ -2524,6 +2525,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
25242525 next_remote_commitment_tx_fee_info_cached: Mutex::new(None),
25252526
25262527 funding_outpoint: None,
2528+ funding_transaction: None,
25272529 };
25282530 let channel_context = ChannelContext {
25292531 user_id,
@@ -2616,7 +2618,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
26162618 funding_outpoint: None,
26172619 channel_type_features: channel_type.clone()
26182620 },
2619- funding_transaction: None,
26202621 is_batch_funding: None,
26212622
26222623 counterparty_cur_commitment_point: Some(open_channel_fields.first_per_commitment_point),
@@ -2761,6 +2762,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
27612762 next_remote_commitment_tx_fee_info_cached: Mutex::new(None),
27622763
27632764 funding_outpoint: None,
2765+ funding_transaction: None,
27642766 };
27652767 let channel_context = Self {
27662768 user_id,
@@ -2850,7 +2852,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
28502852 funding_outpoint: None,
28512853 channel_type_features: channel_type.clone()
28522854 },
2853- funding_transaction: None,
28542855 is_batch_funding: None,
28552856
28562857 counterparty_cur_commitment_point: None,
@@ -4271,8 +4272,8 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
42714272 ///
42724273 /// Note that if [`Self::is_manual_broadcast`] is true the transaction will be a dummy
42734274 /// transaction.
4274- pub fn unbroadcasted_funding(&self) -> Option<Transaction> {
4275- self.if_unbroadcasted_funding(|| self .funding_transaction.clone())
4275+ pub fn unbroadcasted_funding(&self, funding: &FundingScope ) -> Option<Transaction> {
4276+ self.if_unbroadcasted_funding(|| funding .funding_transaction.clone())
42764277 }
42774278
42784279 /// Returns the transaction ID if there is a pending funding transaction that is yet to be
@@ -4337,7 +4338,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
43374338 } else { None }
43384339 } else { None };
43394340 let unbroadcasted_batch_funding_txid = self.unbroadcasted_batch_funding_txid(funding);
4340- let unbroadcasted_funding_tx = self.unbroadcasted_funding();
4341+ let unbroadcasted_funding_tx = self.unbroadcasted_funding(funding );
43414342
43424343 self.channel_state = ChannelState::ShutdownComplete;
43434344 self.update_time_counter += 1;
@@ -6149,7 +6150,7 @@ impl<SP: Deref> FundedChannel<SP> where
61496150 if funding_tx_opt.is_some() {
61506151 self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
61516152 }
6152- self.context .funding_transaction = funding_tx_opt.clone();
6153+ self.funding .funding_transaction = funding_tx_opt.clone();
61536154
61546155 self.context.next_funding_txid = None;
61556156
@@ -6369,7 +6370,7 @@ impl<SP: Deref> FundedChannel<SP> where
63696370 // (re-)broadcast the funding transaction as we may have declined to broadcast it when we
63706371 // first received the funding_signed.
63716372 let mut funding_broadcastable = None;
6372- if let Some(funding_transaction) = &self.context .funding_transaction {
6373+ if let Some(funding_transaction) = &self.funding .funding_transaction {
63736374 if self.context.is_outbound() &&
63746375 (matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if !flags.is_set(AwaitingChannelReadyFlags::WAITING_FOR_BATCH)) ||
63756376 matches!(self.context.channel_state, ChannelState::ChannelReady(_)))
@@ -7223,7 +7224,7 @@ impl<SP: Deref> FundedChannel<SP> where
72237224 user_channel_id: self.context.user_id,
72247225 channel_capacity_satoshis: self.funding.channel_value_satoshis,
72257226 counterparty_node_id: self.context.counterparty_node_id,
7226- unbroadcasted_funding_tx: self.context.unbroadcasted_funding(),
7227+ unbroadcasted_funding_tx: self.context.unbroadcasted_funding(&self.funding ),
72277228 is_manual_broadcast: self.context.is_manual_broadcast,
72287229 channel_funding_txo: self.funding.get_funding_txo(),
72297230 last_local_balance_msat: self.funding.value_to_self_msat,
@@ -7647,7 +7648,7 @@ impl<SP: Deref> FundedChannel<SP> where
76477648 // Because deciding we're awaiting initial broadcast spuriously could result in
76487649 // funds-loss (as we don't have a monitor, but have the funding transaction confirmed),
76497650 // we hard-assert here, even in production builds.
7650- if self.context.is_outbound() { assert!(self.context .funding_transaction.is_some()); }
7651+ if self.context.is_outbound() { assert!(self.funding .funding_transaction.is_some()); }
76517652 assert!(self.context.monitor_pending_channel_ready);
76527653 assert_eq!(self.context.latest_monitor_update_id, 0);
76537654 return true;
@@ -8817,8 +8818,8 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
88178818 self.context.minimum_depth = Some(COINBASE_MATURITY);
88188819 }
88198820
8820- debug_assert!(self.context .funding_transaction.is_none());
8821- self.context .funding_transaction = Some(funding_transaction);
8821+ debug_assert!(self.funding .funding_transaction.is_none());
8822+ self.funding .funding_transaction = Some(funding_transaction);
88228823 self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);
88238824
88248825 let funding_created = self.get_funding_created_msg(logger);
@@ -9898,7 +9899,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
98989899 }
98999900
99009901 self.context.channel_transaction_parameters.write(writer)?;
9901- self.context .funding_transaction.write(writer)?;
9902+ self.funding .funding_transaction.write(writer)?;
99029903
99039904 self.context.counterparty_cur_commitment_point.write(writer)?;
99049905 self.context.counterparty_prev_commitment_point.write(writer)?;
@@ -10481,6 +10482,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1048110482 next_remote_commitment_tx_fee_info_cached: Mutex::new(None),
1048210483
1048310484 funding_outpoint: channel_parameters.funding_outpoint,
10485+ funding_transaction,
1048410486 },
1048510487 context: ChannelContext {
1048610488 user_id,
@@ -10560,7 +10562,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1056010562 counterparty_forwarding_info,
1056110563
1056210564 channel_transaction_parameters: channel_parameters,
10563- funding_transaction,
1056410565 is_batch_funding,
1056510566
1056610567 counterparty_cur_commitment_point,
0 commit comments