@@ -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};
@@ -1498,21 +1497,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
14981497 /// If we can't release a [`ChannelMonitorUpdate`] until some external action completes, we
14991498 /// store it here and only release it to the `ChannelManager` once it asks for it.
15001499 blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,
1501- // The `next_funding_txid` field allows peers to finalize the signing steps of an interactive
1502- // transaction construction, or safely abort that transaction if it was not signed by one of the
1503- // peers, who has thus already removed it from its state.
1504- //
1505- // If we've sent `commtiment_signed` for an interactively constructed transaction
1506- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
1507- // to the txid of that interactive transaction, else we MUST NOT set it.
1508- //
1509- // See the spec for further details on this:
1510- // * `channel_reestablish`-sending node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2466-L2470
1511- // * `channel_reestablish`-receiving node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2520-L2531
1512- //
1513- // TODO(dual_funding): Persist this when we actually contribute funding inputs. For now we always
1514- // send an empty witnesses array in `tx_signatures` as a V2 channel acceptor
1515- next_funding_txid: Option<Txid>,
15161500}
15171501
15181502/// A channel struct implementing this trait can receive an initial counterparty commitment
@@ -1747,10 +1731,6 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
17471731 }
17481732 };
17491733
1750- if let HandleTxCompleteValue::SendTxComplete(_, ref signing_session) = tx_complete {
1751- self.context_mut().next_funding_txid = Some(signing_session.unsigned_tx.compute_txid());
1752- };
1753-
17541734 HandleTxCompleteResult(Ok(tx_complete))
17551735 }
17561736
@@ -2217,8 +2197,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
22172197 blocked_monitor_updates: Vec::new(),
22182198
22192199 is_manual_broadcast: false,
2220-
2221- next_funding_txid: None,
22222200 };
22232201
22242202 Ok(channel_context)
@@ -2451,7 +2429,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
24512429 blocked_monitor_updates: Vec::new(),
24522430 local_initiated_shutdown: None,
24532431 is_manual_broadcast: false,
2454- next_funding_txid: None,
24552432 })
24562433 }
24572434
@@ -5763,7 +5740,6 @@ impl<SP: Deref> Channel<SP> where
57635740 // We have a persisted channel monitor and and a finalized funding transaction, so we can move
57645741 // the channel state forward, set the funding transaction and reset the signing session fields.
57655742 self.context.funding_transaction = funding_tx_opt;
5766- self.context.next_funding_txid = None;
57675743 self.interactive_tx_signing_session = None;
57685744 self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
57695745 }
@@ -7782,6 +7758,25 @@ impl<SP: Deref> Channel<SP> where
77827758 }
77837759 }
77847760
7761+ fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
7762+ // If we've sent `commtiment_signed` for an interactively constructed transaction
7763+ // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
7764+ // to the txid of that interactive transaction, else we MUST NOT set it.
7765+ if let Some(signing_session) = &self.interactive_tx_signing_session {
7766+ // Since we have a signing_session, this implies we've sent an initial `commitment_signed`...
7767+ if !signing_session.counterparty_sent_tx_signatures {
7768+ // ...but we didn't receive a `tx_signatures` from the counterparty yet.
7769+ None
7770+ } else {
7771+ // ...and we received a `tx_signatures` from the counterparty.
7772+ Some(self.funding_outpoint().txid)
7773+ }
7774+ } else {
7775+ // We don't have an active signing session.
7776+ None
7777+ }
7778+ }
7779+
77857780 /// May panic if called on a channel that wasn't immediately-previously
77867781 /// self.remove_uncommitted_htlcs_and_mark_paused()'d
77877782 pub fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
@@ -7826,7 +7821,7 @@ impl<SP: Deref> Channel<SP> where
78267821 next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
78277822 your_last_per_commitment_secret: remote_last_secret,
78287823 my_current_per_commitment_point: dummy_pubkey,
7829- next_funding_txid: self.context.next_funding_txid ,
7824+ next_funding_txid: self.maybe_get_next_funding_txid() ,
78307825 }
78317826 }
78327827
@@ -10141,13 +10136,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1014110136
1014210137 blocked_monitor_updates: blocked_monitor_updates.unwrap(),
1014310138 is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
10144- // TODO(dual_funding): Instead of getting this from persisted value, figure it out based on the
10145- // funding transaction and other channel state.
10146- //
10147- // If we've sent `commtiment_signed` for an interactively constructed transaction
10148- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
10149- // to the txid of that interactive transaction, else we MUST NOT set it.
10150- next_funding_txid: None,
1015110139 },
1015210140 interactive_tx_signing_session: None,
1015310141 })
0 commit comments