<p>I discovered this cool function named <code>hull</code>. Here is the function definition from the docs.</p>
<pre><code>-- The function hull gives the smallest interval containing both the given intervals.
hull :: Ord a =&gt; Interval a -&gt; Interval a -&gt; Interval a
hull (Interval l1 h1) (Interval l2 h2) = Interval (min l1 l2) (max h1 h2)
</code></pre>
<p>I did not expect this to work any better than my previous attempts at specifying some range with an upper limit. But it did.</p>
<p>Here is my constraint now:</p>
<p><code>Constraints.mustValidateIn (hull (from $ firstInterval)(to $ firstInterval + 8000))</code></p>

CC BY-SA 4.0
2021-10-28T15:19:53.817Z
2021-10-28T15:19:53.817Z
Isaac Padberg
<p>I want a transaction to only be valid for a certain period of time relative to some specified start time. I thought that maybe I could use <code>Constraints.mustValidateIn (interval firstInterval $ firstInterval + 10000)</code>, but this has failed to validate. It seems that it does not matter what the upper bound is, because it always fails... unless its positive infinity. So this: <code>Constraints.mustValidateIn (from $ firstInterval)</code> always works.</p>
<p>In the docs, <code>Constraints.mustValidateIn</code> has a footnote specifying this: &quot;@mustValidateIn r@ requires the transaction's time range to be contained in @r@.&quot;</p>
<p>So I guess what I am asking is what is a transactions time range? And can it be manipulated to fit this scenario?</p>
<p>Thanks!</p>

<time><validation><intervals>
Can you specify an upper and lower bound for the validity period of a transaction?
# Can you specify an upper and lower bound for the validity period of a transaction?

(Asked by: username_0 on 2021-10-27)

I want a transaction to only be valid for a certain period of time relative to some specified start time. I thought that maybe I could use `Constraints.mustValidateIn (interval firstInterval $ firstInterval + 10000)`, but this has failed to validate. It seems that it does not matter what the upper bound is, because it always fails... unless its positive infinity. So this: `Constraints.mustValidateIn (from $ firstInterval)` always works.

In the docs, `Constraints.mustValidateIn` has a footnote specifying this: "@mustValidateIn r@ requires the transaction's time range to be contained in @r@."

So I guess what I am asking is what is a transactions time range? And can it be manipulated to fit this scenario?

Thanks!

**Tags:** time, validation, intervals

---

## 1 answers

### Answer by username_0 on 2021-10-28. Score: 2

I discovered this cool function named hull. Here is the function definition from the docs.
-- The function hull gives the smallest interval containing both the given intervals.
hull :: Ord a => Interval a -> Interval a -> Interval a
hull (Interval l1 h1) (Interval l2 h2) = Interval (min l1 l2) (max h1 h2)

I did not expect this to work any better than my previous attempts at specifying some range with an upper limit. But it did.
Here is my constraint now:
Constraints.mustValidateIn (hull (from $ firstInterval)(to $ firstInterval + 8000))


---

