@@ -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};
@@ -1874,21 +1873,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
18741873 /// If we can't release a [`ChannelMonitorUpdate`] until some external action completes, we
18751874 /// store it here and only release it to the `ChannelManager` once it asks for it.
18761875 blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,
1877- // The `next_funding_txid` field allows peers to finalize the signing steps of an interactive
1878- // transaction construction, or safely abort that transaction if it was not signed by one of the
1879- // peers, who has thus already removed it from its state.
1880- //
1881- // If we've sent `commtiment_signed` for an interactively constructed transaction
1882- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
1883- // to the txid of that interactive transaction, else we MUST NOT set it.
1884- //
1885- // See the spec for further details on this:
1886- // * `channel_reestablish`-sending node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2466-L2470
1887- // * `channel_reestablish`-receiving node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2520-L2531
1888- //
1889- // TODO(dual_funding): Persist this when we actually contribute funding inputs. For now we always
1890- // send an empty witnesses array in `tx_signatures` as a V2 channel acceptor
1891- next_funding_txid: Option<Txid>,
18921876}
18931877
18941878/// A channel struct implementing this trait can receive an initial counterparty commitment
@@ -2117,10 +2101,6 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
21172101 }
21182102 };
21192103
2120- if let HandleTxCompleteValue::SendTxComplete(_, ref signing_session) = tx_complete {
2121- self.context.next_funding_txid = Some(signing_session.unsigned_tx.compute_txid());
2122- };
2123-
21242104 HandleTxCompleteResult(Ok(tx_complete))
21252105 }
21262106
@@ -2553,8 +2533,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
25532533 blocked_monitor_updates: Vec::new(),
25542534
25552535 is_manual_broadcast: false,
2556-
2557- next_funding_txid: None,
25582536 };
25592537
25602538 Ok(channel_context)
@@ -2781,7 +2759,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
27812759 blocked_monitor_updates: Vec::new(),
27822760 local_initiated_shutdown: None,
27832761 is_manual_broadcast: false,
2784- next_funding_txid: None,
27852762 })
27862763 }
27872764
@@ -6064,7 +6041,6 @@ impl<SP: Deref> FundedChannel<SP> where
60646041 // We have a persisted channel monitor and and a finalized funding transaction, so we can move
60656042 // the channel state forward, set the funding transaction and reset the signing session fields.
60666043 self.context.funding_transaction = funding_tx_opt;
6067- self.context.next_funding_txid = None;
60686044 self.interactive_tx_signing_session = None;
60696045 self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
60706046 }
@@ -8085,6 +8061,25 @@ impl<SP: Deref> FundedChannel<SP> where
80858061 }
80868062 }
80878063
8064+ fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
8065+ // If we've sent `commtiment_signed` for an interactively constructed transaction
8066+ // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
8067+ // to the txid of that interactive transaction, else we MUST NOT set it.
8068+ if let Some(signing_session) = &self.interactive_tx_signing_session {
8069+ // Since we have a signing_session, this implies we've sent an initial `commitment_signed`...
8070+ if !signing_session.counterparty_sent_tx_signatures {
8071+ // ...but we didn't receive a `tx_signatures` from the counterparty yet.
8072+ Some(self.funding_outpoint().txid)
8073+ } else {
8074+ // ...and we received a `tx_signatures` from the counterparty.
8075+ None
8076+ }
8077+ } else {
8078+ // We don't have an active signing session.
8079+ None
8080+ }
8081+ }
8082+
80888083 /// May panic if called on a channel that wasn't immediately-previously
80898084 /// self.remove_uncommitted_htlcs_and_mark_paused()'d
80908085 fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
@@ -8135,7 +8130,7 @@ impl<SP: Deref> FundedChannel<SP> where
81358130 next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
81368131 your_last_per_commitment_secret: remote_last_secret,
81378132 my_current_per_commitment_point: dummy_pubkey,
8138- next_funding_txid: self.context.next_funding_txid ,
8133+ next_funding_txid: self.maybe_get_next_funding_txid() ,
81398134 }
81408135 }
81418136
@@ -10501,13 +10496,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1050110496
1050210497 blocked_monitor_updates: blocked_monitor_updates.unwrap(),
1050310498 is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
10504- // TODO(dual_funding): Instead of getting this from persisted value, figure it out based on the
10505- // funding transaction and other channel state.
10506- //
10507- // If we've sent `commtiment_signed` for an interactively constructed transaction
10508- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
10509- // to the txid of that interactive transaction, else we MUST NOT set it.
10510- next_funding_txid: None,
1051110499 },
1051210500 interactive_tx_signing_session: None,
1051310501 is_v2_established,
0 commit comments