Skip to content

Commit 8d2a476

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 30ff74d commit 8d2a476

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

lightning/src/ln/channel.rs

Lines changed: 16 additions & 13 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
}
@@ -6015,7 +6018,7 @@ where
60156018
core::iter::once(&mut self.funding).chain(
60166019
self.pending_splice
60176020
.as_mut()
6018-
.map(|pending_splice| pending_splice.pending_funding.as_mut_slice())
6021+
.map(|pending_splice| pending_splice.negotiated_candidates.as_mut_slice())
60196022
.unwrap_or(&mut [])
60206023
.iter_mut(),
60216024
)
@@ -9545,7 +9548,7 @@ where
95459548

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

9548-
debug_assert!(confirmed_funding_index < pending_splice.pending_funding.len());
9551+
debug_assert!(confirmed_funding_index < pending_splice.negotiated_candidates.len());
95499552

95509553
let splice_txid = match pending_splice.sent_funding_txid {
95519554
Some(sent_funding_txid) => sent_funding_txid,
@@ -9563,7 +9566,7 @@ where
95639566
&self.context.channel_id,
95649567
);
95659568

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

@@ -9638,7 +9641,7 @@ where
96389641
let mut funding_already_confirmed = false;
96399642
#[cfg(splicing)]
96409643
if let Some(pending_splice) = &mut self.pending_splice {
9641-
for (index, funding) in pending_splice.pending_funding.iter_mut().enumerate() {
9644+
for (index, funding) in pending_splice.negotiated_candidates.iter_mut().enumerate() {
96429645
if self.context.check_for_funding_tx_confirmed(
96439646
funding, block_hash, height, index_in_block, &mut confirmed_tx, logger,
96449647
)? {
@@ -9673,7 +9676,7 @@ where
96739676
) {
96749677
for &(idx, tx) in txdata.iter() {
96759678
if idx > index_in_block {
9676-
let funding = &pending_splice.pending_funding[confirmed_funding_index];
9679+
let funding = &pending_splice.negotiated_candidates[confirmed_funding_index];
96779680
self.context.check_for_funding_tx_spent(funding, tx, logger)?;
96789681
}
96799682
}
@@ -9703,7 +9706,7 @@ where
97039706
self.context.check_for_funding_tx_spent(&self.funding, tx, logger)?;
97049707
#[cfg(splicing)]
97059708
if let Some(pending_splice) = self.pending_splice.as_ref() {
9706-
for funding in pending_splice.pending_funding.iter() {
9709+
for funding in pending_splice.negotiated_candidates.iter() {
97079710
self.context.check_for_funding_tx_spent(funding, tx, logger)?;
97089711
}
97099712
}
@@ -9832,7 +9835,7 @@ where
98329835
return Err(ClosureReason::ProcessingError { err });
98339836
},
98349837
};
9835-
let funding = &mut pending_splice.pending_funding[confirmed_funding_index];
9838+
let funding = &mut pending_splice.negotiated_candidates[confirmed_funding_index];
98369839

98379840
// Check if the splice funding transaction was unconfirmed
98389841
if funding.get_funding_tx_confirmations(height) == 0 {
@@ -10273,7 +10276,7 @@ where
1027310276
self.pending_splice = Some(PendingSplice {
1027410277
our_funding_contribution: our_funding_contribution_satoshis,
1027510278
funding: None,
10276-
pending_funding: vec![],
10279+
negotiated_candidates: vec![],
1027710280
sent_funding_txid: None,
1027810281
received_funding_txid: None,
1027910282
});
@@ -10391,7 +10394,7 @@ where
1039110394
if let Some(sent_funding_txid) = pending_splice.sent_funding_txid {
1039210395
if sent_funding_txid == msg.splice_txid {
1039310396
if let Some(funding) = pending_splice
10394-
.pending_funding
10397+
.negotiated_candidates
1039510398
.iter_mut()
1039610399
.find(|funding| funding.get_funding_txid() == Some(sent_funding_txid))
1039710400
{

0 commit comments

Comments
 (0)