From 48cb082d9ef33d5a6b2373a9993cd7b5722426fb Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 6 Sep 2024 00:25:00 +0000 Subject: [PATCH] Rename `PackageTemplate::timelock` `counteraprty_spendable_height` This function was very confusing - its used to determine by when we have to stop aggregating this claim with others as it starts to be at risk of pinning due to the counterparty's ability to spend the output. It is not ever used as a timelock for a transaction, and thus its name is very confusing. Instead we rename it `counterparty_spendable_height`. --- lightning/src/chain/onchaintx.rs | 4 ++-- lightning/src/chain/package.rs | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lightning/src/chain/onchaintx.rs b/lightning/src/chain/onchaintx.rs index 39801638b..1cba3efb9 100644 --- a/lightning/src/chain/onchaintx.rs +++ b/lightning/src/chain/onchaintx.rs @@ -765,8 +765,8 @@ impl OnchainTxHandler { continue; } - log_trace!(logger, "Test if outpoint can be aggregated with expiration {} against {}", req.timelock(), cur_height + CLTV_SHARED_CLAIM_BUFFER); - if req.timelock() <= cur_height + CLTV_SHARED_CLAIM_BUFFER || !req.aggregable() { + log_trace!(logger, "Test if outpoint which our counterparty can spend at {} against aggregation limit {}", req.counterparty_spendable_height(), cur_height + CLTV_SHARED_CLAIM_BUFFER); + if req.counterparty_spendable_height() <= cur_height + CLTV_SHARED_CLAIM_BUFFER || !req.aggregable() { // Don't aggregate if outpoint package timelock is soon or marked as non-aggregable preprocessed_requests.push(req); } else if aggregated_request.is_none() { diff --git a/lightning/src/chain/package.rs b/lightning/src/chain/package.rs index 0ff7fd186..52e1c2394 100644 --- a/lightning/src/chain/package.rs +++ b/lightning/src/chain/package.rs @@ -755,7 +755,11 @@ impl PackageTemplate { pub(crate) fn is_malleable(&self) -> bool { self.malleability == PackageMalleability::Malleable } - pub(crate) fn timelock(&self) -> u32 { + /// The height at which our counterparty may be able to spend this output. + /// + /// This is an important limit for aggregation as after this height our counterparty may be + /// able to pin transactions spending this output in the mempool. + pub(crate) fn counterparty_spendable_height(&self) -> u32 { self.soonest_conf_deadline } pub(crate) fn aggregable(&self) -> bool { -- 2.39.5