@@ -19,67 +19,67 @@ namespace internal {
1919Type SanitizeType (Type e) {
2020 int num_types = (e << " K" _mst) + (e << " V" _mst) + (e << " B" _mst) + (e << " W" _mst);
2121 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
3636 return e;
3737}
3838
3939Type ComputeType (Fragment fragment, Type x, Type y, Type z, const std::vector<Type>& sub_types, uint32_t k,
4040 size_t data_size, size_t n_subs, size_t n_keys, MiniscriptContext ms_ctx) {
4141 // Sanity check on data
4242 if (fragment == Fragment::SHA256 || fragment == Fragment::HASH256) {
43- assert (data_size == 32 );
43+ CHECK_NONFATAL (data_size == 32 );
4444 } else if (fragment == Fragment::RIPEMD160 || fragment == Fragment::HASH160) {
45- assert (data_size == 20 );
45+ CHECK_NONFATAL (data_size == 20 );
4646 } else {
47- assert (data_size == 0 );
47+ CHECK_NONFATAL (data_size == 0 );
4848 }
4949 // Sanity check on k
5050 if (fragment == Fragment::OLDER || fragment == Fragment::AFTER) {
51- assert (k >= 1 && k < 0x80000000UL );
51+ CHECK_NONFATAL (k >= 1 && k < 0x80000000UL );
5252 } else if (fragment == Fragment::MULTI || fragment == Fragment::MULTI_A) {
53- assert (k >= 1 && k <= n_keys);
53+ CHECK_NONFATAL (k >= 1 && k <= n_keys);
5454 } else if (fragment == Fragment::THRESH) {
55- assert (k >= 1 && k <= n_subs);
55+ CHECK_NONFATAL (k >= 1 && k <= n_subs);
5656 } else {
57- assert (k == 0 );
57+ CHECK_NONFATAL (k == 0 );
5858 }
5959 // Sanity check on subs
6060 if (fragment == Fragment::AND_V || fragment == Fragment::AND_B || fragment == Fragment::OR_B ||
6161 fragment == Fragment::OR_C || fragment == Fragment::OR_I || fragment == Fragment::OR_D) {
62- assert (n_subs == 2 );
62+ CHECK_NONFATAL (n_subs == 2 );
6363 } else if (fragment == Fragment::ANDOR) {
64- assert (n_subs == 3 );
64+ CHECK_NONFATAL (n_subs == 3 );
6565 } else if (fragment == Fragment::WRAP_A || fragment == Fragment::WRAP_S || fragment == Fragment::WRAP_C ||
6666 fragment == Fragment::WRAP_D || fragment == Fragment::WRAP_V || fragment == Fragment::WRAP_J ||
6767 fragment == Fragment::WRAP_N) {
68- assert (n_subs == 1 );
68+ CHECK_NONFATAL (n_subs == 1 );
6969 } else if (fragment != Fragment::THRESH) {
70- assert (n_subs == 0 );
70+ CHECK_NONFATAL (n_subs == 0 );
7171 }
7272 // Sanity check on keys
7373 if (fragment == Fragment::PK_K || fragment == Fragment::PK_H) {
74- assert (n_keys == 1 );
74+ CHECK_NONFATAL (n_keys == 1 );
7575 } 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));
7878 } 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));
8181 } else {
82- assert (n_keys == 0 );
82+ CHECK_NONFATAL (n_keys == 0 );
8383 }
8484
8585 // Below is the per-fragment logic for computing the expression types.
0 commit comments