From: Matt Corallo Date: Fri, 6 Sep 2024 00:25:00 +0000 (+0000) Subject: Rename `PackageTemplate::timelock` `counteraprty_spendable_height` X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=a19edbc32dcbadd1d50d963238f343fa1a2e2355;p=rust-lightning 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`. --- diff --git a/lightning/src/chain/onchaintx.rs b/lightning/src/chain/onchaintx.rs index e1f3ebf04..6039b7e5d 100644 --- a/lightning/src/chain/onchaintx.rs +++ b/lightning/src/chain/onchaintx.rs @@ -765,9 +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() { - // Don't aggregate if outpoint package timelock is soon or marked as non-aggregable + log_trace!(logger, "Test if outpoint which our counterparty can spend at {} can be aggregated based on 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() { preprocessed_requests.push(req); } else if aggregated_request.is_none() { aggregated_request = Some(req); 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 {