@@ -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
@@ -2154,6 +2158,8 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
21542158 blocked_monitor_updates: Vec::new(),
21552159
21562160 is_manual_broadcast: false,
2161+
2162+ next_funding_txid: None,
21572163 };
21582164
21592165 Ok(channel_context)
@@ -2385,6 +2391,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
23852391 blocked_monitor_updates: Vec::new(),
23862392 local_initiated_shutdown: None,
23872393 is_manual_broadcast: false,
2394+ next_funding_txid: None,
23882395 })
23892396 }
23902397
@@ -4590,6 +4597,14 @@ impl<SP: Deref> Channel<SP> where
45904597 self.context.channel_state.clear_waiting_for_batch();
45914598 }
45924599
4600+ pub fn set_next_funding_txid(&mut self, txid: &Txid) {
4601+ self.context.next_funding_txid = Some(*txid);
4602+ }
4603+
4604+ pub fn clear_next_funding_txid(&mut self) {
4605+ self.context.next_funding_txid = None;
4606+ }
4607+
45934608 /// Unsets the existing funding information.
45944609 ///
45954610 /// This must only be used if the channel has not yet completed funding and has not been used.
@@ -7664,10 +7679,7 @@ impl<SP: Deref> Channel<SP> where
76647679 next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
76657680 your_last_per_commitment_secret: remote_last_secret,
76667681 my_current_per_commitment_point: dummy_pubkey,
7667- // TODO(dual_funding): If we've sent `commtiment_signed` for an interactive transaction
7668- // construction but have not received `tx_signatures` we MUST set `next_funding_txid` to the
7669- // txid of that interactive transaction, else we MUST NOT set it.
7670- next_funding_txid: None,
7682+ next_funding_txid: self.context.next_funding_txid,
76717683 }
76727684 }
76737685
@@ -9437,7 +9449,8 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
94379449 (47, next_holder_commitment_point, option),
94389450 (49, self.context.local_initiated_shutdown, option), // Added in 0.0.122
94399451 (51, is_manual_broadcast, option), // Added in 0.0.124
9440- (53, funding_tx_broadcast_safe_event_emitted, option) // Added in 0.0.124
9452+ (53, funding_tx_broadcast_safe_event_emitted, option), // Added in 0.0.124
9453+ (55, self.context.next_funding_txid, option) // Added in 0.0.125
94419454 });
94429455
94439456 Ok(())
@@ -9727,6 +9740,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
97279740 let mut channel_pending_event_emitted = None;
97289741 let mut channel_ready_event_emitted = None;
97299742 let mut funding_tx_broadcast_safe_event_emitted = None;
9743+ let mut next_funding_txid = None;
97309744
97319745 let mut user_id_high_opt: Option<u64> = None;
97329746 let mut channel_keys_id: Option<[u8; 32]> = None;
@@ -9787,6 +9801,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
97879801 (49, local_initiated_shutdown, option),
97889802 (51, is_manual_broadcast, option),
97899803 (53, funding_tx_broadcast_safe_event_emitted, option),
9804+ (55, next_funding_txid, option) // Added in 0.0.125
97909805 });
97919806
97929807 let (channel_keys_id, holder_signer) = if let Some(channel_keys_id) = channel_keys_id {
@@ -10046,6 +10061,10 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1004610061
1004710062 blocked_monitor_updates: blocked_monitor_updates.unwrap(),
1004810063 is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
10064+ // If we've sent `commtiment_signed` for an interactive transaction construction,
10065+ // but have not received `tx_signatures` we MUST set `next_funding_txid` to the
10066+ // txid of that interactive transaction, else we MUST NOT set it.
10067+ next_funding_txid,
1004910068 },
1005010069 dual_funding_channel_context: None,
1005110070 interactive_tx_constructor: None,
0 commit comments