@@ -31,9 +31,8 @@ use crate::ln::types::ChannelId;
31
31
use crate::types::payment::{PaymentPreimage, PaymentHash};
32
32
use crate::types::features::{ChannelTypeFeatures, InitFeatures};
33
33
use 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,
37
36
};
38
37
use crate::ln::msgs;
39
38
use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError};
@@ -1996,22 +1995,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
1996
1995
/// store it here and only release it to the `ChannelManager` once it asks for it.
1997
1996
blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,
1998
1997
1999
- // The `next_funding_txid` field allows peers to finalize the signing steps of an interactive
2000
- // transaction construction, or safely abort that transaction if it was not signed by one of the
2001
- // peers, who has thus already removed it from its state.
2002
- //
2003
- // If we've sent `commtiment_signed` for an interactively constructed transaction
2004
- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
2005
- // to the txid of that interactive transaction, else we MUST NOT set it.
2006
- //
2007
- // See the spec for further details on this:
2008
- // * `channel_reestablish`-sending node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2466-L2470
2009
- // * `channel_reestablish`-receiving node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2520-L2531
2010
- //
2011
- // TODO(dual_funding): Persist this when we actually contribute funding inputs. For now we always
2012
- // send an empty witnesses array in `tx_signatures` as a V2 channel acceptor
2013
- next_funding_txid: Option<Txid>,
2014
-
2015
1998
/// Only set when a counterparty `stfu` has been processed to track which node is allowed to
2016
1999
/// propose "something fundamental" upon becoming quiescent.
2017
2000
is_holder_quiescence_initiator: Option<bool>,
@@ -2275,10 +2258,6 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2275
2258
}
2276
2259
};
2277
2260
2278
- if let HandleTxCompleteValue::SendTxComplete(_, ref signing_session) = tx_complete {
2279
- self.context.next_funding_txid = Some(signing_session.unsigned_tx.compute_txid());
2280
- };
2281
-
2282
2261
HandleTxCompleteResult(Ok(tx_complete))
2283
2262
}
2284
2263
@@ -2713,8 +2692,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2713
2692
2714
2693
is_manual_broadcast: false,
2715
2694
2716
- next_funding_txid: None,
2717
-
2718
2695
is_holder_quiescence_initiator: None,
2719
2696
};
2720
2697
@@ -2945,7 +2922,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2945
2922
blocked_monitor_updates: Vec::new(),
2946
2923
local_initiated_shutdown: None,
2947
2924
is_manual_broadcast: false,
2948
- next_funding_txid: None,
2949
2925
2950
2926
is_holder_quiescence_initiator: None,
2951
2927
};
@@ -6220,7 +6196,6 @@ impl<SP: Deref> FundedChannel<SP> where
6220
6196
// We have a finalized funding transaction, so we can set the funding transaction and reset the
6221
6197
// signing session fields.
6222
6198
self.funding.funding_transaction = funding_tx_opt;
6223
- self.context.next_funding_txid = None;
6224
6199
self.interactive_tx_signing_session = None;
6225
6200
}
6226
6201
@@ -8269,6 +8244,25 @@ impl<SP: Deref> FundedChannel<SP> where
8269
8244
}
8270
8245
}
8271
8246
8247
+ fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
8248
+ // If we've sent `commtiment_signed` for an interactively constructed transaction
8249
+ // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
8250
+ // to the txid of that interactive transaction, else we MUST NOT set it.
8251
+ if let Some(signing_session) = &self.interactive_tx_signing_session {
8252
+ // Since we have a signing_session, this implies we've sent an initial `commitment_signed`...
8253
+ if !signing_session.counterparty_sent_tx_signatures {
8254
+ // ...but we didn't receive a `tx_signatures` from the counterparty yet.
8255
+ Some(self.funding_outpoint().txid)
8256
+ } else {
8257
+ // ...and we received a `tx_signatures` from the counterparty.
8258
+ None
8259
+ }
8260
+ } else {
8261
+ // We don't have an active signing session.
8262
+ None
8263
+ }
8264
+ }
8265
+
8272
8266
/// May panic if called on a channel that wasn't immediately-previously
8273
8267
/// self.remove_uncommitted_htlcs_and_mark_paused()'d
8274
8268
fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
@@ -8318,7 +8312,7 @@ impl<SP: Deref> FundedChannel<SP> where
8318
8312
next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
8319
8313
your_last_per_commitment_secret: remote_last_secret,
8320
8314
my_current_per_commitment_point: dummy_pubkey,
8321
- next_funding_txid: self.context.next_funding_txid ,
8315
+ next_funding_txid: self.maybe_get_next_funding_txid() ,
8322
8316
}
8323
8317
}
8324
8318
@@ -10872,14 +10866,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
10872
10866
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
10873
10867
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
10874
10868
10875
- // TODO(dual_funding): Instead of getting this from persisted value, figure it out based on the
10876
- // funding transaction and other channel state.
10877
- //
10878
- // If we've sent `commtiment_signed` for an interactively constructed transaction
10879
- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
10880
- // to the txid of that interactive transaction, else we MUST NOT set it.
10881
- next_funding_txid: None,
10882
-
10883
10869
is_holder_quiescence_initiator: None,
10884
10870
},
10885
10871
interactive_tx_signing_session: None,
0 commit comments