22 std::vector<Key> dummy_keys;
23 std::map<Key, int> dummy_key_idx_map;
24 std::map<CKeyID, Key> dummy_keys_map;
25 std::map<Key, std::pair<std::vector<unsigned char>,
bool>> dummy_sigs;
28 std::vector<std::vector<unsigned char>>
sha256;
29 std::vector<std::vector<unsigned char>>
ripemd160;
30 std::vector<std::vector<unsigned char>> hash256;
31 std::vector<std::vector<unsigned char>> hash160;
32 std::map<std::vector<unsigned char>, std::vector<unsigned char>> sha256_preimages;
33 std::map<std::vector<unsigned char>, std::vector<unsigned char>> ripemd160_preimages;
34 std::map<std::vector<unsigned char>, std::vector<unsigned char>> hash256_preimages;
35 std::map<std::vector<unsigned char>, std::vector<unsigned char>> hash160_preimages;
39 unsigned char keydata[32] = {1};
40 for (
size_t i = 0; i < 256; i++) {
43 privkey.
Set(keydata, keydata + 32,
true);
46 dummy_keys.push_back(pubkey);
47 dummy_key_idx_map.emplace(pubkey, i);
48 dummy_keys_map.insert({pubkey.GetID(), pubkey});
50 std::vector<unsigned char> sig;
53 dummy_sigs.insert({pubkey, {sig, i & 1}});
55 std::vector<unsigned char> hash;
59 if (i & 1) sha256_preimages[hash] = std::vector<unsigned char>(keydata, keydata + 32);
61 hash256.push_back(hash);
62 if (i & 1) hash256_preimages[hash] = std::vector<unsigned char>(keydata, keydata + 32);
67 if (i & 1) ripemd160_preimages[hash] = std::vector<unsigned char>(keydata, keydata + 32);
69 hash160.push_back(hash);
70 if (i & 1) hash160_preimages[hash] = std::vector<unsigned char>(keydata, keydata + 32);
80 struct ParserContext {
83 bool KeyCompare(
const Key& a,
const Key& b)
const {
87 std::optional<std::string>
ToString(
const Key& key)
const
89 auto it = TEST_DATA.dummy_key_idx_map.find(key);
90 if (it == TEST_DATA.dummy_key_idx_map.end())
return {};
91 uint8_t idx = it->second;
95 std::vector<unsigned char> ToPKBytes(
const Key& key)
const
97 return {key.begin(), key.end()};
100 std::vector<unsigned char> ToPKHBytes(
const Key& key)
const
103 return {h.begin(), h.end()};
107 std::optional<Key>
FromString(I first, I last)
const {
108 if (last - first != 2)
return {};
109 auto idx =
ParseHex(std::string(first, last));
110 if (idx.size() != 1)
return {};
111 return TEST_DATA.dummy_keys[idx[0]];
115 std::optional<Key> FromPKBytes(I first, I last)
const {
117 key.
Set(first, last);
123 std::optional<Key> FromPKHBytes(I first, I last)
const {
124 assert(last - first == 20);
126 std::copy(first, last, keyid.
begin());
127 const auto it = TEST_DATA.dummy_keys_map.find(keyid);
128 if (it == TEST_DATA.dummy_keys_map.end())
return {};
134 struct ScriptParserContext {
138 std::vector<unsigned char> data;
141 bool KeyCompare(
const Key& a,
const Key& b)
const {
142 return a.data < b.data;
145 const std::vector<unsigned char>& ToPKBytes(
const Key& key)
const
151 std::vector<unsigned char> ToPKHBytes(
const Key& key)
const
153 if (key.is_hash)
return key.data;
154 const auto h =
Hash160(key.data);
155 return {h.begin(), h.end()};
159 std::optional<Key> FromPKBytes(I first, I last)
const
162 key.data.assign(first, last);
168 std::optional<Key> FromPKHBytes(I first, I last)
const
171 key.data.assign(first, last);
175 } SCRIPT_PARSER_CONTEXT;
178 struct SatisfierContext: ParserContext {
181 bool CheckAfter(uint32_t value)
const {
return value % 2; }
182 bool CheckOlder(uint32_t value)
const {
return value % 2; }
186 const auto it = TEST_DATA.dummy_sigs.find(key);
188 if (it->second.second) {
190 sig = it->second.first;
199 const std::map<std::vector<unsigned char>, std::vector<unsigned char>>& map)
const
201 const auto it = map.find(hash);
203 preimage = it->second;
206 miniscript::Availability SatSHA256(
const std::vector<unsigned char>& hash, std::vector<unsigned char>& preimage)
const {
207 return LookupHash(hash, preimage, TEST_DATA.sha256_preimages);
209 miniscript::Availability SatRIPEMD160(
const std::vector<unsigned char>& hash, std::vector<unsigned char>& preimage)
const {
210 return LookupHash(hash, preimage, TEST_DATA.ripemd160_preimages);
212 miniscript::Availability SatHASH256(
const std::vector<unsigned char>& hash, std::vector<unsigned char>& preimage)
const {
213 return LookupHash(hash, preimage, TEST_DATA.hash256_preimages);
215 miniscript::Availability SatHASH160(
const std::vector<unsigned char>& hash, std::vector<unsigned char>& preimage)
const {
216 return LookupHash(hash, preimage, TEST_DATA.hash160_preimages);
225 bool CheckECDSASignature(
const std::vector<unsigned char>& sig,
const std::vector<unsigned char>& vchPubKey,
229 const auto it = TEST_DATA.dummy_sigs.find(key);
230 if (it == TEST_DATA.dummy_sigs.end())
return false;
231 return it->second.first == sig;
238 struct KeyComparator {
251 using miniscript::operator
"" _mst;
265 std::vector<CPubKey> keys;
267 std::vector<unsigned char> hash;
269 std::vector<Type> subtypes;
271 NodeInfo(
Fragment frag): fragment(frag),
k(0) {}
273 NodeInfo(
Fragment frag, uint32_t _k): fragment(frag),
k(_k) {}
274 NodeInfo(
Fragment frag, std::vector<unsigned char> h): fragment(frag),
k(0), hash(
std::move(h)) {}
275 NodeInfo(std::vector<Type> subt,
Fragment frag): fragment(frag),
k(0), subtypes(
std::move(subt)) {}
276 NodeInfo(std::vector<Type> subt,
Fragment frag, uint32_t _k): fragment(frag),
k(_k), subtypes(
std::move(subt)) {}
277 NodeInfo(
Fragment frag, uint32_t _k, std::vector<CPubKey> _keys): fragment(frag),
k(_k), keys(
std::move(_keys)) {}
281 template<
typename T,
typename A>
288 return ConsumeIndex<CPubKey>(provider, TEST_DATA.dummy_keys);
292 return ConsumeIndex<std::vector<unsigned char>>(provider, TEST_DATA.sha256);
296 return ConsumeIndex<std::vector<unsigned char>>(provider, TEST_DATA.hash256);
300 return ConsumeIndex<std::vector<unsigned char>>(provider, TEST_DATA.ripemd160);
304 return ConsumeIndex<std::vector<unsigned char>>(provider, TEST_DATA.hash160);
309 if (k == 0 || k >= 0x80000000)
return {};
326 std::optional<NodeInfo> ConsumeNodeStable(
FuzzedDataProvider& provider, Type type_needed) {
327 bool allow_B = (type_needed ==
""_mst) || (type_needed <<
"B"_mst);
328 bool allow_K = (type_needed ==
""_mst) || (type_needed <<
"K"_mst);
329 bool allow_V = (type_needed ==
""_mst) || (type_needed <<
"V"_mst);
330 bool allow_W = (type_needed ==
""_mst) || (type_needed <<
"W"_mst);
334 if (!allow_B)
return {};
335 return {{Fragment::JUST_0}};
337 if (!allow_B)
return {};
338 return {{Fragment::JUST_1}};
340 if (!allow_K)
return {};
341 return {{Fragment::PK_K, ConsumePubKey(provider)}};
343 if (!allow_K)
return {};
344 return {{Fragment::PK_H, ConsumePubKey(provider)}};
346 if (!allow_B)
return {};
347 const auto k = ConsumeTimeLock(provider);
349 return {{Fragment::OLDER, *
k}};
352 if (!allow_B)
return {};
353 const auto k = ConsumeTimeLock(provider);
355 return {{Fragment::AFTER, *
k}};
358 if (!allow_B)
return {};
361 if (!allow_B)
return {};
362 return {{Fragment::HASH256, ConsumeHash256(provider)}};
364 if (!allow_B)
return {};
367 if (!allow_B)
return {};
368 return {{Fragment::HASH160, ConsumeHash160(provider)}};
370 if (!allow_B)
return {};
373 if (n_keys > 20 || k == 0 || k > n_keys)
return {};
374 std::vector<CPubKey> keys{n_keys};
375 for (
auto& key: keys) key = ConsumePubKey(provider);
376 return {{Fragment::MULTI,
k, std::move(keys)}};
379 if (!(allow_B || allow_K || allow_V))
return {};
380 return {{{
"B"_mst, type_needed, type_needed}, Fragment::ANDOR}};
382 if (!(allow_B || allow_K || allow_V))
return {};
383 return {{{
"V"_mst, type_needed}, Fragment::AND_V}};
385 if (!allow_B)
return {};
386 return {{{
"B"_mst,
"W"_mst}, Fragment::AND_B}};
388 if (!allow_B)
return {};
389 return {{{
"B"_mst,
"W"_mst}, Fragment::OR_B}};
391 if (!allow_V)
return {};
392 return {{{
"B"_mst,
"V"_mst}, Fragment::OR_C}};
394 if (!allow_B)
return {};
395 return {{{
"B"_mst,
"B"_mst}, Fragment::OR_D}};
397 if (!(allow_B || allow_K || allow_V))
return {};
398 return {{{type_needed, type_needed}, Fragment::OR_I}};
400 if (!allow_B)
return {};
403 if (k == 0 || k > n_subs)
return {};
404 std::vector<Type> subtypes;
405 subtypes.reserve(n_subs);
406 subtypes.emplace_back(
"B"_mst);
407 for (
size_t i = 1; i < n_subs; ++i) subtypes.emplace_back(
"W"_mst);
408 return {{std::move(subtypes), Fragment::THRESH,
k}};
411 if (!allow_W)
return {};
412 return {{{
"B"_mst}, Fragment::WRAP_A}};
414 if (!allow_W)
return {};
415 return {{{
"B"_mst}, Fragment::WRAP_S}};
417 if (!allow_B)
return {};
418 return {{{
"K"_mst}, Fragment::WRAP_C}};
420 if (!allow_B)
return {};
421 return {{{
"V"_mst}, Fragment::WRAP_D}};
423 if (!allow_V)
return {};
424 return {{{
"B"_mst}, Fragment::WRAP_V}};
426 if (!allow_B)
return {};
427 return {{{
"B"_mst}, Fragment::WRAP_J}};
429 if (!allow_B)
return {};
430 return {{{
"B"_mst}, Fragment::WRAP_N}};
446 using recipe = std::pair<Fragment, std::vector<Type>>;
447 std::map<Type, std::vector<recipe>> table;
452 std::vector<Type> types;
453 for (
int base = 0; base < 4; ++base) {
454 Type type_base = base == 0 ?
"B"_mst : base == 1 ?
"K"_mst : base == 2 ?
"V"_mst :
"W"_mst;
455 for (
int zo = 0; zo < 3; ++zo) {
456 Type type_zo = zo == 0 ?
"z"_mst : zo == 1 ?
"o"_mst :
""_mst;
457 for (
int n = 0; n < 2; ++n) {
458 if (zo == 0 && n == 1)
continue;
459 if (base == 3 && n == 1)
continue;
460 Type type_n = n == 0 ?
""_mst :
"n"_mst;
461 for (
int d = 0; d < 2; ++d) {
462 if (base == 2 && d == 1)
continue;
463 Type type_d = d == 0 ?
""_mst :
"d"_mst;
464 for (
int u = 0; u < 2; ++u) {
465 if (base == 2 && u == 1)
continue;
466 Type type_u = u == 0 ?
""_mst :
"u"_mst;
467 Type type = type_base | type_zo | type_n | type_d | type_u;
468 types.push_back(type);
481 auto is_super_of = [](
const recipe& a,
const recipe& b) {
482 if (a.first != b.first)
return false;
483 if (a.second.size() != b.second.size())
return false;
484 for (
size_t i = 0; i < a.second.size(); ++i) {
485 if (!(b.second[i] << a.second[i]))
return false;
495 std::sort(types.begin(), types.end());
498 for (
int fragidx = 0; fragidx <= int(Fragment::MULTI); ++fragidx) {
501 size_t data_size = 0;
512 case Fragment::MULTI:
516 case Fragment::OLDER:
517 case Fragment::AFTER:
521 case Fragment::HASH256:
525 case Fragment::HASH160:
528 case Fragment::JUST_0:
529 case Fragment::JUST_1:
531 case Fragment::WRAP_A:
532 case Fragment::WRAP_S:
533 case Fragment::WRAP_C:
534 case Fragment::WRAP_D:
535 case Fragment::WRAP_V:
536 case Fragment::WRAP_J:
537 case Fragment::WRAP_N:
540 case Fragment::AND_V:
541 case Fragment::AND_B:
548 case Fragment::ANDOR:
551 case Fragment::THRESH:
560 std::vector<Type> subt;
561 for (
int subs = sub_count; subs < sub_count + sub_range; ++subs) {
563 for (Type x : types) {
564 for (Type y : types) {
565 for (Type z : types) {
568 if (subs > 0) subt.push_back(x);
569 if (subs > 1) subt.push_back(y);
570 if (subs > 2) subt.push_back(z);
573 if ((res <<
"K"_mst) + (res <<
"V"_mst) + (res <<
"B"_mst) + (res <<
"W"_mst) != 1)
continue;
575 recipe entry{frag, subt};
576 auto super_of_entry = [&](
const recipe& rec) {
return is_super_of(rec, entry); };
579 for (Type s : types) {
580 if ((res &
"BKVWzondu"_mst) << s) {
581 auto& recipes = table[s];
583 if (!std::any_of(recipes.begin(), recipes.end(), super_of_entry)) {
584 recipes.push_back(entry);
589 if (subs <= 2)
break;
591 if (subs <= 1)
break;
593 if (subs <= 0)
break;
601 std::set<Type> useful_types{
"B"_mst,
"V"_mst,
"K"_mst,
"W"_mst};
604 size_t set_size = useful_types.size();
605 for (
const auto& [type, recipes] : table) {
606 if (useful_types.count(type) != 0) {
607 for (
const auto& [
_, subtypes] : recipes) {
608 for (
auto subtype : subtypes) useful_types.insert(subtype);
612 if (useful_types.size() == set_size)
break;
615 for (
auto type_it = table.begin(); type_it != table.end();) {
616 if (useful_types.count(type_it->first) == 0) {
617 type_it = table.erase(type_it);
628 std::set<Type> constructible_types{};
629 auto known_constructible = [&](Type type) {
return constructible_types.count(type) != 0; };
632 size_t set_size = constructible_types.size();
634 for (
const auto& [type, recipes] : table) {
635 if (!known_constructible(type)) {
637 for (
const auto& [
_, subt] : recipes) {
640 if (std::all_of(subt.begin(), subt.end(), known_constructible)) {
641 constructible_types.insert(type);
647 if (constructible_types.size() == set_size)
break;
649 for (
auto type_it = table.begin(); type_it != table.end();) {
651 type_it->second.erase(std::remove_if(type_it->second.begin(), type_it->second.end(),
652 [&](
const recipe& rec) {
653 return !std::all_of(rec.second.begin(), rec.second.end(), known_constructible);
654 }), type_it->second.end());
656 if (type_it->second.empty()) {
657 type_it = table.erase(type_it);
663 for (
auto& [type, recipes] : table) {
667 std::sort(recipes.begin(), recipes.end(),
668 [](
const recipe& a,
const recipe& b) {
669 if (a.second.size() < b.second.size()) return true;
670 if (a.second.size() > b.second.size()) return false;
688 std::optional<NodeInfo> ConsumeNodeSmart(
FuzzedDataProvider& provider, Type type_needed) {
690 auto recipes_it = SMARTINFO.table.find(type_needed);
691 assert(recipes_it != SMARTINFO.table.end());
693 const auto& [frag, subt] =
PickValue(provider, recipes_it->second);
699 return {{frag, ConsumePubKey(provider)}};
700 case Fragment::MULTI: {
703 std::vector<CPubKey> keys{n_keys};
704 for (
auto& key: keys) key = ConsumePubKey(provider);
705 return {{frag,
k, std::move(keys)}};
707 case Fragment::OLDER:
708 case Fragment::AFTER:
711 return {{frag,
PickValue(provider, TEST_DATA.sha256)}};
712 case Fragment::HASH256:
713 return {{frag,
PickValue(provider, TEST_DATA.hash256)}};
715 return {{frag,
PickValue(provider, TEST_DATA.ripemd160)}};
716 case Fragment::HASH160:
717 return {{frag,
PickValue(provider, TEST_DATA.hash160)}};
718 case Fragment::JUST_0:
719 case Fragment::JUST_1:
720 case Fragment::WRAP_A:
721 case Fragment::WRAP_S:
722 case Fragment::WRAP_C:
723 case Fragment::WRAP_D:
724 case Fragment::WRAP_V:
725 case Fragment::WRAP_J:
726 case Fragment::WRAP_N:
727 case Fragment::AND_V:
728 case Fragment::AND_B:
733 case Fragment::ANDOR:
734 return {{subt, frag}};
735 case Fragment::THRESH: {
737 if (subt.size() < 2) {
738 children = subt.size();
745 std::vector<Type> subs = subt;
746 while (subs.size() < children) subs.push_back(subs.back());
747 return {{std::move(subs), frag,
k}};
765 std::vector<NodeRef> stack;
767 std::vector<std::pair<Type, std::optional<NodeInfo>>> todo{{root_type, {}}};
772 uint32_t scriptsize{1};
774 while (!todo.empty()) {
776 auto type_needed = todo.back().first;
777 if (!todo.back().second) {
780 if (!node_info)
return {};
786 switch (node_info->fragment) {
787 case Fragment::JUST_0:
788 case Fragment::JUST_1:
795 case Fragment::OLDER:
796 case Fragment::AFTER:
801 case Fragment::HASH160:
802 case Fragment::HASH256:
805 case Fragment::ANDOR:
808 case Fragment::AND_V:
810 case Fragment::AND_B:
823 case Fragment::THRESH:
824 ops += node_info->subtypes.size();
826 case Fragment::MULTI:
829 case Fragment::WRAP_A:
832 case Fragment::WRAP_S:
835 case Fragment::WRAP_C:
838 case Fragment::WRAP_D:
841 case Fragment::WRAP_V:
845 case Fragment::WRAP_J:
848 case Fragment::WRAP_N:
853 auto subtypes = node_info->subtypes;
854 todo.back().second = std::move(node_info);
855 todo.reserve(todo.size() + subtypes.size());
858 for (
size_t i = 0; i < subtypes.size(); ++i) {
859 todo.emplace_back(*(subtypes.rbegin() + i), std::nullopt);
866 NodeInfo& info = *todo.back().second;
868 std::vector<NodeRef> sub;
869 sub.reserve(info.subtypes.size());
870 for (
size_t i = 0; i < info.subtypes.size(); ++i) {
871 sub.push_back(std::move(*(stack.end() - info.subtypes.size() + i)));
873 stack.erase(stack.end() - info.subtypes.size(), stack.end());
876 if (info.keys.empty()) {
877 node =
MakeNodeRef(info.fragment, std::move(sub), std::move(info.hash), info.k);
880 assert(info.hash.empty());
884 if (!
node || (
node->GetType() &
"KVWB"_mst) ==
""_mst) {
888 if (!(type_needed ==
""_mst)) {
891 if (!
node->IsValid())
return {};
893 if (
node->fragment == Fragment::WRAP_V &&
node->subs[0]->GetType() <<
"x"_mst) {
900 stack.push_back(std::move(
node));
904 assert(stack.size() == 1);
905 assert(stack[0]->GetStaticOps() == ops);
906 assert(stack[0]->ScriptSize() == scriptsize);
907 stack[0]->DuplicateKeyCheck(KEY_COMP);
908 return std::move(stack[0]);
917 std::optional<std::string> str{
node->ToString(PARSER_CTX)};
924 auto script =
node->ToScript(PARSER_CTX);
929 if (!(
node->GetType() <<
"K"_mst)) {
930 bool ends_in_verify = !(
node->GetType() <<
"x"_mst);
935 if (!
node->IsValidTopLevel())
return;
943 assert(decoded->ToScript(PARSER_CTX) == script);
944 assert(decoded->GetType() ==
node->GetType());
946 const auto node_ops{
node->GetOps()};
957 int add = std::min<int>(
960 for (
int i = 0; i < add; ++i) script.push_back(
OP_NOP);
967 witness_mal.
stack.push_back(std::vector<unsigned char>(script.begin(), script.end()));
972 witness_nonmal.
stack.push_back(std::vector<unsigned char>(script.begin(), script.end()));
974 if (nonmal_success) {
993 if (mal_success && (!nonmal_success || witness_mal.
stack != witness_nonmal.
stack)) {
1002 if (
node->IsSane()) {
1004 assert(mal_success == nonmal_success);
1011 bool satisfiable =
node->IsSatisfiable([](
const Node&
node) ->
bool {
1012 switch (
node.fragment) {
1013 case Fragment::PK_K:
1014 case Fragment::PK_H: {
1015 auto it = TEST_DATA.dummy_sigs.find(node.keys[0]);
1016 assert(it != TEST_DATA.dummy_sigs.end());
1017 return it->second.second;
1019 case Fragment::MULTI: {
1021 for (const auto& key : node.keys) {
1022 auto it = TEST_DATA.dummy_sigs.find(key);
1023 assert(it != TEST_DATA.dummy_sigs.end());
1024 sats += it->second.second;
1026 return sats >=
node.k;
1028 case Fragment::OLDER:
1029 case Fragment::AFTER:
1032 return TEST_DATA.sha256_preimages.count(
node.data);
1033 case Fragment::HASH256:
1034 return TEST_DATA.hash256_preimages.count(
node.data);
1036 return TEST_DATA.ripemd160_preimages.count(
node.data);
1037 case Fragment::HASH160:
1038 return TEST_DATA.hash160_preimages.count(
node.data);
1044 assert(mal_success == satisfiable);
1065 TestNode(GenNode([&](Type needed_type) {
1066 return ConsumeNodeStable(provider, needed_type);
1067 },
""_mst), provider);
1074 static constexpr std::array<Type, 4> BASE_TYPES{
"B"_mst,
"V"_mst,
"K"_mst,
"W"_mst};
1077 TestNode(GenNode([&](Type needed_type) {
1078 return ConsumeNodeSmart(provider, needed_type);
1079 },
PickValue(provider, BASE_TYPES),
true), provider);
1088 if (!parsed)
return;
1090 const auto str2 = parsed->ToString(PARSER_CTX);
1094 assert(*parsed == *parsed2);
1101 const std::optional<CScript> script = ConsumeDeserializable<CScript>(fuzzed_data_provider);
1102 if (!script)
return;
1107 assert(ms->ToScript(SCRIPT_PARSER_CONTEXT) == *script);
virtual bool CheckLockTime(const CScriptNum &nLockTime) const
virtual bool CheckSequence(const CScriptNum &nSequence) const
virtual bool CheckECDSASignature(const std::vector< unsigned char > &scriptSig, const std::vector< unsigned char > &vchPubKey, const CScript &scriptCode, SigVersion sigversion) const
A hasher class for Bitcoin's 160-bit hash (SHA-256 + RIPEMD-160).
void Finalize(Span< unsigned char > output)
CHash160 & Write(Span< const unsigned char > input)
A hasher class for Bitcoin's 256-bit hash (double SHA-256).
CHash256 & Write(Span< const unsigned char > input)
void Finalize(Span< unsigned char > output)
An encapsulated private key.
bool Sign(const uint256 &hash, std::vector< unsigned char > &vchSig, bool grind=true, uint32_t test_case=0) const
Create a DER-serialized signature.
CPubKey GetPubKey() const
Compute the public key from a private key.
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
A reference to a CKey: the Hash160 of its serialized public key.
An encapsulated public key.
void Set(const T pbegin, const T pend)
Initialize a public key using begin/end iterators to byte data.
A hasher class for RIPEMD-160.
CRIPEMD160 & Write(const unsigned char *data, size_t len)
void Finalize(unsigned char hash[OUTPUT_SIZE])
A hasher class for SHA-256.
void Finalize(unsigned char hash[OUTPUT_SIZE])
CSHA256 & Write(const unsigned char *data, size_t len)
Serialized script, used inside transaction inputs and outputs.
T ConsumeIntegralInRange(T min, T max)
std::string ConsumeRemainingBytesAsString()
A Span is an object that can refer to a contiguous sequence of objects.
constexpr unsigned char * begin()
This type encapsulates the miniscript type system properties.
static void SHA256(benchmark::Bench &bench)
uint160 Hash160(const T1 &in1)
Compute the 160-bit hash an object.
uint160 RIPEMD160(Span< const unsigned char > data)
Compute the 160-bit RIPEMD-160 hash of an array.
#define T(expected, seed, data)
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
Type ComputeType(Fragment fragment, Type x, Type y, Type z, const std::vector< Type > &sub_types, uint32_t k, size_t data_size, size_t n_subs, size_t n_keys)
Helper function for Node::CalcType.
size_t ComputeScriptLen(Fragment fragment, Type sub0typ, size_t subsize, uint32_t k, size_t n_subs, size_t n_keys)
Helper function for Node::CalcScriptLen.
std::shared_ptr< const Node< Key > > NodeRef
NodeRef< Key > MakeNodeRef(Args &&... args)
Construct a miniscript node as a shared_ptr.
NodeRef< typename Ctx::Key > FromScript(const CScript &script, const Ctx &ctx)
NodeRef< typename Ctx::Key > FromString(const std::string &str, const Ctx &ctx)
Fragment
The different node types in miniscript.
Internal RIPEMD-160 implementation.
Internal SHA-256 implementation.
static constexpr unsigned int STANDARD_SCRIPT_VERIFY_FLAGS
Standard script verification flags that standard transactions will comply with.
static constexpr unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE
The maximum size in bytes of a standard witnessScript.
static const int MAX_OPS_PER_SCRIPT
enum ScriptError_t ScriptError
std::vector< Byte > ParseHex(std::string_view hex_str)
Like TryParseHex, but returns an empty vector on invalid input.
std::string ToString(const T &t)
Locale-independent version of std::to_string.
std::vector< std::vector< unsigned char > > stack
A node in a miniscript expression.
FUZZ_TARGET(miniscript_stable,.init=FuzzInit)
Fuzz target that runs TestNode on nodes generated using ConsumeNodeStable.
auto ConsumeNode(FuzzedDataProvider &fuzzed_data_provider, const std::optional< NodeId > &node_id_in=std::nullopt) noexcept
auto & PickValue(FuzzedDataProvider &fuzzed_data_provider, Collection &col)
bilingual_str _(const char *psz)
Translation function.
uint256 uint256S(const char *str)
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.