Skip to content

Commit ac8803c

Browse files
committed
f - store funding_tx_locktime in PendingV2Channel
1 parent e247652 commit ac8803c

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

lightning/src/ln/channel.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13946,6 +13946,8 @@ where
1394613946
pub funding: FundingScope,
1394713947
pub context: ChannelContext<SP>,
1394813948
pub unfunded_context: UnfundedChannelContext,
13949+
funding_tx_locktime: LockTime,
13950+
#[allow(unused)] // TODO(dual_funding): Remove once initiating V2 channels is enabled.
1394913951
pub funding_negotiation_context: Option<FundingNegotiationContext>,
1395013952
/// The current interactive transaction construction session under negotiation.
1395113953
pub interactive_tx_constructor: Option<InteractiveTxConstructor>,
@@ -14021,6 +14023,7 @@ where
1402114023
funding,
1402214024
context,
1402314025
unfunded_context,
14026+
funding_tx_locktime,
1402414027
funding_negotiation_context: Some(funding_negotiation_context),
1402514028
interactive_tx_constructor: None,
1402614029
};
@@ -14096,7 +14099,7 @@ where
1409614099
},
1409714100
funding_feerate_sat_per_1000_weight: self.context.feerate_per_kw,
1409814101
second_per_commitment_point,
14099-
locktime: self.funding_tx_locktime().to_consensus_u32(),
14102+
locktime: self.funding_tx_locktime.to_consensus_u32(),
1410014103
require_confirmed_inputs: None,
1410114104
}
1410214105
}
@@ -14160,12 +14163,13 @@ where
1416014163
&funding.get_counterparty_pubkeys().revocation_basepoint);
1416114164
context.channel_id = channel_id;
1416214165

14166+
let funding_tx_locktime = LockTime::from_consensus(msg.locktime);
1416314167
let funding_negotiation_context = FundingNegotiationContext {
1416414168
is_initiator: false,
1416514169
our_funding_contribution: our_funding_contribution
1416614170
.to_signed()
1416714171
.expect("our_funding_contribution should not be greater than Amount::MAX_MONEY"),
14168-
funding_tx_locktime: LockTime::from_consensus(msg.locktime),
14172+
funding_tx_locktime,
1416914173
funding_feerate_sat_per_1000_weight: msg.funding_feerate_sat_per_1000_weight,
1417014174
shared_funding_input: None,
1417114175
our_funding_inputs: our_funding_inputs.clone(),
@@ -14194,9 +14198,10 @@ where
1419414198
Ok(Self {
1419514199
funding,
1419614200
context,
14201+
unfunded_context,
14202+
funding_tx_locktime,
1419714203
funding_negotiation_context: None,
1419814204
interactive_tx_constructor: Some(interactive_tx_constructor),
14199-
unfunded_context,
1420014205
})
1420114206
}
1420214207

@@ -14278,20 +14283,6 @@ where
1427814283
pub fn our_funding_contribution(&self) -> Amount {
1427914284
Amount::from_sat(self.funding.value_to_self_msat / 1000)
1428014285
}
14281-
14282-
pub fn funding_tx_locktime(&self) -> LockTime {
14283-
self.funding_negotiation_context
14284-
.as_ref()
14285-
.map(|context| context.funding_tx_locktime)
14286-
.or_else(|| {
14287-
self.interactive_tx_constructor
14288-
.as_ref()
14289-
.map(|constructor| constructor.funding_tx_locktime())
14290-
})
14291-
.expect(
14292-
"either funding_negotiation_context or interactive_tx_constructor should be set",
14293-
)
14294-
}
1429514286
}
1429614287

1429714288
// Unfunded channel utilities

lightning/src/ln/interactivetxs.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,7 +1947,6 @@ pub(super) struct InteractiveTxConstructor {
19471947
is_initiator: bool,
19481948
initiator_first_message: Option<InteractiveTxMessageSend>,
19491949
channel_id: ChannelId,
1950-
funding_tx_locktime: AbsoluteLockTime,
19511950
inputs_to_contribute: Vec<(SerialId, InputOwned)>,
19521951
outputs_to_contribute: Vec<(SerialId, OutputOwned)>,
19531952
next_input_index: Option<usize>,
@@ -2113,7 +2112,6 @@ impl InteractiveTxConstructor {
21132112
is_initiator,
21142113
initiator_first_message: None,
21152114
channel_id,
2116-
funding_tx_locktime,
21172115
inputs_to_contribute,
21182116
outputs_to_contribute,
21192117
next_input_index,
@@ -2133,10 +2131,6 @@ impl InteractiveTxConstructor {
21332131
Ok(constructor)
21342132
}
21352133

2136-
pub(super) fn funding_tx_locktime(&self) -> AbsoluteLockTime {
2137-
self.funding_tx_locktime
2138-
}
2139-
21402134
fn into_negotiation_error(self, reason: AbortReason) -> NegotiationError {
21412135
let (contributed_inputs, contributed_outputs) = self.into_contributed_inputs_and_outputs();
21422136
NegotiationError { reason, contributed_inputs, contributed_outputs }

0 commit comments

Comments
 (0)