@@ -30,7 +30,7 @@ use crate::ln::types::ChannelId;
3030use crate::types::payment::{PaymentPreimage, PaymentHash};
3131use crate::types::features::{ChannelTypeFeatures, InitFeatures};
3232use crate::ln::interactivetxs::{
33- calculate_change_output_value, get_output_weight, AbortReason, HandleTxCompleteValue, HandleTxCompleteResult, InteractiveTxConstructor,
33+ calculate_change_output_value, get_output_weight, AbortReason, HandleTxCompleteResult, InteractiveTxConstructor,
3434 InteractiveTxConstructorArgs, InteractiveTxMessageSend, InteractiveTxSigningSession, InteractiveTxMessageSendResult,
3535 OutputOwned, SharedOwnedOutput, TX_COMMON_FIELDS_WEIGHT,
3636};
@@ -2179,22 +2179,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
21792179 /// store it here and only release it to the `ChannelManager` once it asks for it.
21802180 blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,
21812181
2182- // The `next_funding_txid` field allows peers to finalize the signing steps of an interactive
2183- // transaction construction, or safely abort that transaction if it was not signed by one of the
2184- // peers, who has thus already removed it from its state.
2185- //
2186- // If we've sent `commtiment_signed` for an interactively constructed transaction
2187- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
2188- // to the txid of that interactive transaction, else we MUST NOT set it.
2189- //
2190- // See the spec for further details on this:
2191- // * `channel_reestablish`-sending node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2466-L2470
2192- // * `channel_reestablish`-receiving node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2520-L2531
2193- //
2194- // TODO(dual_funding): Persist this when we actually contribute funding inputs. For now we always
2195- // send an empty witnesses array in `tx_signatures` as a V2 channel acceptor
2196- next_funding_txid: Option<Txid>,
2197-
21982182 /// Only set when a counterparty `stfu` has been processed to track which node is allowed to
21992183 /// propose "something fundamental" upon becoming quiescent.
22002184 is_holder_quiescence_initiator: Option<bool>,
@@ -2542,10 +2526,6 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
25422526 }
25432527 };
25442528
2545- if let HandleTxCompleteValue::SendTxComplete(_, ref signing_session) = tx_complete {
2546- self.context.next_funding_txid = Some(signing_session.unsigned_tx.compute_txid());
2547- };
2548-
25492529 HandleTxCompleteResult(Ok(tx_complete))
25502530 }
25512531
@@ -2981,8 +2961,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
29812961
29822962 is_manual_broadcast: false,
29832963
2984- next_funding_txid: None,
2985-
29862964 is_holder_quiescence_initiator: None,
29872965 };
29882966
@@ -3214,7 +3192,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
32143192 blocked_monitor_updates: Vec::new(),
32153193 local_initiated_shutdown: None,
32163194 is_manual_broadcast: false,
3217- next_funding_txid: None,
32183195
32193196 is_holder_quiescence_initiator: None,
32203197 };
@@ -6603,7 +6580,6 @@ impl<SP: Deref> FundedChannel<SP> where
66036580 // We have a finalized funding transaction, so we can set the funding transaction and reset the
66046581 // signing session fields.
66056582 self.funding.funding_transaction = funding_tx_opt;
6606- self.context.next_funding_txid = None;
66076583 self.interactive_tx_signing_session = None;
66086584 }
66096585
@@ -8654,6 +8630,25 @@ impl<SP: Deref> FundedChannel<SP> where
86548630 self.sign_channel_announcement(node_signer, announcement).ok()
86558631 }
86568632
8633+ fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
8634+ // If we've sent `commtiment_signed` for an interactively constructed transaction
8635+ // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
8636+ // to the txid of that interactive transaction, else we MUST NOT set it.
8637+ if let Some(signing_session) = &self.interactive_tx_signing_session {
8638+ // Since we have a signing_session, this implies we've sent an initial `commitment_signed`...
8639+ if !signing_session.counterparty_sent_tx_signatures {
8640+ // ...but we didn't receive a `tx_signatures` from the counterparty yet.
8641+ Some(self.funding_outpoint().txid)
8642+ } else {
8643+ // ...and we received a `tx_signatures` from the counterparty.
8644+ None
8645+ }
8646+ } else {
8647+ // We don't have an active signing session.
8648+ None
8649+ }
8650+ }
8651+
86578652 /// May panic if called on a channel that wasn't immediately-previously
86588653 /// self.remove_uncommitted_htlcs_and_mark_paused()'d
86598654 fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
@@ -8703,7 +8698,7 @@ impl<SP: Deref> FundedChannel<SP> where
87038698 next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
87048699 your_last_per_commitment_secret: remote_last_secret,
87058700 my_current_per_commitment_point: dummy_pubkey,
8706- next_funding_txid: self.context.next_funding_txid ,
8701+ next_funding_txid: self.maybe_get_next_funding_txid() ,
87078702 }
87088703 }
87098704
@@ -11569,14 +11564,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
1156911564 blocked_monitor_updates: blocked_monitor_updates.unwrap(),
1157011565 is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
1157111566
11572- // TODO(dual_funding): Instead of getting this from persisted value, figure it out based on the
11573- // funding transaction and other channel state.
11574- //
11575- // If we've sent `commtiment_signed` for an interactively constructed transaction
11576- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
11577- // to the txid of that interactive transaction, else we MUST NOT set it.
11578- next_funding_txid: None,
11579-
1158011567 is_holder_quiescence_initiator: None,
1158111568 },
1158211569 interactive_tx_signing_session: None,
0 commit comments