Skip to content

Commit 0430313

Browse files
committed
fix Misc smaller fixes, rename
1 parent 6e8aa63 commit 0430313

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

lightning/src/ln/channel.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,9 +1255,6 @@ impl<SP: Deref> Channel<SP> where
12551255
pub fn unfunded_context_mut(&mut self) -> Option<&mut UnfundedChannelContext> {
12561256
match &mut self.phase {
12571257
ChannelPhase::Undefined => unreachable!(),
1258-
#[cfg(not(splicing))]
1259-
ChannelPhase::Funded(_) => { debug_assert!(false); None }
1260-
#[cfg(splicing)]
12611258
ChannelPhase::Funded(_chan) => {
12621259
debug_assert!(false, "FundedChannel is not unfunded!");
12631260
None
@@ -2481,7 +2478,7 @@ impl<'a, SP: Deref> FundingTxConstructorV2<SP> for FundedChannelRefundingWrapper
24812478
&mut self.refunding_scope.pending_funding_negotiation_context
24822479
}
24832480

2484-
fn transaction_number(&self) -> u64 {
2481+
fn current_holder_transaction_number(&self) -> u64 {
24852482
self.holder_commitment_point.transaction_number()
24862483
}
24872484

@@ -2509,7 +2506,7 @@ pub(super) trait FundingTxConstructorV2<SP: Deref>: ChannelContextProvider<SP> w
25092506
fn pending_funding_and_context_mut(&mut self) -> (&FundingScope, &mut ChannelContext<SP>);
25102507
fn funding_negotiation_context(&self) -> &FundingNegotiationContext;
25112508
fn funding_negotiation_context_mut(&mut self) -> &mut FundingNegotiationContext;
2512-
fn transaction_number(&self) -> u64;
2509+
fn current_holder_transaction_number(&self) -> u64;
25132510
fn interactive_tx_constructor(&self) -> Option<&InteractiveTxConstructor>;
25142511
fn interactive_tx_constructor_mut(&mut self) -> &mut Option<InteractiveTxConstructor>;
25152512
fn interactive_tx_signing_session_mut(&mut self) -> &mut Option<InteractiveTxSigningSession>;
@@ -2694,7 +2691,7 @@ pub(super) trait FundingTxConstructorV2<SP: Deref>: ChannelContextProvider<SP> w
26942691
{
26952692
let our_funding_satoshis = self.funding_negotiation_context()
26962693
.our_funding_satoshis;
2697-
let transaction_number = self.transaction_number();
2694+
let transaction_number = self.current_holder_transaction_number();
26982695
let pending_funding = self.pending_funding();
26992696

27002697
let mut output_index = None;
@@ -2825,7 +2822,7 @@ impl<SP: Deref> FundingTxConstructorV2<SP> for PendingV2Channel<SP> where SP::Ta
28252822
&mut self.funding_negotiation_context
28262823
}
28272824

2828-
fn transaction_number(&self) -> u64 {
2825+
fn current_holder_transaction_number(&self) -> u64 {
28292826
self.unfunded_context.transaction_number()
28302827
}
28312828

@@ -8939,7 +8936,7 @@ impl<SP: Deref> FundedChannel<SP> where
89398936
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
89408937
#[cfg(splicing)]
89418938
pub fn splice_channel(&mut self, our_funding_contribution_satoshis: i64,
8942-
our_funding_inputs: &Vec<(TxIn, Transaction, Weight)>,
8939+
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
89438940
funding_feerate_per_kw: u32, locktime: u32,
89448941
) -> Result<msgs::SpliceInit, APIError> {
89458942
// Check if a splice has been initiated already.
@@ -9073,7 +9070,7 @@ impl<SP: Deref> FundedChannel<SP> where
90739070
{
90749071
let _res = self.splice_init_checks(msg)?;
90759072

9076-
let pre_channel_value = self.funding().get_value_satoshis();
9073+
let pre_channel_value = self.funding.get_value_satoshis();
90779074
let their_funding_contribution = msg.funding_contribution_satoshis;
90789075

90799076
let post_channel_value = PendingSplice::compute_post_value(pre_channel_value, our_funding_contribution, their_funding_contribution);
@@ -9085,13 +9082,13 @@ impl<SP: Deref> FundedChannel<SP> where
90859082
false, // is_outbound
90869083
)?;
90879084

9088-
let post_value_to_self_msat = self.funding().value_to_self_msat.saturating_add(our_funding_satoshis);
9085+
let post_value_to_self_msat = self.funding.value_to_self_msat.saturating_add(our_funding_satoshis);
90899086

9090-
let mut post_channel_transaction_parameters = self.funding().channel_transaction_parameters.clone();
9087+
let mut post_channel_transaction_parameters = self.funding.channel_transaction_parameters.clone();
90919088
post_channel_transaction_parameters.channel_value_satoshis = post_channel_value;
90929089
// Update the splicing 'tweak', this will rotate the keys in the signer
9093-
let prev_funding_txid = self.funding.funding_transaction.as_ref()
9094-
.map(|tx| tx.compute_txid());
9090+
let prev_funding_txid = self.funding.channel_transaction_parameters.funding_outpoint
9091+
.map(|outpoint| outpoint.txid);
90959092
post_channel_transaction_parameters.splice_parent_funding_txid = prev_funding_txid;
90969093
match &self.context.holder_signer {
90979094
ChannelSignerType::Ecdsa(ecdsa) => {
@@ -9210,13 +9207,13 @@ impl<SP: Deref> FundedChannel<SP> where
92109207
true, // is_outbound
92119208
)?;
92129209

9213-
let post_value_to_self_msat = self.funding().value_to_self_msat.saturating_add(our_funding_satoshis);
9210+
let post_value_to_self_msat = self.funding.value_to_self_msat.saturating_add(our_funding_satoshis);
92149211

9215-
let mut post_channel_transaction_parameters = self.funding().channel_transaction_parameters.clone();
9212+
let mut post_channel_transaction_parameters = self.funding.channel_transaction_parameters.clone();
92169213
post_channel_transaction_parameters.channel_value_satoshis = post_channel_value;
92179214
// Update the splicing 'tweak', this will rotate the keys in the signer
9218-
let prev_funding_txid = self.funding.funding_transaction.as_ref()
9219-
.map(|tx| tx.compute_txid());
9215+
let prev_funding_txid = self.funding.channel_transaction_parameters.funding_outpoint
9216+
.map(|outpoint| outpoint.txid);
92209217
post_channel_transaction_parameters.splice_parent_funding_txid = prev_funding_txid;
92219218
match &self.context.holder_signer {
92229219
ChannelSignerType::Ecdsa(ecdsa) => {

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4277,7 +4277,7 @@ where
42774277
let mut res = Ok(());
42784278
PersistenceNotifierGuard::optionally_notify(self, || {
42794279
let result = self.internal_splice_channel(
4280-
channel_id, counterparty_node_id, our_funding_contribution_satoshis, &our_funding_inputs, funding_feerate_per_kw, locktime
4280+
channel_id, counterparty_node_id, our_funding_contribution_satoshis, our_funding_inputs.clone(), funding_feerate_per_kw, locktime
42814281
);
42824282
res = result;
42834283
match res {
@@ -4292,7 +4292,7 @@ where
42924292
#[cfg(splicing)]
42934293
fn internal_splice_channel(
42944294
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey, our_funding_contribution_satoshis: i64,
4295-
our_funding_inputs: &Vec<(TxIn, Transaction, Weight)>,
4295+
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
42964296
funding_feerate_per_kw: u32, locktime: Option<u32>,
42974297
) -> Result<(), APIError> {
42984298
let per_peer_state = self.per_peer_state.read().unwrap();

0 commit comments

Comments
 (0)