@@ -19,67 +19,67 @@ namespace internal {
19
19
Type SanitizeType (Type e) {
20
20
int num_types = (e << " K" _mst) + (e << " V" _mst) + (e << " B" _mst) + (e << " W" _mst);
21
21
if (num_types == 0 ) return " " _mst; // No valid type, don't care about the rest
22
- assert (num_types == 1 ); // K, V, B, W all conflict with each other
23
- assert (!(e << " z" _mst) || !(e << " o" _mst)); // z conflicts with o
24
- assert (!(e << " n" _mst) || !(e << " z" _mst)); // n conflicts with z
25
- assert (!(e << " n" _mst) || !(e << " W" _mst)); // n conflicts with W
26
- assert (!(e << " V" _mst) || !(e << " d" _mst)); // V conflicts with d
27
- assert (!(e << " K" _mst) || (e << " u" _mst)); // K implies u
28
- assert (!(e << " V" _mst) || !(e << " u" _mst)); // V conflicts with u
29
- assert (!(e << " e" _mst) || !(e << " f" _mst)); // e conflicts with f
30
- assert (!(e << " e" _mst) || (e << " d" _mst)); // e implies d
31
- assert (!(e << " V" _mst) || !(e << " e" _mst)); // V conflicts with e
32
- assert (!(e << " d" _mst) || !(e << " f" _mst)); // d conflicts with f
33
- assert (!(e << " V" _mst) || (e << " f" _mst)); // V implies f
34
- assert (!(e << " K" _mst) || (e << " s" _mst)); // K implies s
35
- assert (!(e << " z" _mst) || (e << " m" _mst)); // z implies m
22
+ CHECK_NONFATAL (num_types == 1 ); // K, V, B, W all conflict with each other
23
+ CHECK_NONFATAL (!(e << " z" _mst) || !(e << " o" _mst)); // z conflicts with o
24
+ CHECK_NONFATAL (!(e << " n" _mst) || !(e << " z" _mst)); // n conflicts with z
25
+ CHECK_NONFATAL (!(e << " n" _mst) || !(e << " W" _mst)); // n conflicts with W
26
+ CHECK_NONFATAL (!(e << " V" _mst) || !(e << " d" _mst)); // V conflicts with d
27
+ CHECK_NONFATAL (!(e << " K" _mst) || (e << " u" _mst)); // K implies u
28
+ CHECK_NONFATAL (!(e << " V" _mst) || !(e << " u" _mst)); // V conflicts with u
29
+ CHECK_NONFATAL (!(e << " e" _mst) || !(e << " f" _mst)); // e conflicts with f
30
+ CHECK_NONFATAL (!(e << " e" _mst) || (e << " d" _mst)); // e implies d
31
+ CHECK_NONFATAL (!(e << " V" _mst) || !(e << " e" _mst)); // V conflicts with e
32
+ CHECK_NONFATAL (!(e << " d" _mst) || !(e << " f" _mst)); // d conflicts with f
33
+ CHECK_NONFATAL (!(e << " V" _mst) || (e << " f" _mst)); // V implies f
34
+ CHECK_NONFATAL (!(e << " K" _mst) || (e << " s" _mst)); // K implies s
35
+ CHECK_NONFATAL (!(e << " z" _mst) || (e << " m" _mst)); // z implies m
36
36
return e;
37
37
}
38
38
39
39
Type ComputeType (Fragment fragment, Type x, Type y, Type z, const std::vector<Type>& sub_types, uint32_t k,
40
40
size_t data_size, size_t n_subs, size_t n_keys, MiniscriptContext ms_ctx) {
41
41
// Sanity check on data
42
42
if (fragment == Fragment::SHA256 || fragment == Fragment::HASH256) {
43
- assert (data_size == 32 );
43
+ CHECK_NONFATAL (data_size == 32 );
44
44
} else if (fragment == Fragment::RIPEMD160 || fragment == Fragment::HASH160) {
45
- assert (data_size == 20 );
45
+ CHECK_NONFATAL (data_size == 20 );
46
46
} else {
47
- assert (data_size == 0 );
47
+ CHECK_NONFATAL (data_size == 0 );
48
48
}
49
49
// Sanity check on k
50
50
if (fragment == Fragment::OLDER || fragment == Fragment::AFTER) {
51
- assert (k >= 1 && k < 0x80000000UL );
51
+ CHECK_NONFATAL (k >= 1 && k < 0x80000000UL );
52
52
} else if (fragment == Fragment::MULTI || fragment == Fragment::MULTI_A) {
53
- assert (k >= 1 && k <= n_keys);
53
+ CHECK_NONFATAL (k >= 1 && k <= n_keys);
54
54
} else if (fragment == Fragment::THRESH) {
55
- assert (k >= 1 && k <= n_subs);
55
+ CHECK_NONFATAL (k >= 1 && k <= n_subs);
56
56
} else {
57
- assert (k == 0 );
57
+ CHECK_NONFATAL (k == 0 );
58
58
}
59
59
// Sanity check on subs
60
60
if (fragment == Fragment::AND_V || fragment == Fragment::AND_B || fragment == Fragment::OR_B ||
61
61
fragment == Fragment::OR_C || fragment == Fragment::OR_I || fragment == Fragment::OR_D) {
62
- assert (n_subs == 2 );
62
+ CHECK_NONFATAL (n_subs == 2 );
63
63
} else if (fragment == Fragment::ANDOR) {
64
- assert (n_subs == 3 );
64
+ CHECK_NONFATAL (n_subs == 3 );
65
65
} else if (fragment == Fragment::WRAP_A || fragment == Fragment::WRAP_S || fragment == Fragment::WRAP_C ||
66
66
fragment == Fragment::WRAP_D || fragment == Fragment::WRAP_V || fragment == Fragment::WRAP_J ||
67
67
fragment == Fragment::WRAP_N) {
68
- assert (n_subs == 1 );
68
+ CHECK_NONFATAL (n_subs == 1 );
69
69
} else if (fragment != Fragment::THRESH) {
70
- assert (n_subs == 0 );
70
+ CHECK_NONFATAL (n_subs == 0 );
71
71
}
72
72
// Sanity check on keys
73
73
if (fragment == Fragment::PK_K || fragment == Fragment::PK_H) {
74
- assert (n_keys == 1 );
74
+ CHECK_NONFATAL (n_keys == 1 );
75
75
} else if (fragment == Fragment::MULTI) {
76
- assert (n_keys >= 1 && n_keys <= MAX_PUBKEYS_PER_MULTISIG);
77
- assert (!IsTapscript (ms_ctx));
76
+ CHECK_NONFATAL (n_keys >= 1 && n_keys <= MAX_PUBKEYS_PER_MULTISIG);
77
+ CHECK_NONFATAL (!IsTapscript (ms_ctx));
78
78
} else if (fragment == Fragment::MULTI_A) {
79
- assert (n_keys >= 1 && n_keys <= MAX_PUBKEYS_PER_MULTI_A);
80
- assert (IsTapscript (ms_ctx));
79
+ CHECK_NONFATAL (n_keys >= 1 && n_keys <= MAX_PUBKEYS_PER_MULTI_A);
80
+ CHECK_NONFATAL (IsTapscript (ms_ctx));
81
81
} else {
82
- assert (n_keys == 0 );
82
+ CHECK_NONFATAL (n_keys == 0 );
83
83
}
84
84
85
85
// Below is the per-fragment logic for computing the expression types.
0 commit comments