@@ -30,7 +30,7 @@ use crate::ln::types::ChannelId;
30
30
use crate::types::payment::{PaymentPreimage, PaymentHash};
31
31
use crate::types::features::{ChannelTypeFeatures, InitFeatures};
32
32
use 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,
34
34
InteractiveTxConstructorArgs, InteractiveTxMessageSend, InteractiveTxSigningSession, InteractiveTxMessageSendResult,
35
35
OutputOwned, SharedOwnedOutput, TX_COMMON_FIELDS_WEIGHT,
36
36
};
@@ -2179,22 +2179,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
2179
2179
/// store it here and only release it to the `ChannelManager` once it asks for it.
2180
2180
blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,
2181
2181
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
-
2198
2182
/// Only set when a counterparty `stfu` has been processed to track which node is allowed to
2199
2183
/// propose "something fundamental" upon becoming quiescent.
2200
2184
is_holder_quiescence_initiator: Option<bool>,
@@ -2542,10 +2526,6 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2542
2526
}
2543
2527
};
2544
2528
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
-
2549
2529
HandleTxCompleteResult(Ok(tx_complete))
2550
2530
}
2551
2531
@@ -2981,8 +2961,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2981
2961
2982
2962
is_manual_broadcast: false,
2983
2963
2984
- next_funding_txid: None,
2985
-
2986
2964
is_holder_quiescence_initiator: None,
2987
2965
};
2988
2966
@@ -3214,7 +3192,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3214
3192
blocked_monitor_updates: Vec::new(),
3215
3193
local_initiated_shutdown: None,
3216
3194
is_manual_broadcast: false,
3217
- next_funding_txid: None,
3218
3195
3219
3196
is_holder_quiescence_initiator: None,
3220
3197
};
@@ -6603,7 +6580,6 @@ impl<SP: Deref> FundedChannel<SP> where
6603
6580
// We have a finalized funding transaction, so we can set the funding transaction and reset the
6604
6581
// signing session fields.
6605
6582
self.funding.funding_transaction = funding_tx_opt;
6606
- self.context.next_funding_txid = None;
6607
6583
self.interactive_tx_signing_session = None;
6608
6584
}
6609
6585
@@ -8654,6 +8630,25 @@ impl<SP: Deref> FundedChannel<SP> where
8654
8630
self.sign_channel_announcement(node_signer, announcement).ok()
8655
8631
}
8656
8632
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(signing_session.unsigned_tx.compute_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
+
8657
8652
/// May panic if called on a channel that wasn't immediately-previously
8658
8653
/// self.remove_uncommitted_htlcs_and_mark_paused()'d
8659
8654
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
8703
8698
next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
8704
8699
your_last_per_commitment_secret: remote_last_secret,
8705
8700
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() ,
8707
8702
}
8708
8703
}
8709
8704
@@ -11569,14 +11564,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11569
11564
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
11570
11565
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
11571
11566
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
-
11580
11567
is_holder_quiescence_initiator: None,
11581
11568
},
11582
11569
interactive_tx_signing_session: None,
0 commit comments