Commit b68bf13
committed
Merge #654: Several locktime improvements
422b83c interpreter: use `relative::LockTime` for constraints from Miniscript (Andrew Poelstra)
fc42e48 miniscript: use RelLockTime in Terminal (Andrew Poelstra)
c490f49 policy: use `RelLockTime` in semantic and concrete policies (Andrew Poelstra)
a7a1b9a miniscript: use RelLockTime in `Satisfaction` (Andrew Poelstra)
fc6bfa8 introduce RelLockTime type (Andrew Poelstra)
637720a plan/satisfy: use relative::LockTime instead of Sequence to indicate relative locktimes (Andrew Poelstra)
bd6ef65 interpreter: rename "age" to "sequence" (Andrew Poelstra)
950b793 AbsLockTime: move to module, consolidate error checking (Andrew Poelstra)
60d7c98 types: drop unused "strongness" errors (Andrew Poelstra)
2f66778 types: replace closure with iterator (Andrew Poelstra)
Pull request description:
This PR:
* Changes user-facing "check locktime" functions to use `bitcoin::relative::LockTime` rather than `Sequence` numbers.
* Introduces a new `RelLockTime` type analogous to `AbsLockTime` which is used to provide a locktime type that implements `Ord`.
* In both types, validate that the locktimes are legal for use in Miniscript during creation, rather than during typechecking or validity checks.
* In many places, replace manual code with the new `is_implied_by` method from rust-bitcoin.
This might be a little hard to review because it messes with locktime code which is so easy to get backward. But it appears that there are pretty extensive unit tests which caught several iterations of this where I did get them backward. Going forward things should be much easier to maintain because we have stronger types and an encapsulated `is_implied_by` method.
The next PR will do a similar thing with thresholds to validate the `0 < k <= n` invariant when thresholds are created, avoiding the repeated and inconsistent post-hoc error checking logic.
Fixes #270
ACKs for top commit:
sanket1729:
ACK 422b83c
Tree-SHA512: 42a749a405c142c7ec468b2fd2e8c3c559c31e6eacf72a351c4dd24887385fa74d8128982a70cef69489c4ef72d6247860e1cd96e52ec83a00bdee0e3359d9b8File tree
22 files changed
+516
-453
lines changed- src
- descriptor
- interpreter
- miniscript
- types
- policy
- primitives
- psbt
22 files changed
+516
-453
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
515 | | - | |
| 515 | + | |
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
| |||
540 | 540 | | |
541 | 541 | | |
542 | 542 | | |
543 | | - | |
| 543 | + | |
| 544 | + | |
544 | 545 | | |
545 | 546 | | |
546 | 547 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
119 | | - | |
| 121 | + | |
120 | 122 | | |
121 | 123 | | |
122 | | - | |
| 124 | + | |
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
| |||
159 | 161 | | |
160 | 162 | | |
161 | 163 | | |
162 | | - | |
| 164 | + | |
163 | 165 | | |
164 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
165 | 170 | | |
166 | 171 | | |
167 | 172 | | |
| |||
188 | 193 | | |
189 | 194 | | |
190 | 195 | | |
191 | | - | |
192 | | - | |
| 196 | + | |
| 197 | + | |
193 | 198 | | |
194 | 199 | | |
195 | 200 | | |
| |||
212 | 217 | | |
213 | 218 | | |
214 | 219 | | |
215 | | - | |
| 220 | + | |
| 221 | + | |
216 | 222 | | |
217 | 223 | | |
218 | 224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
| 168 | + | |
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| |||
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
471 | | - | |
| 471 | + | |
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
| |||
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
511 | | - | |
| 511 | + | |
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
| |||
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
611 | | - | |
| 611 | + | |
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
| |||
1110 | 1110 | | |
1111 | 1111 | | |
1112 | 1112 | | |
1113 | | - | |
| 1113 | + | |
1114 | 1114 | | |
1115 | 1115 | | |
1116 | 1116 | | |
| |||
1182 | 1182 | | |
1183 | 1183 | | |
1184 | 1184 | | |
1185 | | - | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
1186 | 1188 | | |
1187 | 1189 | | |
1188 | 1190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 215 | + | |
221 | 216 | | |
222 | 217 | | |
223 | 218 | | |
224 | 219 | | |
225 | 220 | | |
226 | 221 | | |
227 | | - | |
| 222 | + | |
228 | 223 | | |
229 | 224 | | |
230 | 225 | | |
| |||
236 | 231 | | |
237 | 232 | | |
238 | 233 | | |
239 | | - | |
240 | | - | |
| 234 | + | |
| 235 | + | |
241 | 236 | | |
242 | | - | |
243 | | - | |
244 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
245 | 244 | | |
246 | | - | |
| 245 | + | |
| 246 | + | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| 129 | + | |
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
134 | | - | |
| 136 | + | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
138 | 140 | | |
139 | 141 | | |
140 | | - | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
| 153 | + | |
| 154 | + | |
152 | 155 | | |
153 | 156 | | |
154 | 157 | | |
| |||
501 | 504 | | |
502 | 505 | | |
503 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
504 | 511 | | |
505 | 512 | | |
506 | 513 | | |
| |||
576 | 583 | | |
577 | 584 | | |
578 | 585 | | |
| 586 | + | |
| 587 | + | |
579 | 588 | | |
580 | 589 | | |
581 | 590 | | |
| |||
628 | 637 | | |
629 | 638 | | |
630 | 639 | | |
| 640 | + | |
| 641 | + | |
631 | 642 | | |
632 | 643 | | |
633 | 644 | | |
| |||
711 | 722 | | |
712 | 723 | | |
713 | 724 | | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | | - | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | 725 | | |
760 | 726 | | |
761 | 727 | | |
| |||
0 commit comments