Skip to content

Commit be154c2

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 ba7d53e commit be154c2

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

lightning/src/ln/channel.rs

Lines changed: 18 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[confirmed_funding_index];
2203+
let funding = &self.negotiated_candidates[confirmed_funding_index];
22012204
if !context.check_funding_meets_minimum_depth(funding, height) {
22022205
return None;
22032206
}
@@ -5999,7 +6002,7 @@ where
59996002
#[cfg(splicing)]
60006003
fn pending_funding(&self) -> &[FundingScope] {
60016004
if let Some(pending_splice) = &self.pending_splice {
6002-
pending_splice.pending_funding.as_slice()
6005+
pending_splice.negotiated_candidates.as_slice()
60036006
} else {
60046007
&[]
60056008
}
@@ -7283,7 +7286,7 @@ where
72837286
for funding in core::iter::once(&mut self.funding).chain(
72847287
self.pending_splice
72857288
.as_mut()
7286-
.map(|pending_splice| pending_splice.pending_funding.as_mut_slice())
7289+
.map(|pending_splice| pending_splice.negotiated_candidates.as_mut_slice())
72877290
.unwrap_or(&mut [])
72887291
.iter_mut(),
72897292
) {
@@ -7493,7 +7496,7 @@ where
74937496
for funding in core::iter::once(&mut self.funding).chain(
74947497
self.pending_splice
74957498
.as_mut()
7496-
.map(|pending_splice| pending_splice.pending_funding.as_mut_slice())
7499+
.map(|pending_splice| pending_splice.negotiated_candidates.as_mut_slice())
74977500
.unwrap_or(&mut [])
74987501
.iter_mut(),
74997502
) {
@@ -9546,7 +9549,7 @@ where
95469549

95479550
let pending_splice = self.pending_splice.as_mut().unwrap();
95489551

9549-
debug_assert!(confirmed_funding_index < pending_splice.pending_funding.len());
9552+
debug_assert!(confirmed_funding_index < pending_splice.negotiated_candidates.len());
95509553

95519554
let splice_txid = match pending_splice.sent_funding_txid {
95529555
Some(sent_funding_txid) => sent_funding_txid,
@@ -9564,7 +9567,7 @@ where
95649567
&self.context.channel_id,
95659568
);
95669569

9567-
let funding = &mut pending_splice.pending_funding[confirmed_funding_index];
9570+
let funding = &mut pending_splice.negotiated_candidates[confirmed_funding_index];
95689571
debug_assert_eq!(Some(splice_txid), funding.get_funding_txid());
95699572
promote_splice_funding!(self, funding);
95709573

@@ -9639,7 +9642,7 @@ where
96399642
let mut funding_already_confirmed = false;
96409643
#[cfg(splicing)]
96419644
if let Some(pending_splice) = &mut self.pending_splice {
9642-
for (index, funding) in pending_splice.pending_funding.iter_mut().enumerate() {
9645+
for (index, funding) in pending_splice.negotiated_candidates.iter_mut().enumerate() {
96439646
if self.context.check_for_funding_tx_confirmed(
96449647
funding, block_hash, height, index_in_block, &mut confirmed_tx, logger,
96459648
)? {
@@ -9674,7 +9677,7 @@ where
96749677
) {
96759678
for &(idx, tx) in txdata.iter() {
96769679
if idx > index_in_block {
9677-
let funding = &pending_splice.pending_funding[confirmed_funding_index];
9680+
let funding = &pending_splice.negotiated_candidates[confirmed_funding_index];
96789681
self.context.check_for_funding_tx_spent(funding, tx, logger)?;
96799682
}
96809683
}
@@ -9704,7 +9707,7 @@ where
97049707
self.context.check_for_funding_tx_spent(&self.funding, tx, logger)?;
97059708
#[cfg(splicing)]
97069709
if let Some(pending_splice) = self.pending_splice.as_ref() {
9707-
for funding in pending_splice.pending_funding.iter() {
9710+
for funding in pending_splice.negotiated_candidates.iter() {
97089711
self.context.check_for_funding_tx_spent(funding, tx, logger)?;
97099712
}
97109713
}
@@ -9833,7 +9836,7 @@ where
98339836
return Err(ClosureReason::ProcessingError { err });
98349837
},
98359838
};
9836-
let funding = &mut pending_splice.pending_funding[confirmed_funding_index];
9839+
let funding = &mut pending_splice.negotiated_candidates[confirmed_funding_index];
98379840

98389841
// Check if the splice funding transaction was unconfirmed
98399842
if funding.get_funding_tx_confirmations(height) == 0 {
@@ -9922,7 +9925,7 @@ where
99229925
#[cfg(splicing)] {
99239926
self.pending_splice.as_mut().and_then(|pending_splice| {
99249927
pending_splice
9925-
.pending_funding
9928+
.negotiated_candidates
99269929
.iter_mut()
99279930
.find(|funding| funding.get_funding_txid() == Some(*txid))
99289931
})
@@ -10286,7 +10289,7 @@ where
1028610289
self.pending_splice = Some(PendingSplice {
1028710290
our_funding_contribution: our_funding_contribution_satoshis,
1028810291
funding: None,
10289-
pending_funding: vec![],
10292+
negotiated_candidates: vec![],
1029010293
sent_funding_txid: None,
1029110294
received_funding_txid: None,
1029210295
});
@@ -10404,7 +10407,7 @@ where
1040410407
if let Some(sent_funding_txid) = pending_splice.sent_funding_txid {
1040510408
if sent_funding_txid == msg.splice_txid {
1040610409
if let Some(funding) = pending_splice
10407-
.pending_funding
10410+
.negotiated_candidates
1040810411
.iter_mut()
1040910412
.find(|funding| funding.get_funding_txid() == Some(sent_funding_txid))
1041010413
{

0 commit comments

Comments
 (0)