]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Rename `PackageTemplate::timelock` `counteraprty_spendable_height`
authorMatt Corallo <git@bluematt.me>
Fri, 6 Sep 2024 00:25:00 +0000 (00:25 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 16 Oct 2024 21:04:48 +0000 (21:04 +0000)
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
lightning/src/chain/package.rs

index e1f3ebf049bf2f376fe59bb11a4db9e297fe4454..6039b7e5d49e883392e27d5a28f015d849dbb5a6 100644 (file)
@@ -765,9 +765,8 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
                                        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);
index 0ff7fd186cd3a4319e4a107085836aadd056199a..52e1c23945de8b1a945111c3e50148743c6b409f 100644 (file)
@@ -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 {