@@ -1950,21 +1950,19 @@ where
1950
1950
let logger = WithChannelContext::from(logger, self.context(), None);
1951
1951
match &mut self.phase {
1952
1952
ChannelPhase::UnfundedV2(chan) => {
1953
- let mut signing_session = chan
1953
+ let signing_session = chan
1954
1954
.interactive_tx_constructor
1955
1955
.take()
1956
1956
.expect("PendingV2Channel::interactive_tx_constructor should be set")
1957
1957
.into_signing_session();
1958
1958
let commitment_signed = chan.context.funding_tx_constructed(
1959
1959
&mut chan.funding,
1960
- &mut signing_session,
1960
+ signing_session,
1961
1961
false,
1962
1962
chan.unfunded_context.transaction_number(),
1963
1963
&&logger,
1964
1964
)?;
1965
1965
1966
- chan.interactive_tx_signing_session = Some(signing_session);
1967
-
1968
1966
return Ok(commitment_signed);
1969
1967
},
1970
1968
ChannelPhase::Funded(chan) => {
@@ -1975,17 +1973,15 @@ where
1975
1973
interactive_tx_constructor,
1976
1974
) = funding_negotiation
1977
1975
{
1978
- let mut signing_session =
1979
- interactive_tx_constructor.into_signing_session();
1976
+ let signing_session = interactive_tx_constructor.into_signing_session();
1980
1977
let commitment_signed = chan.context.funding_tx_constructed(
1981
1978
&mut funding,
1982
- &mut signing_session,
1979
+ signing_session,
1983
1980
true,
1984
1981
chan.holder_commitment_point.next_transaction_number(),
1985
1982
&&logger,
1986
1983
)?;
1987
1984
1988
- chan.interactive_tx_signing_session = Some(signing_session);
1989
1985
pending_splice.funding_negotiation =
1990
1986
Some(FundingNegotiation::AwaitingSignatures(funding));
1991
1987
@@ -2039,7 +2035,6 @@ where
2039
2035
funding: chan.funding,
2040
2036
pending_funding: vec![],
2041
2037
context: chan.context,
2042
- interactive_tx_signing_session: chan.interactive_tx_signing_session,
2043
2038
holder_commitment_point,
2044
2039
pending_splice: None,
2045
2040
quiescent_action: None,
@@ -2064,6 +2059,7 @@ where
2064
2059
.map(|funding_negotiation| funding_negotiation.as_funding().is_some())
2065
2060
.unwrap_or(false);
2066
2061
let session_received_commitment_signed = funded_channel
2062
+ .context
2067
2063
.interactive_tx_signing_session
2068
2064
.as_ref()
2069
2065
.map(|session| session.has_received_commitment_signed())
@@ -2945,6 +2941,16 @@ where
2945
2941
/// If we can't release a [`ChannelMonitorUpdate`] until some external action completes, we
2946
2942
/// store it here and only release it to the `ChannelManager` once it asks for it.
2947
2943
blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,
2944
+
2945
+ /// The signing session for the current interactive tx construction, if any.
2946
+ ///
2947
+ /// This is populated when the interactive tx construction phase completes
2948
+ /// (i.e., upon receiving a consecutive `tx_complete`) and the channel enters
2949
+ /// the signing phase (`FundingNegotiated` state with the `INTERACTIVE_SIGNING` flag set).
2950
+ ///
2951
+ /// This field is cleared once our counterparty sends a `channel_ready` or upon splice funding
2952
+ /// promotion.
2953
+ pub interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
2948
2954
}
2949
2955
2950
2956
/// A channel struct implementing this trait can receive an initial counterparty commitment
@@ -3519,6 +3525,8 @@ where
3519
3525
blocked_monitor_updates: Vec::new(),
3520
3526
3521
3527
is_manual_broadcast: false,
3528
+
3529
+ interactive_tx_signing_session: None,
3522
3530
};
3523
3531
3524
3532
Ok((funding, channel_context))
@@ -3755,6 +3763,8 @@ where
3755
3763
blocked_monitor_updates: Vec::new(),
3756
3764
local_initiated_shutdown: None,
3757
3765
is_manual_broadcast: false,
3766
+
3767
+ interactive_tx_signing_session: None,
3758
3768
};
3759
3769
3760
3770
Ok((funding, channel_context))
@@ -6064,7 +6074,7 @@ where
6064
6074
6065
6075
#[rustfmt::skip]
6066
6076
fn funding_tx_constructed<L: Deref>(
6067
- &mut self, funding: &mut FundingScope, signing_session: &mut InteractiveTxSigningSession,
6077
+ &mut self, funding: &mut FundingScope, signing_session: InteractiveTxSigningSession,
6068
6078
is_splice: bool, holder_commitment_transaction_number: u64, logger: &L
6069
6079
) -> Result<msgs::CommitmentSigned, AbortReason>
6070
6080
where
@@ -6087,7 +6097,7 @@ where
6087
6097
};
6088
6098
funding
6089
6099
.channel_transaction_parameters.funding_outpoint = Some(outpoint);
6090
-
6100
+ self.interactive_tx_signing_session = Some(signing_session);
6091
6101
self.channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
6092
6102
self.channel_state.set_interactive_signing();
6093
6103
@@ -6178,7 +6188,7 @@ where
6178
6188
}
6179
6189
6180
6190
fn get_initial_commitment_signed_v2<L: Deref>(
6181
- &mut self, funding: &FundingScope, logger: &L,
6191
+ &self, funding: &FundingScope, logger: &L,
6182
6192
) -> Option<msgs::CommitmentSigned>
6183
6193
where
6184
6194
SP::Target: SignerProvider,
@@ -6621,14 +6631,6 @@ where
6621
6631
pub funding: FundingScope,
6622
6632
pending_funding: Vec<FundingScope>,
6623
6633
pub context: ChannelContext<SP>,
6624
- /// The signing session for the current interactive tx construction, if any.
6625
- ///
6626
- /// This is populated when the interactive tx construction phase completes
6627
- /// (i.e., upon receiving a consecutive `tx_complete`) and the channel enters
6628
- /// the signing phase (`FundingNegotiated` state with the `INTERACTIVE_SIGNING` flag set).
6629
- ///
6630
- /// This field is cleared once our counterparty sends a `channel_ready`.
6631
- pub interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
6632
6634
holder_commitment_point: HolderCommitmentPoint,
6633
6635
/// Info about an in-progress, pending splice (if any), on the pre-splice channel
6634
6636
pending_splice: Option<PendingSplice>,
@@ -6647,7 +6649,7 @@ macro_rules! promote_splice_funding {
6647
6649
$self.context.historical_scids.push(scid);
6648
6650
}
6649
6651
core::mem::swap(&mut $self.funding, $funding);
6650
- $self.interactive_tx_signing_session = None;
6652
+ $self.context. interactive_tx_signing_session = None;
6651
6653
$self.pending_splice = None;
6652
6654
$self.context.announcement_sigs = None;
6653
6655
$self.context.announcement_sigs_state = AnnouncementSigsState::NotSent;
@@ -7373,8 +7375,7 @@ where
7373
7375
7374
7376
self.context.counterparty_current_commitment_point = self.context.counterparty_next_commitment_point;
7375
7377
self.context.counterparty_next_commitment_point = Some(msg.next_per_commitment_point);
7376
- // Clear any interactive signing session.
7377
- self.interactive_tx_signing_session = None;
7378
+ self.context.interactive_tx_signing_session = None;
7378
7379
7379
7380
log_info!(logger, "Received channel_ready from peer for channel {}", &self.context.channel_id());
7380
7381
@@ -7540,7 +7541,7 @@ where
7540
7541
log_info!(logger, "Received initial commitment_signed from peer for channel {}", &self.context.channel_id());
7541
7542
7542
7543
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
7543
- self.interactive_tx_signing_session.as_mut().expect("signing session should be present").received_commitment_signed();
7544
+ self.context. interactive_tx_signing_session.as_mut().expect("signing session should be present").received_commitment_signed();
7544
7545
Ok(channel_monitor)
7545
7546
}
7546
7547
@@ -7633,7 +7634,8 @@ where
7633
7634
channel_id: Some(self.context.channel_id()),
7634
7635
};
7635
7636
7636
- self.interactive_tx_signing_session
7637
+ self.context
7638
+ .interactive_tx_signing_session
7637
7639
.as_mut()
7638
7640
.expect("Signing session must exist for negotiated pending splice")
7639
7641
.received_commitment_signed();
@@ -8580,6 +8582,7 @@ where
8580
8582
}
8581
8583
8582
8584
let (tx_signatures_opt, funding_tx_opt) = self
8585
+ .context
8583
8586
.interactive_tx_signing_session
8584
8587
.as_mut()
8585
8588
.ok_or_else(|| APIError::APIMisuseError {
@@ -8647,7 +8650,7 @@ where
8647
8650
return Err(ChannelError::Ignore("Ignoring tx_signatures received outside of interactive signing".to_owned()));
8648
8651
}
8649
8652
8650
- if let Some(ref mut signing_session) = self.interactive_tx_signing_session {
8653
+ if let Some(ref mut signing_session) = self.context. interactive_tx_signing_session {
8651
8654
if msg.tx_hash != signing_session.unsigned_tx().compute_txid() {
8652
8655
let msg = "The txid for the transaction does not match";
8653
8656
let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
@@ -8919,7 +8922,7 @@ where
8919
8922
// An active interactive signing session or an awaiting channel_ready state implies that a
8920
8923
// commitment_signed retransmission is an initial one for funding negotiation. Thus, the
8921
8924
// signatures should be sent before channel_ready.
8922
- let channel_ready_order = if self.interactive_tx_signing_session.is_some() {
8925
+ let channel_ready_order = if self.context. interactive_tx_signing_session.is_some() {
8923
8926
ChannelReadyOrder::SignaturesFirst
8924
8927
} else if matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(_)) {
8925
8928
ChannelReadyOrder::SignaturesFirst
@@ -9410,7 +9413,7 @@ where
9410
9413
if let Some(next_funding) = &msg.next_funding {
9411
9414
// - if `next_funding` matches the latest interactive funding transaction
9412
9415
// or the current channel funding transaction:
9413
- if let Some(session) = &self.interactive_tx_signing_session {
9416
+ if let Some(session) = &self.context. interactive_tx_signing_session {
9414
9417
let our_next_funding_txid = session.unsigned_tx().compute_txid();
9415
9418
if our_next_funding_txid != next_funding.txid {
9416
9419
return Err(ChannelError::close(format!(
@@ -11246,7 +11249,7 @@ where
11246
11249
// Since we have a signing_session, this implies we've sent an initial `commitment_signed`...
11247
11250
if !self.context.channel_state.is_their_tx_signatures_sent() {
11248
11251
// ...but we didn't receive a `tx_signatures` from the counterparty yet.
11249
- self.interactive_tx_signing_session
11252
+ self.context. interactive_tx_signing_session
11250
11253
.as_ref()
11251
11254
.map(|signing_session| {
11252
11255
let mut next_funding = msgs::NextFunding {
@@ -11781,7 +11784,7 @@ where
11781
11784
})?;
11782
11785
let tx_msg_opt = interactive_tx_constructor.take_initiator_first_message();
11783
11786
11784
- debug_assert!(self.interactive_tx_signing_session.is_none());
11787
+ debug_assert!(self.context. interactive_tx_signing_session.is_none());
11785
11788
11786
11789
pending_splice.funding_negotiation = Some(FundingNegotiation::ConstructingTransaction(
11787
11790
splice_funding,
@@ -13053,7 +13056,6 @@ where
13053
13056
funding: self.funding,
13054
13057
pending_funding: vec![],
13055
13058
context: self.context,
13056
- interactive_tx_signing_session: None,
13057
13059
holder_commitment_point,
13058
13060
pending_splice: None,
13059
13061
quiescent_action: None,
@@ -13339,7 +13341,6 @@ where
13339
13341
funding: self.funding,
13340
13342
pending_funding: vec![],
13341
13343
context: self.context,
13342
- interactive_tx_signing_session: None,
13343
13344
holder_commitment_point,
13344
13345
pending_splice: None,
13345
13346
quiescent_action: None,
@@ -13383,8 +13384,6 @@ where
13383
13384
pub funding_negotiation_context: FundingNegotiationContext,
13384
13385
/// The current interactive transaction construction session under negotiation.
13385
13386
pub interactive_tx_constructor: Option<InteractiveTxConstructor>,
13386
- /// The signing session created after `tx_complete` handling
13387
- pub interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
13388
13387
}
13389
13388
13390
13389
impl<SP: Deref> PendingV2Channel<SP>
@@ -13459,7 +13458,6 @@ where
13459
13458
unfunded_context,
13460
13459
funding_negotiation_context,
13461
13460
interactive_tx_constructor: None,
13462
- interactive_tx_signing_session: None,
13463
13461
};
13464
13462
Ok(chan)
13465
13463
}
@@ -13647,7 +13645,6 @@ where
13647
13645
context,
13648
13646
funding_negotiation_context,
13649
13647
interactive_tx_constructor,
13650
- interactive_tx_signing_session: None,
13651
13648
unfunded_context,
13652
13649
})
13653
13650
}
@@ -14255,7 +14252,7 @@ where
14255
14252
(54, self.pending_funding, optional_vec), // Added in 0.2
14256
14253
(55, removed_htlc_attribution_data, optional_vec), // Added in 0.2
14257
14254
(57, holding_cell_attribution_data, optional_vec), // Added in 0.2
14258
- (58, self.interactive_tx_signing_session, option), // Added in 0.2
14255
+ (58, self.context. interactive_tx_signing_session, option), // Added in 0.2
14259
14256
(59, self.funding.minimum_depth_override, option), // Added in 0.2
14260
14257
(60, self.context.historical_scids, optional_vec), // Added in 0.2
14261
14258
(61, fulfill_attribution_data, optional_vec), // Added in 0.2
@@ -15025,8 +15022,9 @@ where
15025
15022
15026
15023
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
15027
15024
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
15025
+
15026
+ interactive_tx_signing_session,
15028
15027
},
15029
- interactive_tx_signing_session,
15030
15028
holder_commitment_point,
15031
15029
pending_splice: None,
15032
15030
quiescent_action,
0 commit comments