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.
This commit is contained in:
Tobin C. Harding 2025-05-01 13:29:18 +10:00
parent 8a0e645dfd
commit 16f6fc6b5b
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 9 additions and 3 deletions

View File

@ -253,9 +253,15 @@ impl LockTime {
/// two lock times (same unit) then the larger lock time being satisfied implies (in a /// two lock times (same unit) then the larger lock time being satisfied implies (in a
/// mathematical sense) the smaller one being satisfied. /// 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., /// This function serves multiple purposes:
/// 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. /// * 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 /// # Examples
/// ///