@@ -31,9 +31,8 @@ use crate::ln::types::ChannelId;
3131use crate::types::payment::{PaymentPreimage, PaymentHash};
3232use crate::types::features::{ChannelTypeFeatures, InitFeatures};
3333use crate::ln::interactivetxs::{
34- get_output_weight, HandleTxCompleteValue, HandleTxCompleteResult, InteractiveTxConstructor,
35- InteractiveTxConstructorArgs, InteractiveTxSigningSession, InteractiveTxMessageSendResult,
36- TX_COMMON_FIELDS_WEIGHT,
34+ get_output_weight, HandleTxCompleteResult, InteractiveTxConstructor, InteractiveTxConstructorArgs,
35+ InteractiveTxSigningSession, InteractiveTxMessageSendResult, TX_COMMON_FIELDS_WEIGHT,
3736};
3837use crate::ln::msgs;
3938use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError};
@@ -1996,22 +1995,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
19961995 /// store it here and only release it to the `ChannelManager` once it asks for it.
19971996 blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,
19981997
1999- // The `next_funding_txid` field allows peers to finalize the signing steps of an interactive
2000- // transaction construction, or safely abort that transaction if it was not signed by one of the
2001- // peers, who has thus already removed it from its state.
2002- //
2003- // If we've sent `commtiment_signed` for an interactively constructed transaction
2004- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
2005- // to the txid of that interactive transaction, else we MUST NOT set it.
2006- //
2007- // See the spec for further details on this:
2008- // * `channel_reestablish`-sending node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2466-L2470
2009- // * `channel_reestablish`-receiving node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2520-L2531
2010- //
2011- // TODO(dual_funding): Persist this when we actually contribute funding inputs. For now we always
2012- // send an empty witnesses array in `tx_signatures` as a V2 channel acceptor
2013- next_funding_txid: Option<Txid>,
2014-
20151998 /// Only set when a counterparty `stfu` has been processed to track which node is allowed to
20161999 /// propose "something fundamental" upon becoming quiescent.
20172000 is_holder_quiescence_initiator: Option<bool>,
@@ -2275,10 +2258,6 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22752258 }
22762259 };
22772260
2278- if let HandleTxCompleteValue::SendTxComplete(_, ref signing_session) = tx_complete {
2279- self.context.next_funding_txid = Some(signing_session.unsigned_tx.compute_txid());
2280- };
2281-
22822261 HandleTxCompleteResult(Ok(tx_complete))
22832262 }
22842263
@@ -2713,8 +2692,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
27132692
27142693 is_manual_broadcast: false,
27152694
2716- next_funding_txid: None,
2717-
27182695 is_holder_quiescence_initiator: None,
27192696 };
27202697
@@ -2945,7 +2922,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
29452922 blocked_monitor_updates: Vec::new(),
29462923 local_initiated_shutdown: None,
29472924 is_manual_broadcast: false,
2948- next_funding_txid: None,
29492925
29502926 is_holder_quiescence_initiator: None,
29512927 };
@@ -6220,7 +6196,6 @@ impl<SP: Deref> FundedChannel<SP> where
62206196 // We have a finalized funding transaction, so we can set the funding transaction and reset the
62216197 // signing session fields.
62226198 self.funding.funding_transaction = funding_tx_opt;
6223- self.context.next_funding_txid = None;
62246199 self.interactive_tx_signing_session = None;
62256200 }
62266201
@@ -8269,6 +8244,25 @@ impl<SP: Deref> FundedChannel<SP> where
82698244 }
82708245 }
82718246
8247+ fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
8248+ // If we've sent `commtiment_signed` for an interactively constructed transaction
8249+ // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
8250+ // to the txid of that interactive transaction, else we MUST NOT set it.
8251+ if let Some(signing_session) = &self.interactive_tx_signing_session {
8252+ // Since we have a signing_session, this implies we've sent an initial `commitment_signed`...
8253+ if !signing_session.counterparty_sent_tx_signatures {
8254+ // ...but we didn't receive a `tx_signatures` from the counterparty yet.
8255+ Some(self.funding_outpoint().txid)
8256+ } else {
8257+ // ...and we received a `tx_signatures` from the counterparty.
8258+ None
8259+ }
8260+ } else {
8261+ // We don't have an active signing session.
8262+ None
8263+ }
8264+ }
8265+
82728266 /// May panic if called on a channel that wasn't immediately-previously
82738267 /// self.remove_uncommitted_htlcs_and_mark_paused()'d
82748268 fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
@@ -8318,7 +8312,7 @@ impl<SP: Deref> FundedChannel<SP> where
83188312 next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
83198313 your_last_per_commitment_secret: remote_last_secret,
83208314 my_current_per_commitment_point: dummy_pubkey,
8321- next_funding_txid: self.context.next_funding_txid ,
8315+ next_funding_txid: self.maybe_get_next_funding_txid() ,
83228316 }
83238317 }
83248318
@@ -10872,14 +10866,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1087210866 blocked_monitor_updates: blocked_monitor_updates.unwrap(),
1087310867 is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
1087410868
10875- // TODO(dual_funding): Instead of getting this from persisted value, figure it out based on the
10876- // funding transaction and other channel state.
10877- //
10878- // If we've sent `commtiment_signed` for an interactively constructed transaction
10879- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
10880- // to the txid of that interactive transaction, else we MUST NOT set it.
10881- next_funding_txid: None,
10882-
1088310869 is_holder_quiescence_initiator: None,
1088410870 },
1088510871 interactive_tx_signing_session: None,
0 commit comments