@@ -30,9 +30,8 @@ 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
- get_output_weight, HandleTxCompleteValue, HandleTxCompleteResult, InteractiveTxConstructor,
34
- InteractiveTxConstructorArgs, InteractiveTxSigningSession, InteractiveTxMessageSendResult,
35
- TX_COMMON_FIELDS_WEIGHT,
33
+ get_output_weight, HandleTxCompleteResult, InteractiveTxConstructor, InteractiveTxConstructorArgs,
34
+ InteractiveTxSigningSession, InteractiveTxMessageSendResult, TX_COMMON_FIELDS_WEIGHT,
36
35
};
37
36
use crate::ln::msgs;
38
37
use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError};
@@ -2006,22 +2005,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
2006
2005
/// store it here and only release it to the `ChannelManager` once it asks for it.
2007
2006
blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,
2008
2007
2009
- // The `next_funding_txid` field allows peers to finalize the signing steps of an interactive
2010
- // transaction construction, or safely abort that transaction if it was not signed by one of the
2011
- // peers, who has thus already removed it from its state.
2012
- //
2013
- // If we've sent `commtiment_signed` for an interactively constructed transaction
2014
- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
2015
- // to the txid of that interactive transaction, else we MUST NOT set it.
2016
- //
2017
- // See the spec for further details on this:
2018
- // * `channel_reestablish`-sending node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2466-L2470
2019
- // * `channel_reestablish`-receiving node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2520-L2531
2020
- //
2021
- // TODO(dual_funding): Persist this when we actually contribute funding inputs. For now we always
2022
- // send an empty witnesses array in `tx_signatures` as a V2 channel acceptor
2023
- next_funding_txid: Option<Txid>,
2024
-
2025
2008
/// Only set when a counterparty `stfu` has been processed to track which node is allowed to
2026
2009
/// propose "something fundamental" upon becoming quiescent.
2027
2010
is_holder_quiescence_initiator: Option<bool>,
@@ -2285,10 +2268,6 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2285
2268
}
2286
2269
};
2287
2270
2288
- if let HandleTxCompleteValue::SendTxComplete(_, ref signing_session) = tx_complete {
2289
- self.context.next_funding_txid = Some(signing_session.unsigned_tx.compute_txid());
2290
- };
2291
-
2292
2271
HandleTxCompleteResult(Ok(tx_complete))
2293
2272
}
2294
2273
@@ -2725,8 +2704,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2725
2704
2726
2705
is_manual_broadcast: false,
2727
2706
2728
- next_funding_txid: None,
2729
-
2730
2707
is_holder_quiescence_initiator: None,
2731
2708
};
2732
2709
@@ -2959,7 +2936,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2959
2936
blocked_monitor_updates: Vec::new(),
2960
2937
local_initiated_shutdown: None,
2961
2938
is_manual_broadcast: false,
2962
- next_funding_txid: None,
2963
2939
2964
2940
is_holder_quiescence_initiator: None,
2965
2941
};
@@ -6320,7 +6296,6 @@ impl<SP: Deref> FundedChannel<SP> where
6320
6296
// We have a finalized funding transaction, so we can set the funding transaction and reset the
6321
6297
// signing session fields.
6322
6298
self.funding.funding_transaction = funding_tx_opt;
6323
- self.context.next_funding_txid = None;
6324
6299
self.interactive_tx_signing_session = None;
6325
6300
}
6326
6301
@@ -8372,6 +8347,25 @@ impl<SP: Deref> FundedChannel<SP> where
8372
8347
}
8373
8348
}
8374
8349
8350
+ fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
8351
+ // If we've sent `commtiment_signed` for an interactively constructed transaction
8352
+ // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
8353
+ // to the txid of that interactive transaction, else we MUST NOT set it.
8354
+ if let Some(signing_session) = &self.interactive_tx_signing_session {
8355
+ // Since we have a signing_session, this implies we've sent an initial `commitment_signed`...
8356
+ if !signing_session.counterparty_sent_tx_signatures {
8357
+ // ...but we didn't receive a `tx_signatures` from the counterparty yet.
8358
+ Some(self.funding_outpoint().txid)
8359
+ } else {
8360
+ // ...and we received a `tx_signatures` from the counterparty.
8361
+ None
8362
+ }
8363
+ } else {
8364
+ // We don't have an active signing session.
8365
+ None
8366
+ }
8367
+ }
8368
+
8375
8369
/// May panic if called on a channel that wasn't immediately-previously
8376
8370
/// self.remove_uncommitted_htlcs_and_mark_paused()'d
8377
8371
fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
@@ -8421,7 +8415,7 @@ impl<SP: Deref> FundedChannel<SP> where
8421
8415
next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
8422
8416
your_last_per_commitment_secret: remote_last_secret,
8423
8417
my_current_per_commitment_point: dummy_pubkey,
8424
- next_funding_txid: self.context.next_funding_txid ,
8418
+ next_funding_txid: self.maybe_get_next_funding_txid() ,
8425
8419
}
8426
8420
}
8427
8421
@@ -11106,14 +11100,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11106
11100
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
11107
11101
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
11108
11102
11109
- // TODO(dual_funding): Instead of getting this from persisted value, figure it out based on the
11110
- // funding transaction and other channel state.
11111
- //
11112
- // If we've sent `commtiment_signed` for an interactively constructed transaction
11113
- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
11114
- // to the txid of that interactive transaction, else we MUST NOT set it.
11115
- next_funding_txid: None,
11116
-
11117
11103
is_holder_quiescence_initiator: None,
11118
11104
},
11119
11105
interactive_tx_signing_session: None,
0 commit comments