From 16f6fc6b5b469741c076bc3a4d92f7d4e619ffc7 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 1 May 2025 13:29:18 +1000 Subject: [PATCH] Improve docs on absolute::LockTime::is_implied_by If one wishes to verify a script that contains CLTV is valid in a transaction then one must compare the argument to CLTV (the locktime) to the transaction locktime. And to be valid the CLTV locktime must be less than or equal to the transaction locktime. This usage kind of lends itself to the term 'implied by' and we have a function already `is_implied_by` that does exactly this. Improve the docs by adding a section mentioning this usecase. --- primitives/src/locktime/absolute.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/primitives/src/locktime/absolute.rs b/primitives/src/locktime/absolute.rs index d6434ed83..3d5205ac8 100644 --- a/primitives/src/locktime/absolute.rs +++ b/primitives/src/locktime/absolute.rs @@ -253,9 +253,15 @@ impl LockTime { /// two lock times (same unit) then the larger lock time being satisfied implies (in a /// mathematical sense) the smaller one being satisfied. /// - /// This function is useful if you wish to check a lock time against various other locks e.g., - /// filtering out locks which cannot be satisfied. Can also be used to remove the smaller value - /// of two `OP_CHECKLOCKTIMEVERIFY` operations within one branch of the script. + /// This function serves multiple purposes: + /// + /// * When evaluating `OP_CHECKLOCKTIMEVERIFY` the argument must be less than or equal to the + /// transactions nLockTime. If using this function to validate a script `self` is the argument + /// to `CLTV` and `other` is the transaction nLockTime. + /// + /// * If you wish to check a lock time against various other locks e.g., filtering out locks + /// which cannot be satisfied. Can also be used to remove the smaller value of two + /// `OP_CHECKLOCKTIMEVERIFY` operations within one branch of the script. /// /// # Examples ///