]> 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>
Fri, 6 Sep 2024 00:56:53 +0000 (00:56 +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 39801638bb2de3a34b0c9182111e91d63599f5bc..1cba3efb92c51d9233b706fb6c67010de72019d9 100644 (file)
@@ -765,8 +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() {
+                               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() {
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 {