@@ -1494,6 +1494,10 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
14941494 /// If we can't release a [`ChannelMonitorUpdate`] until some external action completes, we
14951495 /// store it here and only release it to the `ChannelManager` once it asks for it.
14961496 blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,
1497+ // If we've sent `commtiment_signed` for an interactive transaction construction,
1498+ // but have not received `tx_signatures` we MUST set `next_funding_txid` to the
1499+ // txid of that interactive transaction, else we MUST NOT set it.
1500+ next_funding_txid: Option<Txid>,
14971501}
14981502
14991503/// A channel struct implementing this trait can receive an initial counterparty commitment
@@ -2146,6 +2150,8 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
21462150 blocked_monitor_updates: Vec::new(),
21472151
21482152 is_manual_broadcast: false,
2153+
2154+ next_funding_txid: None,
21492155 };
21502156
21512157 Ok(channel_context)
@@ -2377,6 +2383,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
23772383 blocked_monitor_updates: Vec::new(),
23782384 local_initiated_shutdown: None,
23792385 is_manual_broadcast: false,
2386+ next_funding_txid: None,
23802387 })
23812388 }
23822389
@@ -4579,6 +4586,14 @@ impl<SP: Deref> Channel<SP> where
45794586 self.context.channel_state.clear_waiting_for_batch();
45804587 }
45814588
4589+ pub fn set_next_funding_txid(&mut self, txid: &Txid) {
4590+ self.context.next_funding_txid = Some(*txid);
4591+ }
4592+
4593+ pub fn clear_next_funding_txid(&mut self) {
4594+ self.context.next_funding_txid = None;
4595+ }
4596+
45824597 /// Unsets the existing funding information.
45834598 ///
45844599 /// This must only be used if the channel has not yet completed funding and has not been used.
@@ -7653,10 +7668,7 @@ impl<SP: Deref> Channel<SP> where
76537668 next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
76547669 your_last_per_commitment_secret: remote_last_secret,
76557670 my_current_per_commitment_point: dummy_pubkey,
7656- // TODO(dual_funding): If we've sent `commtiment_signed` for an interactive transaction
7657- // construction but have not received `tx_signatures` we MUST set `next_funding_txid` to the
7658- // txid of that interactive transaction, else we MUST NOT set it.
7659- next_funding_txid: None,
7671+ next_funding_txid: self.context.next_funding_txid,
76607672 }
76617673 }
76627674
@@ -9411,7 +9423,8 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
94119423 (47, next_holder_commitment_point, option),
94129424 (49, self.context.local_initiated_shutdown, option), // Added in 0.0.122
94139425 (51, is_manual_broadcast, option), // Added in 0.0.124
9414- (53, funding_tx_broadcast_safe_event_emitted, option) // Added in 0.0.124
9426+ (53, funding_tx_broadcast_safe_event_emitted, option), // Added in 0.0.124
9427+ (55, self.context.next_funding_txid, option) // Added in 0.0.125
94159428 });
94169429
94179430 Ok(())
@@ -9701,6 +9714,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
97019714 let mut channel_pending_event_emitted = None;
97029715 let mut channel_ready_event_emitted = None;
97039716 let mut funding_tx_broadcast_safe_event_emitted = None;
9717+ let mut next_funding_txid = None;
97049718
97059719 let mut user_id_high_opt: Option<u64> = None;
97069720 let mut channel_keys_id: Option<[u8; 32]> = None;
@@ -9761,6 +9775,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
97619775 (49, local_initiated_shutdown, option),
97629776 (51, is_manual_broadcast, option),
97639777 (53, funding_tx_broadcast_safe_event_emitted, option),
9778+ (55, next_funding_txid, option) // Added in 0.0.125
97649779 });
97659780
97669781 let (channel_keys_id, holder_signer) = if let Some(channel_keys_id) = channel_keys_id {
@@ -10020,6 +10035,10 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1002010035
1002110036 blocked_monitor_updates: blocked_monitor_updates.unwrap(),
1002210037 is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
10038+ // If we've sent `commtiment_signed` for an interactive transaction construction,
10039+ // but have not received `tx_signatures` we MUST set `next_funding_txid` to the
10040+ // txid of that interactive transaction, else we MUST NOT set it.
10041+ next_funding_txid,
1002310042 },
1002410043 interactive_tx_signing_session: None,
1002510044 })
0 commit comments