@@ -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
};
@@ -6573,7 +6550,6 @@ impl<SP: Deref> FundedChannel<SP> where
6573
6550
// We have a finalized funding transaction, so we can set the funding transaction and reset the
6574
6551
// signing session fields.
6575
6552
self.funding.funding_transaction = funding_tx_opt;
6576
- self.context.next_funding_txid = None;
6577
6553
self.interactive_tx_signing_session = None;
6578
6554
}
6579
6555
@@ -8627,6 +8603,25 @@ impl<SP: Deref> FundedChannel<SP> where
8627
8603
self.sign_channel_announcement(node_signer, announcement).ok()
8628
8604
}
8629
8605
8606
+ fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
8607
+ // If we've sent `commtiment_signed` for an interactively constructed transaction
8608
+ // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
8609
+ // to the txid of that interactive transaction, else we MUST NOT set it.
8610
+ if let Some(signing_session) = &self.interactive_tx_signing_session {
8611
+ // Since we have a signing_session, this implies we've sent an initial `commitment_signed`...
8612
+ if !signing_session.counterparty_sent_tx_signatures {
8613
+ // ...but we didn't receive a `tx_signatures` from the counterparty yet.
8614
+ Some(self.funding_outpoint().txid)
8615
+ } else {
8616
+ // ...and we received a `tx_signatures` from the counterparty.
8617
+ None
8618
+ }
8619
+ } else {
8620
+ // We don't have an active signing session.
8621
+ None
8622
+ }
8623
+ }
8624
+
8630
8625
/// May panic if called on a channel that wasn't immediately-previously
8631
8626
/// self.remove_uncommitted_htlcs_and_mark_paused()'d
8632
8627
fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
@@ -8676,7 +8671,7 @@ impl<SP: Deref> FundedChannel<SP> where
8676
8671
next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
8677
8672
your_last_per_commitment_secret: remote_last_secret,
8678
8673
my_current_per_commitment_point: dummy_pubkey,
8679
- next_funding_txid: self.context.next_funding_txid ,
8674
+ next_funding_txid: self.maybe_get_next_funding_txid() ,
8680
8675
}
8681
8676
}
8682
8677
@@ -11537,14 +11532,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11537
11532
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
11538
11533
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
11539
11534
11540
- // TODO(dual_funding): Instead of getting this from persisted value, figure it out based on the
11541
- // funding transaction and other channel state.
11542
- //
11543
- // If we've sent `commtiment_signed` for an interactively constructed transaction
11544
- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
11545
- // to the txid of that interactive transaction, else we MUST NOT set it.
11546
- next_funding_txid: None,
11547
-
11548
11535
is_holder_quiescence_initiator: None,
11549
11536
},
11550
11537
interactive_tx_signing_session: None,
0 commit comments