Skip to content

Commit f5fde96

Browse files
committed
Rename PendingSplice::pending_funding to negotiated_candidates
An upcoming commit will rename PendingSplice to PendingFunding. Thus, rename the similarly named field to something more meaningful. It includes FundingScopes that have been negotiated but have not reached enough confirmations by both parties to have exchanged splice_locked.
1 parent 6fff756 commit f5fde96

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

lightning/src/ln/channel.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,7 +2178,10 @@ impl FundingScope {
21782178
struct PendingSplice {
21792179
pub our_funding_contribution: i64,
21802180
funding: Option<FundingScope>,
2181-
pending_funding: Vec<FundingScope>,
2181+
2182+
/// Funding candidates that have been negotiated but have not reached enough confirmations
2183+
/// by both counterparties to have exchanged `splice_locked` and be promoted.
2184+
negotiated_candidates: Vec<FundingScope>,
21822185

21832186
/// The funding txid used in the `splice_locked` sent to the counterparty.
21842187
sent_funding_txid: Option<Txid>,
@@ -2195,9 +2198,9 @@ impl PendingSplice {
21952198
where
21962199
SP::Target: SignerProvider,
21972200
{
2198-
debug_assert!(confirmed_funding_index < self.pending_funding.len());
2201+
debug_assert!(confirmed_funding_index < self.negotiated_candidates.len());
21992202

2200-
let funding = self.pending_funding.get(confirmed_funding_index).unwrap();
2203+
let funding = self.negotiated_candidates.get(confirmed_funding_index).unwrap();
22012204
if !context.check_funding_meets_minimum_depth(funding, height) {
22022205
return None;
22032206
}
@@ -5998,7 +6001,7 @@ where
59986001
{
59996002
fn pending_funding(&self) -> &[FundingScope] {
60006003
if let Some(pending_splice) = &self.pending_splice {
6001-
pending_splice.pending_funding.as_slice()
6004+
pending_splice.negotiated_candidates.as_slice()
60026005
} else {
60036006
&[]
60046007
}
@@ -7277,7 +7280,7 @@ where
72777280
*self.funding.next_local_commitment_tx_fee_info_cached.lock().unwrap() = None;
72787281
*self.funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = None;
72797282
if let Some(pending_splice) = self.pending_splice.as_mut() {
7280-
for funding in pending_splice.pending_funding.iter_mut() {
7283+
for funding in pending_splice.negotiated_candidates.iter_mut() {
72817284
*funding.next_local_commitment_tx_fee_info_cached.lock().unwrap() = None;
72827285
*funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = None;
72837286
}
@@ -7484,7 +7487,7 @@ where
74847487
self.funding.value_to_self_msat =
74857488
(self.funding.value_to_self_msat as i64 + value_to_self_msat_diff) as u64;
74867489
if let Some(pending_splice) = self.pending_splice.as_mut() {
7487-
for funding in pending_splice.pending_funding.iter_mut() {
7490+
for funding in pending_splice.negotiated_candidates.iter_mut() {
74887491
funding.value_to_self_msat =
74897492
(funding.value_to_self_msat as i64 + value_to_self_msat_diff) as u64;
74907493
}
@@ -9531,7 +9534,7 @@ where
95319534

95329535
let pending_splice = self.pending_splice.as_mut().unwrap();
95339536

9534-
debug_assert!(confirmed_funding_index < pending_splice.pending_funding.len());
9537+
debug_assert!(confirmed_funding_index < pending_splice.negotiated_candidates.len());
95359538

95369539
let splice_txid = match pending_splice.sent_funding_txid {
95379540
Some(sent_funding_txid) => sent_funding_txid,
@@ -9549,7 +9552,8 @@ where
95499552
&self.context.channel_id,
95509553
);
95519554

9552-
let funding = pending_splice.pending_funding.get_mut(confirmed_funding_index).unwrap();
9555+
let funding =
9556+
pending_splice.negotiated_candidates.get_mut(confirmed_funding_index).unwrap();
95539557
debug_assert_eq!(Some(splice_txid), funding.get_funding_txid());
95549558
promote_splice_funding!(self, funding);
95559559

@@ -9624,7 +9628,7 @@ where
96249628
let mut funding_already_confirmed = false;
96259629
#[cfg(splicing)]
96269630
if let Some(pending_splice) = &mut self.pending_splice {
9627-
for (index, funding) in pending_splice.pending_funding.iter_mut().enumerate() {
9631+
for (index, funding) in pending_splice.negotiated_candidates.iter_mut().enumerate() {
96289632
if self.context.check_for_funding_tx_confirmed(
96299633
funding, block_hash, height, index_in_block, &mut confirmed_tx, logger,
96309634
)? {
@@ -9659,7 +9663,7 @@ where
96599663
) {
96609664
for &(idx, tx) in txdata.iter() {
96619665
if idx > index_in_block {
9662-
let funding = pending_splice.pending_funding.get(confirmed_funding_index).unwrap();
9666+
let funding = pending_splice.negotiated_candidates.get(confirmed_funding_index).unwrap();
96639667
self.context.check_for_funding_tx_spent(funding, tx, logger)?;
96649668
}
96659669
}
@@ -9689,7 +9693,7 @@ where
96899693
self.context.check_for_funding_tx_spent(&self.funding, tx, logger)?;
96909694
#[cfg(splicing)]
96919695
if let Some(pending_splice) = self.pending_splice.as_ref() {
9692-
for funding in pending_splice.pending_funding.iter() {
9696+
for funding in pending_splice.negotiated_candidates.iter() {
96939697
self.context.check_for_funding_tx_spent(funding, tx, logger)?;
96949698
}
96959699
}
@@ -9818,7 +9822,7 @@ where
98189822
return Err(ClosureReason::ProcessingError { err });
98199823
},
98209824
};
9821-
let funding = pending_splice.pending_funding.get_mut(confirmed_funding_index).unwrap();
9825+
let funding = pending_splice.negotiated_candidates.get_mut(confirmed_funding_index).unwrap();
98229826

98239827
// Check if the splice funding transaction was unconfirmed
98249828
if funding.get_funding_tx_confirmations(height) == 0 {
@@ -9906,7 +9910,7 @@ where
99069910
.or_else(|| {
99079911
self.pending_splice.as_mut().and_then(|pending_splice| {
99089912
pending_splice
9909-
.pending_funding
9913+
.negotiated_candidates
99109914
.iter_mut()
99119915
.find(|funding| funding.get_funding_txid() == Some(*txid))
99129916
})
@@ -10266,7 +10270,7 @@ where
1026610270
self.pending_splice = Some(PendingSplice {
1026710271
our_funding_contribution: our_funding_contribution_satoshis,
1026810272
funding: None,
10269-
pending_funding: vec![],
10273+
negotiated_candidates: vec![],
1027010274
sent_funding_txid: None,
1027110275
received_funding_txid: None,
1027210276
});
@@ -10384,7 +10388,7 @@ where
1038410388
if let Some(sent_funding_txid) = pending_splice.sent_funding_txid {
1038510389
if sent_funding_txid == msg.splice_txid {
1038610390
if let Some(funding) = pending_splice
10387-
.pending_funding
10391+
.negotiated_candidates
1038810392
.iter_mut()
1038910393
.find(|funding| funding.get_funding_txid() == Some(sent_funding_txid))
1039010394
{

0 commit comments

Comments
 (0)