Coverage Report

Created: 2026-07-14 18:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/bitcoin/src/script/miniscript.h
Line
Count
Source
1
// Copyright (c) 2019-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#ifndef BITCOIN_SCRIPT_MINISCRIPT_H
6
#define BITCOIN_SCRIPT_MINISCRIPT_H
7
8
#include <consensus/consensus.h>
9
#include <crypto/hex_base.h>
10
#include <policy/policy.h>
11
#include <script/interpreter.h>
12
#include <script/parsing.h>
13
#include <script/script.h>
14
#include <serialize.h>
15
#include <util/check.h>
16
#include <util/strencodings.h>
17
#include <util/string.h>
18
#include <util/vector.h>
19
20
#include <algorithm>
21
#include <concepts>
22
#include <cstdint>
23
#include <cstdlib>
24
#include <functional>
25
#include <memory>
26
#include <optional>
27
#include <set>
28
#include <span>
29
#include <stdexcept>
30
#include <string>
31
#include <string_view>
32
#include <tuple>
33
#include <utility>
34
#include <variant>
35
#include <vector>
36
37
namespace miniscript {
38
39
/** This type encapsulates the miniscript type system properties.
40
 *
41
 * Every miniscript expression is one of 4 basic types, and additionally has
42
 * a number of boolean type properties.
43
 *
44
 * The basic types are:
45
 * - "B" Base:
46
 *   - Takes its inputs from the top of the stack.
47
 *   - When satisfied, pushes a nonzero value of up to 4 bytes onto the stack.
48
 *   - When dissatisfied, pushes a 0 onto the stack.
49
 *   - This is used for most expressions, and required for the top level one.
50
 *   - For example: older(n) = <n> OP_CHECKSEQUENCEVERIFY.
51
 * - "V" Verify:
52
 *   - Takes its inputs from the top of the stack.
53
 *   - When satisfied, pushes nothing.
54
 *   - Cannot be dissatisfied.
55
 *   - This can be obtained by adding an OP_VERIFY to a B, modifying the last opcode
56
 *     of a B to its -VERIFY version (only for OP_CHECKSIG, OP_CHECKSIGVERIFY,
57
 *     OP_NUMEQUAL and OP_EQUAL), or by combining a V fragment under some conditions.
58
 *   - For example vc:pk_k(key) = <key> OP_CHECKSIGVERIFY
59
 * - "K" Key:
60
 *   - Takes its inputs from the top of the stack.
61
 *   - Becomes a B when followed by OP_CHECKSIG.
62
 *   - Always pushes a public key onto the stack, for which a signature is to be
63
 *     provided to satisfy the expression.
64
 *   - For example pk_h(key) = OP_DUP OP_HASH160 <Hash160(key)> OP_EQUALVERIFY
65
 * - "W" Wrapped:
66
 *   - Takes its input from one below the top of the stack.
67
 *   - When satisfied, pushes a nonzero value (like B) on top of the stack, or one below.
68
 *   - When dissatisfied, pushes 0 op top of the stack or one below.
69
 *   - Is always "OP_SWAP [B]" or "OP_TOALTSTACK [B] OP_FROMALTSTACK".
70
 *   - For example sc:pk_k(key) = OP_SWAP <key> OP_CHECKSIG
71
 *
72
 * There are type properties that help reasoning about correctness:
73
 * - "z" Zero-arg:
74
 *   - Is known to always consume exactly 0 stack elements.
75
 *   - For example after(n) = <n> OP_CHECKLOCKTIMEVERIFY
76
 * - "o" One-arg:
77
 *   - Is known to always consume exactly 1 stack element.
78
 *   - Conflicts with property 'z'
79
 *   - For example sha256(hash) = OP_SIZE 32 OP_EQUALVERIFY OP_SHA256 <hash> OP_EQUAL
80
 * - "n" Nonzero:
81
 *   - For every way this expression can be satisfied, a satisfaction exists that never needs
82
 *     a zero top stack element.
83
 *   - Conflicts with property 'z' and with type 'W'.
84
 * - "d" Dissatisfiable:
85
 *   - There is an easy way to construct a dissatisfaction for this expression.
86
 *   - Conflicts with type 'V'.
87
 * - "u" Unit:
88
 *   - In case of satisfaction, an exact 1 is put on the stack (rather than just nonzero).
89
 *   - Conflicts with type 'V'.
90
 *
91
 * Additional type properties help reasoning about nonmalleability:
92
 * - "e" Expression:
93
 *   - This implies property 'd', but the dissatisfaction is nonmalleable.
94
 *   - This generally requires 'e' for all subexpressions which are invoked for that
95
 *     dissatisfaction, and property 'f' for the unexecuted subexpressions in that case.
96
 *   - Conflicts with type 'V'.
97
 * - "f" Forced:
98
 *   - Dissatisfactions (if any) for this expression always involve at least one signature.
99
 *   - Is always true for type 'V'.
100
 * - "s" Safe:
101
 *   - Satisfactions for this expression always involve at least one signature.
102
 * - "m" Nonmalleable:
103
 *   - For every way this expression can be satisfied (which may be none),
104
 *     a nonmalleable satisfaction exists.
105
 *   - This generally requires 'm' for all subexpressions, and 'e' for all subexpressions
106
 *     which are dissatisfied when satisfying the parent.
107
 *
108
 * One type property is an implementation detail:
109
 * - "x" Expensive verify:
110
 *   - Expressions with this property have a script whose last opcode is not EQUAL, CHECKSIG, or CHECKMULTISIG.
111
 *   - Not having this property means that it can be converted to a V at no cost (by switching to the
112
 *     -VERIFY version of the last opcode).
113
 *
114
 * Five more type properties for representing timelock information. Spend paths
115
 * in miniscripts containing conflicting timelocks and heightlocks cannot be spent together.
116
 * This helps users detect if miniscript does not match the semantic behaviour the
117
 * user expects.
118
 * - "g" Whether the branch contains a relative time timelock
119
 * - "h" Whether the branch contains a relative height timelock
120
 * - "i" Whether the branch contains an absolute time timelock
121
 * - "j" Whether the branch contains an absolute height timelock
122
 * - "k"
123
 *   - Whether all satisfactions of this expression don't contain a mix of heightlock and timelock
124
 *     of the same type.
125
 *   - If the miniscript does not have the "k" property, the miniscript template will not match
126
 *     the user expectation of the corresponding spending policy.
127
 * For each of these properties the subset rule holds: an expression with properties X, Y, and Z, is also
128
 * valid in places where an X, a Y, a Z, an XY, ... is expected.
129
*/
130
class Type {
131
    //! Internal bitmap of properties (see ""_mst operator for details).
132
    uint32_t m_flags;
133
134
    //! Internal constructor used by the ""_mst operator.
135
0
    explicit constexpr Type(uint32_t flags) : m_flags(flags) {}
136
137
public:
138
    //! The only way to publicly construct a Type is using this literal operator.
139
    friend consteval Type operator""_mst(const char* c, size_t l);
140
141
    //! Compute the type with the union of properties.
142
0
    constexpr Type operator|(Type x) const { return Type(m_flags | x.m_flags); }
143
144
    //! Compute the type with the intersection of properties.
145
0
    constexpr Type operator&(Type x) const { return Type(m_flags & x.m_flags); }
146
147
    //! Check whether the left hand's properties are superset of the right's (= left is a subtype of right).
148
0
    constexpr bool operator<<(Type x) const { return (x.m_flags & ~m_flags) == 0; }
149
150
    //! Comparison operator to enable use in sets/maps (total ordering incompatible with <<).
151
0
    constexpr bool operator<(Type x) const { return m_flags < x.m_flags; }
152
153
    //! Equality operator.
154
0
    constexpr bool operator==(Type x) const { return m_flags == x.m_flags; }
155
156
    //! The empty type if x is false, itself otherwise.
157
0
    constexpr Type If(bool x) const { return Type(x ? m_flags : 0); }
  Branch (157:51): [True: 0, False: 0]
158
};
159
160
//! Literal operator to construct Type objects.
161
inline consteval Type operator""_mst(const char* c, size_t l)
162
{
163
    Type typ{0};
164
165
    for (const char *p = c; p < c + l; p++) {
166
        typ = typ | Type(
167
            *p == 'B' ? 1 << 0 : // Base type
168
            *p == 'V' ? 1 << 1 : // Verify type
169
            *p == 'K' ? 1 << 2 : // Key type
170
            *p == 'W' ? 1 << 3 : // Wrapped type
171
            *p == 'z' ? 1 << 4 : // Zero-arg property
172
            *p == 'o' ? 1 << 5 : // One-arg property
173
            *p == 'n' ? 1 << 6 : // Nonzero arg property
174
            *p == 'd' ? 1 << 7 : // Dissatisfiable property
175
            *p == 'u' ? 1 << 8 : // Unit property
176
            *p == 'e' ? 1 << 9 : // Expression property
177
            *p == 'f' ? 1 << 10 : // Forced property
178
            *p == 's' ? 1 << 11 : // Safe property
179
            *p == 'm' ? 1 << 12 : // Nonmalleable property
180
            *p == 'x' ? 1 << 13 : // Expensive verify
181
            *p == 'g' ? 1 << 14 : // older: contains relative time timelock   (csv_time)
182
            *p == 'h' ? 1 << 15 : // older: contains relative height timelock (csv_height)
183
            *p == 'i' ? 1 << 16 : // after: contains time timelock   (cltv_time)
184
            *p == 'j' ? 1 << 17 : // after: contains height timelock   (cltv_height)
185
            *p == 'k' ? 1 << 18 : // does not contain a combination of height and time locks
186
            (throw std::logic_error("Unknown character in _mst literal"), 0)
187
        );
188
    }
189
190
    return typ;
191
}
192
193
using Opcode = std::pair<opcodetype, std::vector<unsigned char>>;
194
195
template<typename Key> class Node;
196
197
//! Unordered traversal of a miniscript node tree.
198
template <typename Key, std::invocable<const Node<Key>&> Fn>
199
void ForEachNode(const Node<Key>& root, Fn&& fn)
200
0
{
201
0
    std::vector<std::reference_wrapper<const Node<Key>>> stack{root};
202
0
    while (!stack.empty()) {
  Branch (202:12): [True: 0, False: 0]
203
0
        const Node<Key>& node = stack.back();
204
0
        std::invoke(fn, node);
205
0
        stack.pop_back();
206
0
        for (const auto& sub : node.Subs()) {
  Branch (206:30): [True: 0, False: 0]
207
0
            stack.emplace_back(sub);
208
0
        }
209
0
    }
210
0
}
211
212
//! The different node types in miniscript.
213
enum class Fragment {
214
    JUST_0,    //!< OP_0
215
    JUST_1,    //!< OP_1
216
    PK_K,      //!< [key]
217
    PK_H,      //!< OP_DUP OP_HASH160 [keyhash] OP_EQUALVERIFY
218
    OLDER,     //!< [n] OP_CHECKSEQUENCEVERIFY
219
    AFTER,     //!< [n] OP_CHECKLOCKTIMEVERIFY
220
    SHA256,    //!< OP_SIZE 32 OP_EQUALVERIFY OP_SHA256 [hash] OP_EQUAL
221
    HASH256,   //!< OP_SIZE 32 OP_EQUALVERIFY OP_HASH256 [hash] OP_EQUAL
222
    RIPEMD160, //!< OP_SIZE 32 OP_EQUALVERIFY OP_RIPEMD160 [hash] OP_EQUAL
223
    HASH160,   //!< OP_SIZE 32 OP_EQUALVERIFY OP_HASH160 [hash] OP_EQUAL
224
    WRAP_A,    //!< OP_TOALTSTACK [X] OP_FROMALTSTACK
225
    WRAP_S,    //!< OP_SWAP [X]
226
    WRAP_C,    //!< [X] OP_CHECKSIG
227
    WRAP_D,    //!< OP_DUP OP_IF [X] OP_ENDIF
228
    WRAP_V,    //!< [X] OP_VERIFY (or -VERIFY version of last opcode in X)
229
    WRAP_J,    //!< OP_SIZE OP_0NOTEQUAL OP_IF [X] OP_ENDIF
230
    WRAP_N,    //!< [X] OP_0NOTEQUAL
231
    AND_V,     //!< [X] [Y]
232
    AND_B,     //!< [X] [Y] OP_BOOLAND
233
    OR_B,      //!< [X] [Y] OP_BOOLOR
234
    OR_C,      //!< [X] OP_NOTIF [Y] OP_ENDIF
235
    OR_D,      //!< [X] OP_IFDUP OP_NOTIF [Y] OP_ENDIF
236
    OR_I,      //!< OP_IF [X] OP_ELSE [Y] OP_ENDIF
237
    ANDOR,     //!< [X] OP_NOTIF [Z] OP_ELSE [Y] OP_ENDIF
238
    THRESH,    //!< [X1] ([Xn] OP_ADD)* [k] OP_EQUAL
239
    MULTI,     //!< [k] [key_n]* [n] OP_CHECKMULTISIG (only available within P2WSH context)
240
    MULTI_A,   //!< [key_0] OP_CHECKSIG ([key_n] OP_CHECKSIGADD)* [k] OP_NUMEQUAL (only within Tapscript ctx)
241
    // AND_N(X,Y) is represented as ANDOR(X,Y,0)
242
    // WRAP_T(X) is represented as AND_V(X,1)
243
    // WRAP_L(X) is represented as OR_I(0,X)
244
    // WRAP_U(X) is represented as OR_I(X,0)
245
};
246
247
enum class Availability {
248
    NO,
249
    YES,
250
    MAYBE,
251
};
252
253
enum class MiniscriptContext {
254
    P2WSH,
255
    TAPSCRIPT,
256
};
257
258
/** Whether the context Tapscript, ensuring the only other possibility is P2WSH. */
259
constexpr bool IsTapscript(MiniscriptContext ms_ctx)
260
0
{
261
0
    switch (ms_ctx) {
  Branch (261:13): [True: 0, False: 0]
262
0
        case MiniscriptContext::P2WSH: return false;
  Branch (262:9): [True: 0, False: 0]
263
0
        case MiniscriptContext::TAPSCRIPT: return true;
  Branch (263:9): [True: 0, False: 0]
264
0
    }
265
0
    assert(false);
  Branch (265:5): [Folded - Ignored]
266
0
}
267
268
namespace internal {
269
270
//! The maximum size of a witness item for a Miniscript under Tapscript context. (A BIP340 signature with a sighash type byte.)
271
static constexpr uint32_t MAX_TAPMINISCRIPT_STACK_ELEM_SIZE{65};
272
273
//! version + nLockTime
274
constexpr uint32_t TX_OVERHEAD{4 + 4};
275
//! prevout + nSequence + scriptSig
276
constexpr uint32_t TXIN_BYTES_NO_WITNESS{36 + 4 + 1};
277
//! nValue + script len + OP_0 + pushdata 32.
278
constexpr uint32_t P2WSH_TXOUT_BYTES{8 + 1 + 1 + 33};
279
//! Data other than the witness in a transaction. Overhead + vin count + one vin + vout count + one vout + segwit marker
280
constexpr uint32_t TX_BODY_LEEWAY_WEIGHT{(TX_OVERHEAD + GetSizeOfCompactSize(1) + TXIN_BYTES_NO_WITNESS + GetSizeOfCompactSize(1) + P2WSH_TXOUT_BYTES) * WITNESS_SCALE_FACTOR + 2};
281
//! Maximum possible stack size to spend a Taproot output (excluding the script itself).
282
constexpr uint32_t MAX_TAPSCRIPT_SAT_SIZE{GetSizeOfCompactSize(MAX_STACK_SIZE) + (GetSizeOfCompactSize(MAX_TAPMINISCRIPT_STACK_ELEM_SIZE) + MAX_TAPMINISCRIPT_STACK_ELEM_SIZE) * MAX_STACK_SIZE + GetSizeOfCompactSize(TAPROOT_CONTROL_MAX_SIZE) + TAPROOT_CONTROL_MAX_SIZE};
283
/** The maximum size of a script depending on the context. */
284
constexpr uint32_t MaxScriptSize(MiniscriptContext ms_ctx)
285
0
{
286
0
    if (IsTapscript(ms_ctx)) {
  Branch (286:9): [True: 0, False: 0]
287
        // Leaf scripts under Tapscript are not explicitly limited in size. They are only implicitly
288
        // bounded by the maximum standard size of a spending transaction. Let the maximum script
289
        // size conservatively be small enough such that even a maximum sized witness and a reasonably
290
        // sized spending transaction can spend an output paying to this script without running into
291
        // the maximum standard tx size limit.
292
0
        constexpr auto max_size{MAX_STANDARD_TX_WEIGHT - TX_BODY_LEEWAY_WEIGHT - MAX_TAPSCRIPT_SAT_SIZE};
293
0
        return max_size - GetSizeOfCompactSize(max_size);
294
0
    }
295
0
    return MAX_STANDARD_P2WSH_SCRIPT_SIZE;
296
0
}
297
298
//! Helper function for Node::CalcType.
299
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, MiniscriptContext ms_ctx);
300
301
//! Helper function for Node::CalcScriptLen.
302
size_t ComputeScriptLen(Fragment fragment, Type sub0typ, size_t subsize, uint32_t k, size_t n_subs, size_t n_keys, MiniscriptContext ms_ctx);
303
304
//! A helper sanitizer/checker for the output of CalcType.
305
Type SanitizeType(Type x);
306
307
//! An object representing a sequence of witness stack elements.
308
struct InputStack {
309
    /** Whether this stack is valid for its intended purpose (satisfaction or dissatisfaction of a Node).
310
     *  The MAYBE value is used for size estimation, when keys/preimages may actually be unavailable,
311
     *  but may be available at signing time. This makes the InputStack structure and signing logic,
312
     *  filled with dummy signatures/preimages usable for witness size estimation.
313
     */
314
    Availability available = Availability::YES;
315
    //! Whether this stack contains a digital signature.
316
    bool has_sig = false;
317
    //! Whether this stack is malleable (can be turned into an equally valid other stack by a third party).
318
    bool malleable = false;
319
    //! Whether this stack is non-canonical (using a construction known to be unnecessary for satisfaction).
320
    //! Note that this flag does not affect the satisfaction algorithm; it is only used for sanity checking.
321
    bool non_canon = false;
322
    //! Serialized witness size.
323
    size_t size = 0;
324
    //! Data elements.
325
    std::vector<std::vector<unsigned char>> stack;
326
    //! Construct an empty stack (valid).
327
81
    InputStack() = default;
328
    //! Construct a valid single-element stack (with an element up to 75 bytes).
329
243
    InputStack(std::vector<unsigned char> in) : size(in.size() + 1), stack(Vector(std::move(in))) {}
330
    //! Change availability
331
    InputStack& SetAvailable(Availability avail);
332
    //! Mark this input stack as having a signature.
333
    InputStack& SetWithSig();
334
    //! Mark this input stack as non-canonical (known to not be necessary in non-malleable satisfactions).
335
    InputStack& SetNonCanon();
336
    //! Mark this input stack as malleable.
337
    InputStack& SetMalleable(bool x = true);
338
    //! Concatenate two input stacks.
339
    friend InputStack operator+(InputStack a, InputStack b);
340
    //! Choose between two potential input stacks.
341
    friend InputStack operator|(InputStack a, InputStack b);
342
};
343
344
/** A stack consisting of a single zero-length element (interpreted as 0 by the script interpreter in numeric context). */
345
static const auto ZERO = InputStack(std::vector<unsigned char>());
346
/** A stack consisting of a single malleable 32-byte 0x0000...0000 element (for dissatisfying hash challenges). */
347
static const auto ZERO32 = InputStack(std::vector<unsigned char>(32, 0)).SetMalleable();
348
/** A stack consisting of a single 0x01 element (interpreted as 1 by the script interpreted in numeric context). */
349
static const auto ONE = InputStack(Vector((unsigned char)1));
350
/** The empty stack. */
351
static const auto EMPTY = InputStack();
352
/** A stack representing the lack of any (dis)satisfactions. */
353
static const auto INVALID = InputStack().SetAvailable(Availability::NO);
354
355
//! A pair of a satisfaction and a dissatisfaction InputStack.
356
struct InputResult {
357
    InputStack nsat, sat;
358
359
    template<typename A, typename B>
360
0
    InputResult(A&& in_nsat, B&& in_sat) : nsat(std::forward<A>(in_nsat)), sat(std::forward<B>(in_sat)) {}
Unexecuted instantiation: miniscript::internal::InputResult::InputResult<miniscript::internal::InputStack const&, miniscript::internal::InputStack&>(miniscript::internal::InputStack const&, miniscript::internal::InputStack&)
Unexecuted instantiation: miniscript::internal::InputResult::InputResult<miniscript::internal::InputStack, miniscript::internal::InputStack&>(miniscript::internal::InputStack&&, miniscript::internal::InputStack&)
Unexecuted instantiation: miniscript::internal::InputResult::InputResult<miniscript::internal::InputStack, miniscript::internal::InputStack>(miniscript::internal::InputStack&&, miniscript::internal::InputStack&&)
Unexecuted instantiation: miniscript::internal::InputResult::InputResult<miniscript::internal::InputStack const&, miniscript::internal::InputStack const&>(miniscript::internal::InputStack const&, miniscript::internal::InputStack const&)
Unexecuted instantiation: miniscript::internal::InputResult::InputResult<miniscript::internal::InputStack&, miniscript::internal::InputStack>(miniscript::internal::InputStack&, miniscript::internal::InputStack&&)
Unexecuted instantiation: miniscript::internal::InputResult::InputResult<miniscript::internal::InputStack const&, miniscript::internal::InputStack>(miniscript::internal::InputStack const&, miniscript::internal::InputStack&&)
361
};
362
363
//! Class whose objects represent the maximum of a list of integers.
364
template <typename I>
365
class MaxInt
366
{
367
    bool valid;
368
    I value;
369
370
public:
371
0
    MaxInt() : valid(false), value(0) {}
372
0
    MaxInt(I val) : valid(true), value(val) {}
373
374
0
    bool Valid() const { return valid; }
375
0
    I Value() const { return value; }
376
377
0
    friend MaxInt<I> operator+(const MaxInt<I>& a, const MaxInt<I>& b) {
378
0
        if (!a.valid || !b.valid) return {};
  Branch (378:13): [True: 0, False: 0]
  Branch (378:25): [True: 0, False: 0]
379
0
        return a.value + b.value;
380
0
    }
381
382
0
    friend MaxInt<I> operator|(const MaxInt<I>& a, const MaxInt<I>& b) {
383
0
        if (!a.valid) return b;
  Branch (383:13): [True: 0, False: 0]
384
0
        if (!b.valid) return a;
  Branch (384:13): [True: 0, False: 0]
385
0
        return std::max(a.value, b.value);
386
0
    }
387
};
388
389
struct Ops {
390
    //! Non-push opcodes.
391
    uint32_t count;
392
    //! Number of keys in possibly executed OP_CHECKMULTISIG(VERIFY)s to satisfy.
393
    MaxInt<uint32_t> sat;
394
    //! Number of keys in possibly executed OP_CHECKMULTISIG(VERIFY)s to dissatisfy.
395
    MaxInt<uint32_t> dsat;
396
397
0
    Ops(uint32_t in_count, MaxInt<uint32_t> in_sat, MaxInt<uint32_t> in_dsat) : count(in_count), sat(in_sat), dsat(in_dsat) {};
398
};
399
400
/** A data structure to help the calculation of stack size limits.
401
 *
402
 * Conceptually, every SatInfo object corresponds to a (possibly empty) set of script execution
403
 * traces (sequences of opcodes).
404
 * - SatInfo{} corresponds to the empty set.
405
 * - SatInfo{n, e} corresponds to a single trace whose net effect is removing n elements from the
406
 *   stack (may be negative for a net increase), and reaches a maximum of e stack elements more
407
 *   than it ends with.
408
 * - operator| is the union operation: (a | b) corresponds to the union of the traces in a and the
409
 *   traces in b.
410
 * - operator+ is the concatenation operator: (a + b) corresponds to the set of traces formed by
411
 *   concatenating any trace in a with any trace in b.
412
 *
413
 * Its fields are:
414
 * - valid is true if the set is non-empty.
415
 * - netdiff (if valid) is the largest difference between stack size at the beginning and at the
416
 *   end of the script across all traces in the set.
417
 * - exec (if valid) is the largest difference between stack size anywhere during execution and at
418
 *   the end of the script, across all traces in the set (note that this is not necessarily due
419
 *   to the same trace as the one that resulted in the value for netdiff).
420
 *
421
 * This allows us to build up stack size limits for any script efficiently, by starting from the
422
 * individual opcodes miniscripts correspond to, using concatenation to construct scripts, and
423
 * using the union operation to choose between execution branches. Since any top-level script
424
 * satisfaction ends with a single stack element, we know that for a full script:
425
 * - netdiff+1 is the maximal initial stack size (relevant for P2WSH stack limits).
426
 * - exec+1 is the maximal stack size reached during execution (relevant for P2TR stack limits).
427
 *
428
 * Mathematically, SatInfo forms a semiring:
429
 * - operator| is the semiring addition operator, with identity SatInfo{}, and which is commutative
430
 *   and associative.
431
 * - operator+ is the semiring multiplication operator, with identity SatInfo{0}, and which is
432
 *   associative.
433
 * - operator+ is distributive over operator|, so (a + (b | c)) = (a+b | a+c). This means we do not
434
 *   need to actually materialize all possible full execution traces over the whole script (which
435
 *   may be exponential in the length of the script); instead we can use the union operation at the
436
 *   individual subexpression level, and concatenate the result with subexpressions before and
437
 *   after it.
438
 * - It is not a commutative semiring, because a+b can differ from b+a. For example, "OP_1 OP_DROP"
439
 *   has exec=1, while "OP_DROP OP_1" has exec=0.
440
 */
441
class SatInfo
442
{
443
    //! Whether a canonical satisfaction/dissatisfaction is possible at all.
444
    bool valid;
445
    //! How much higher the stack size at start of execution can be compared to at the end.
446
    int32_t netdiff;
447
    //! How much higher the stack size can be during execution compared to at the end.
448
    int32_t exec;
449
450
public:
451
    /** Empty script set. */
452
0
    constexpr SatInfo() noexcept : valid(false), netdiff(0), exec(0) {}
453
454
    /** Script set with a single script in it, with specified netdiff and exec. */
455
    constexpr SatInfo(int32_t in_netdiff, int32_t in_exec) noexcept :
456
0
        valid{true}, netdiff{in_netdiff}, exec{in_exec} {}
457
458
0
    bool Valid() const { return valid; }
459
0
    int32_t NetDiff() const { return netdiff; }
460
0
    int32_t Exec() const { return exec; }
461
462
    /** Script set union. */
463
    constexpr friend SatInfo operator|(const SatInfo& a, const SatInfo& b) noexcept
464
0
    {
465
        // Union with an empty set is itself.
466
0
        if (!a.valid) return b;
  Branch (466:13): [True: 0, False: 0]
467
0
        if (!b.valid) return a;
  Branch (467:13): [True: 0, False: 0]
468
        // Otherwise the netdiff and exec of the union is the maximum of the individual values.
469
0
        return {std::max(a.netdiff, b.netdiff), std::max(a.exec, b.exec)};
470
0
    }
471
472
    /** Script set concatenation. */
473
    constexpr friend SatInfo operator+(const SatInfo& a, const SatInfo& b) noexcept
474
0
    {
475
        // Concatenation with an empty set yields an empty set.
476
0
        if (!a.valid || !b.valid) return {};
  Branch (476:13): [True: 0, False: 0]
  Branch (476:25): [True: 0, False: 0]
477
        // Otherwise, the maximum stack size difference for the combined scripts is the sum of the
478
        // netdiffs, and the maximum stack size difference anywhere is either b.exec (if the
479
        // maximum occurred in b) or b.netdiff+a.exec (if the maximum occurred in a).
480
0
        return {a.netdiff + b.netdiff, std::max(b.exec, b.netdiff + a.exec)};
481
0
    }
482
483
    /** The empty script. */
484
0
    static constexpr SatInfo Empty() noexcept { return {0, 0}; }
485
    /** A script consisting of a single push opcode. */
486
0
    static constexpr SatInfo Push() noexcept { return {-1, 0}; }
487
    /** A script consisting of a single hash opcode. */
488
0
    static constexpr SatInfo Hash() noexcept { return {0, 0}; }
489
    /** A script consisting of just a repurposed nop (OP_CHECKLOCKTIMEVERIFY, OP_CHECKSEQUENCEVERIFY). */
490
0
    static constexpr SatInfo Nop() noexcept { return {0, 0}; }
491
    /** A script consisting of just OP_IF or OP_NOTIF. Note that OP_ELSE and OP_ENDIF have no stack effect. */
492
0
    static constexpr SatInfo If() noexcept { return {1, 1}; }
493
    /** A script consisting of just a binary operator (OP_BOOLAND, OP_BOOLOR, OP_ADD). */
494
0
    static constexpr SatInfo BinaryOp() noexcept { return {1, 1}; }
495
496
    // Scripts for specific individual opcodes.
497
0
    static constexpr SatInfo OP_DUP() noexcept { return {-1, 0}; }
498
0
    static constexpr SatInfo OP_IFDUP(bool nonzero) noexcept { return {nonzero ? -1 : 0, 0}; }
  Branch (498:72): [True: 0, False: 0]
499
0
    static constexpr SatInfo OP_EQUALVERIFY() noexcept { return {2, 2}; }
500
0
    static constexpr SatInfo OP_EQUAL() noexcept { return {1, 1}; }
501
0
    static constexpr SatInfo OP_SIZE() noexcept { return {-1, 0}; }
502
0
    static constexpr SatInfo OP_CHECKSIG() noexcept { return {1, 1}; }
503
0
    static constexpr SatInfo OP_0NOTEQUAL() noexcept { return {0, 0}; }
504
0
    static constexpr SatInfo OP_VERIFY() noexcept { return {1, 1}; }
505
};
506
507
class StackSize
508
{
509
    SatInfo sat, dsat;
510
511
public:
512
0
    constexpr StackSize(SatInfo in_sat, SatInfo in_dsat) noexcept : sat(in_sat), dsat(in_dsat) {};
513
0
    constexpr StackSize(SatInfo in_both) noexcept : sat(in_both), dsat(in_both) {};
514
515
0
    const SatInfo& Sat() const { return sat; }
516
0
    const SatInfo& Dsat() const { return dsat; }
517
};
518
519
struct WitnessSize {
520
    //! Maximum witness size to satisfy;
521
    MaxInt<uint32_t> sat;
522
    //! Maximum witness size to dissatisfy;
523
    MaxInt<uint32_t> dsat;
524
525
0
    WitnessSize(MaxInt<uint32_t> in_sat, MaxInt<uint32_t> in_dsat) : sat(in_sat), dsat(in_dsat) {};
526
};
527
528
struct NoDupCheck {};
529
530
} // namespace internal
531
532
//! A node in a miniscript expression.
533
template <typename Key>
534
class Node
535
{
536
    //! What node type this node is.
537
    enum Fragment fragment;
538
    //! The k parameter (time for OLDER/AFTER, threshold for THRESH(_M))
539
    uint32_t k = 0;
540
    //! The keys used by this expression (only for PK_K/PK_H/MULTI)
541
    std::vector<Key> keys;
542
    //! The data bytes in this expression (only for HASH160/HASH256/SHA256/RIPEMD160).
543
    std::vector<unsigned char> data;
544
    //! Subexpressions (for WRAP_*/AND_*/OR_*/ANDOR/THRESH)
545
    std::vector<Node> subs;
546
    //! The Script context for this node. Either P2WSH or Tapscript.
547
    MiniscriptContext m_script_ctx;
548
549
public:
550
    // Permit 1 level deep recursion since we own instances of our own type.
551
    // NOLINTBEGIN(misc-no-recursion)
552
    ~Node()
553
0
    {
554
        // Destroy the subexpressions iteratively after moving out their
555
        // subexpressions to avoid a stack-overflow due to recursive calls to
556
        // the subs' destructors.
557
        // We move vectors in order to only update array-pointers inside them
558
        // rather than moving individual Node instances which would involve
559
        // moving/copying each Node field.
560
0
        std::vector<std::vector<Node>> queue;
561
0
        queue.push_back(std::move(subs));
562
0
        do {
563
0
            auto flattening{std::move(queue.back())};
564
0
            queue.pop_back();
565
0
            for (Node& n : flattening) {
  Branch (565:26): [True: 0, False: 0]
  Branch (565:26): [True: 0, False: 0]
  Branch (565:26): [True: 0, False: 0]
566
0
                if (!n.subs.empty()) queue.push_back(std::move(n.subs));
  Branch (566:21): [True: 0, False: 0]
  Branch (566:21): [True: 0, False: 0]
  Branch (566:21): [True: 0, False: 0]
567
0
            }
568
0
        } while (!queue.empty());
  Branch (568:18): [True: 0, False: 0]
  Branch (568:18): [True: 0, False: 0]
  Branch (568:18): [True: 0, False: 0]
569
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::~Node()
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::~Node()
Unexecuted instantiation: miniscript::Node<CPubKey>::~Node()
570
    // NOLINTEND(misc-no-recursion)
571
572
    Node<Key> Clone() const
573
0
    {
574
        // Use TreeEval() to avoid a stack-overflow due to recursion
575
0
        auto upfn = [](const Node& node, std::span<Node> children) {
576
0
            std::vector<Node> new_subs;
577
0
            for (auto& child : children) {
  Branch (577:30): [True: 0, False: 0]
578
                // It's fine to move from children as they are new nodes having
579
                // been produced by calling this function one level down.
580
0
                new_subs.push_back(std::move(child));
581
0
            }
582
0
            return Node{internal::NoDupCheck{}, node.m_script_ctx, node.fragment, std::move(new_subs), node.keys, node.data, node.k};
583
0
        };
584
0
        return TreeEval<Node>(upfn);
585
0
    }
586
587
0
    enum Fragment Fragment() const { return fragment; }
588
0
    uint32_t K() const { return k; }
589
    const std::vector<Key>& Keys() const { return keys; }
590
    const std::vector<unsigned char>& Data() const { return data; }
591
0
    const std::vector<Node>& Subs() const { return subs; }
592
593
private:
594
    //! Cached ops counts.
595
    internal::Ops ops;
596
    //! Cached stack size bounds.
597
    internal::StackSize ss;
598
    //! Cached witness size bounds.
599
    internal::WitnessSize ws;
600
    //! Cached expression type (computed by CalcType and fed through SanitizeType).
601
    Type typ;
602
    //! Cached script length (computed by CalcScriptLen).
603
    size_t scriptlen;
604
    //! Whether a public key appears more than once in this node. This value is initialized
605
    //! by all constructors except the NoDupCheck ones. The NoDupCheck ones skip the
606
    //! computation, requiring it to be done manually by invoking DuplicateKeyCheck().
607
    //! DuplicateKeyCheck(), or a non-NoDupCheck constructor, will compute has_duplicate_keys
608
    //! for all subnodes as well.
609
    mutable std::optional<bool> has_duplicate_keys;
610
611
    // Constructor which takes all of the data that a Node could possibly contain.
612
    // This is kept private as no valid fragment has all of these arguments.
613
    // Only used by Clone()
614
    Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, std::vector<Node> sub, std::vector<Key> key, std::vector<unsigned char> arg, uint32_t val)
615
0
        : fragment(nt), k(val), keys(std::move(key)), data(std::move(arg)), subs(std::move(sub)), m_script_ctx{script_ctx}, ops(CalcOps()), ss(CalcStackSize()), ws(CalcWitnessSize()), typ(CalcType()), scriptlen(CalcScriptLen()) {}
616
617
    //! Compute the length of the script for this miniscript (including children).
618
    size_t CalcScriptLen() const
619
0
    {
620
0
        size_t subsize = 0;
621
0
        for (const auto& sub : subs) {
  Branch (621:30): [True: 0, False: 0]
  Branch (621:30): [True: 0, False: 0]
  Branch (621:30): [True: 0, False: 0]
622
0
            subsize += sub.ScriptSize();
623
0
        }
624
0
        Type sub0type = subs.size() > 0 ? subs[0].GetType() : ""_mst;
  Branch (624:25): [True: 0, False: 0]
  Branch (624:25): [True: 0, False: 0]
  Branch (624:25): [True: 0, False: 0]
625
0
        return internal::ComputeScriptLen(fragment, sub0type, subsize, k, subs.size(), keys.size(), m_script_ctx);
626
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::CalcScriptLen() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::CalcScriptLen() const
Unexecuted instantiation: miniscript::Node<CPubKey>::CalcScriptLen() const
627
628
    /* Apply a recursive algorithm to a Miniscript tree, without actual recursive calls.
629
     *
630
     * The algorithm is defined by two functions: downfn and upfn. Conceptually, the
631
     * result can be thought of as first using downfn to compute a "state" for each node,
632
     * from the root down to the leaves. Then upfn is used to compute a "result" for each
633
     * node, from the leaves back up to the root, which is then returned. In the actual
634
     * implementation, both functions are invoked in an interleaved fashion, performing a
635
     * depth-first traversal of the tree.
636
     *
637
     * In more detail, it is invoked as node.TreeEvalMaybe<Result>(root, downfn, upfn):
638
     * - root is the state of the root node, of type State.
639
     * - downfn is a callable (State&, const Node&, size_t) -> State, which given a
640
     *   node, its state, and an index of one of its children, computes the state of that
641
     *   child. It can modify the state. Children of a given node will have downfn()
642
     *   called in order.
643
     * - upfn is a callable (State&&, const Node&, std::span<Result>) -> std::optional<Result>,
644
     *   which given a node, its state, and a span of the results of its children,
645
     *   computes the result of the node. If std::nullopt is returned by upfn,
646
     *   TreeEvalMaybe() immediately returns std::nullopt.
647
     * The return value of TreeEvalMaybe is the result of the root node.
648
     *
649
     * Result type cannot be bool due to the std::vector<bool> specialization.
650
     */
651
    template<typename Result, typename State, typename DownFn, typename UpFn>
652
    std::optional<Result> TreeEvalMaybe(State root_state, DownFn downfn, UpFn upfn) const
653
0
    {
654
        /** Entries of the explicit stack tracked in this algorithm. */
655
0
        struct StackElem
656
0
        {
657
0
            const Node& node; //!< The node being evaluated.
658
0
            size_t expanded; //!< How many children of this node have been expanded.
659
0
            State state; //!< The state for that node.
660
661
0
            StackElem(const Node& node_, size_t exp_, State&& state_) :
662
0
                node(node_), expanded(exp_), state(std::move(state_)) {}
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::TreeEvalMaybe<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::StackElem::StackElem(miniscript::Node<unsigned int> const&, unsigned long, miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::DummyState&&)
Unexecuted instantiation: miniscript::Node<unsigned int>::TreeEvalMaybe<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::StackElem::StackElem(miniscript::Node<unsigned int> const&, unsigned long, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::DummyState&&)
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::TreeEvalMaybe<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 18446744073709551615ul>)#1}>(bool, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 18446744073709551615ul>)#1}) const::StackElem::StackElem(miniscript::Node<unsigned int> const&, unsigned long, bool&&)
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::TreeEvalMaybe<CScript, bool, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<CScript, bool, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}&, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<CScript, 18446744073709551615ul>)#1}>(bool, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}&, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<CScript, 18446744073709551615ul>)#1}) const::{lambda(bool&&, miniscript::Node<unsigned int> const&, std::span<CScript, 18446744073709551615ul>)#1}>(bool, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<CScript, bool, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}&, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<CScript, 18446744073709551615ul>)#1}>(bool, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}&, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<CScript, 18446744073709551615ul>)#1}) const::{lambda(bool&&, miniscript::Node<unsigned int> const&, std::span<CScript, 18446744073709551615ul>)#1}) const::StackElem::StackElem(miniscript::Node<unsigned int> const&, unsigned long, bool&&)
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::TreeEvalMaybe<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::StringMaker>((anonymous namespace)::StringMaker const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::StringMaker>((anonymous namespace)::StringMaker const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 18446744073709551615ul>)#1}>(bool, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::StringMaker>((anonymous namespace)::StringMaker const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::StringMaker>((anonymous namespace)::StringMaker const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 18446744073709551615ul>)#1}) const::StackElem::StackElem(miniscript::Node<unsigned int> const&, unsigned long, bool&&)
Unexecuted instantiation: miniscript::Node<unsigned int>::TreeEvalMaybe<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::StackElem::StackElem(miniscript::Node<unsigned int> const&, unsigned long, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::DummyState&&)
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::TreeEvalMaybe<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, unsigned long)#1}, miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, unsigned long)#1}, miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::StackElem::StackElem(miniscript::Node<XOnlyPubKey> const&, unsigned long, miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState&&)
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::TreeEvalMaybe<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState, miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, unsigned long)#1}, miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState, miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, unsigned long)#1}, miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#1}) const::StackElem::StackElem(miniscript::Node<XOnlyPubKey> const&, unsigned long, miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState&&)
Unexecuted instantiation: miniscript::Node<CPubKey>::TreeEvalMaybe<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, unsigned long)#1}, miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, unsigned long)#1}, miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::StackElem::StackElem(miniscript::Node<CPubKey> const&, unsigned long, miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState&&)
Unexecuted instantiation: miniscript::Node<CPubKey>::TreeEvalMaybe<miniscript::internal::InputResult, miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState, miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, unsigned long)#1}, miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState, miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, unsigned long)#1}, miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#1}) const::StackElem::StackElem(miniscript::Node<CPubKey> const&, unsigned long, miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState&&)
663
0
        };
664
        /* Stack of tree nodes being explored. */
665
0
        std::vector<StackElem> stack;
666
        /* Results of subtrees so far. Their order and mapping to tree nodes
667
         * is implicitly defined by stack. */
668
0
        std::vector<Result> results;
669
0
        stack.emplace_back(*this, 0, std::move(root_state));
670
671
        /* Here is a demonstration of the algorithm, for an example tree A(B,C(D,E),F).
672
         * State variables are omitted for simplicity.
673
         *
674
         * First: stack=[(A,0)] results=[]
675
         *        stack=[(A,1),(B,0)] results=[]
676
         *        stack=[(A,1)] results=[B]
677
         *        stack=[(A,2),(C,0)] results=[B]
678
         *        stack=[(A,2),(C,1),(D,0)] results=[B]
679
         *        stack=[(A,2),(C,1)] results=[B,D]
680
         *        stack=[(A,2),(C,2),(E,0)] results=[B,D]
681
         *        stack=[(A,2),(C,2)] results=[B,D,E]
682
         *        stack=[(A,2)] results=[B,C]
683
         *        stack=[(A,3),(F,0)] results=[B,C]
684
         *        stack=[(A,3)] results=[B,C,F]
685
         * Final: stack=[] results=[A]
686
         */
687
0
        while (stack.size()) {
  Branch (687:16): [True: 0, False: 0]
  Branch (687:16): [True: 0, False: 0]
  Branch (687:16): [True: 0, False: 0]
  Branch (687:16): [True: 0, False: 0]
  Branch (687:16): [True: 0, False: 0]
  Branch (687:16): [True: 0, False: 0]
  Branch (687:16): [True: 0, False: 0]
  Branch (687:16): [True: 0, False: 0]
  Branch (687:16): [True: 0, False: 0]
  Branch (687:16): [True: 0, False: 0]
688
0
            const Node& node = stack.back().node;
689
0
            if (stack.back().expanded < node.subs.size()) {
  Branch (689:17): [True: 0, False: 0]
  Branch (689:17): [True: 0, False: 0]
  Branch (689:17): [True: 0, False: 0]
  Branch (689:17): [True: 0, False: 0]
  Branch (689:17): [True: 0, False: 0]
  Branch (689:17): [True: 0, False: 0]
  Branch (689:17): [True: 0, False: 0]
  Branch (689:17): [True: 0, False: 0]
  Branch (689:17): [True: 0, False: 0]
  Branch (689:17): [True: 0, False: 0]
690
                /* We encounter a tree node with at least one unexpanded child.
691
                 * Expand it. By the time we hit this node again, the result of
692
                 * that child (and all earlier children) will be at the end of `results`. */
693
0
                size_t child_index = stack.back().expanded++;
694
0
                State child_state = downfn(stack.back().state, node, child_index);
695
0
                stack.emplace_back(node.subs[child_index], 0, std::move(child_state));
696
0
                continue;
697
0
            }
698
            // Invoke upfn with the last node.subs.size() elements of results as input.
699
0
            assert(results.size() >= node.subs.size());
  Branch (699:13): [True: 0, False: 0]
  Branch (699:13): [True: 0, False: 0]
  Branch (699:13): [True: 0, False: 0]
  Branch (699:13): [True: 0, False: 0]
  Branch (699:13): [True: 0, False: 0]
  Branch (699:13): [True: 0, False: 0]
  Branch (699:13): [True: 0, False: 0]
  Branch (699:13): [True: 0, False: 0]
  Branch (699:13): [True: 0, False: 0]
  Branch (699:13): [True: 0, False: 0]
700
0
            std::optional<Result> result{upfn(std::move(stack.back().state), node,
701
0
                std::span<Result>{results}.last(node.subs.size()))};
702
            // If evaluation returns std::nullopt, abort immediately.
703
0
            if (!result) return {};
  Branch (703:17): [True: 0, False: 0]
  Branch (703:17): [True: 0, False: 0]
  Branch (703:17): [True: 0, False: 0]
  Branch (703:17): [True: 0, False: 0]
  Branch (703:17): [True: 0, False: 0]
  Branch (703:17): [True: 0, False: 0]
  Branch (703:17): [True: 0, False: 0]
  Branch (703:17): [True: 0, False: 0]
  Branch (703:17): [True: 0, False: 0]
  Branch (703:17): [True: 0, False: 0]
704
            // Replace the last node.subs.size() elements of results with the new result.
705
0
            results.erase(results.end() - node.subs.size(), results.end());
706
0
            results.push_back(std::move(*result));
707
0
            stack.pop_back();
708
0
        }
709
        // The final remaining results element is the root result, return it.
710
0
        assert(results.size() >= 1);
  Branch (710:9): [True: 0, False: 0]
  Branch (710:9): [True: 0, False: 0]
  Branch (710:9): [True: 0, False: 0]
  Branch (710:9): [True: 0, False: 0]
  Branch (710:9): [True: 0, False: 0]
  Branch (710:9): [True: 0, False: 0]
  Branch (710:9): [True: 0, False: 0]
  Branch (710:9): [True: 0, False: 0]
  Branch (710:9): [True: 0, False: 0]
  Branch (710:9): [True: 0, False: 0]
711
0
        CHECK_NONFATAL(results.size() == 1);
712
0
        return std::move(results[0]);
713
0
    }
Unexecuted instantiation: descriptor.cpp:std::optional<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > > > miniscript::Node<unsigned int>::TreeEvalMaybe<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: std::optional<miniscript::Node<unsigned int> const*> miniscript::Node<unsigned int>::TreeEvalMaybe<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: descriptor.cpp:std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > miniscript::Node<unsigned int>::TreeEvalMaybe<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 18446744073709551615ul>)#1}>(bool, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: descriptor.cpp:std::optional<CScript> miniscript::Node<unsigned int>::TreeEvalMaybe<CScript, bool, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<CScript, bool, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}&, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<CScript, 18446744073709551615ul>)#1}>(bool, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}&, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<CScript, 18446744073709551615ul>)#1}) const::{lambda(bool&&, miniscript::Node<unsigned int> const&, std::span<CScript, 18446744073709551615ul>)#1}>(bool, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<CScript, bool, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}&, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<CScript, 18446744073709551615ul>)#1}>(bool, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}&, miniscript::Node<unsigned int>::ToScript<(anonymous namespace)::ScriptMaker>((anonymous namespace)::ScriptMaker const&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<CScript, 18446744073709551615ul>)#1}) const::{lambda(bool&&, miniscript::Node<unsigned int> const&, std::span<CScript, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: descriptor.cpp:std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > miniscript::Node<unsigned int>::TreeEvalMaybe<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::StringMaker>((anonymous namespace)::StringMaker const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::StringMaker>((anonymous namespace)::StringMaker const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 18446744073709551615ul>)#1}>(bool, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::StringMaker>((anonymous namespace)::StringMaker const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::ToString<(anonymous namespace)::StringMaker>((anonymous namespace)::StringMaker const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: std::optional<miniscript::Node<unsigned int> > miniscript::Node<unsigned int>::TreeEvalMaybe<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}, miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: std::optional<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > > > miniscript::Node<XOnlyPubKey>::TreeEvalMaybe<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, unsigned long)#1}, miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, unsigned long)#1}, miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: std::optional<miniscript::internal::InputResult> miniscript::Node<XOnlyPubKey>::TreeEvalMaybe<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState, miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, unsigned long)#1}, miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState, miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, unsigned long)#1}, miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: std::optional<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > > > miniscript::Node<CPubKey>::TreeEvalMaybe<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, unsigned long)#1}, miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, unsigned long)#1}, miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: std::optional<miniscript::internal::InputResult> miniscript::Node<CPubKey>::TreeEvalMaybe<miniscript::internal::InputResult, miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState, miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, unsigned long)#1}, miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState, miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, unsigned long)#1}, miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#1}) const
714
715
    /** Like TreeEvalMaybe, but without downfn or State type.
716
     * upfn takes (const Node&, std::span<Result>) and returns std::optional<Result>. */
717
    template<typename Result, typename UpFn>
718
    std::optional<Result> TreeEvalMaybe(UpFn upfn) const
719
    {
720
        struct DummyState {};
721
        return TreeEvalMaybe<Result>(DummyState{},
722
            [](DummyState, const Node&, size_t) { return DummyState{}; },
723
            [&upfn](DummyState, const Node& node, std::span<Result> subs) {
724
                return upfn(node, subs);
725
            }
726
        );
727
    }
728
729
    /** Like TreeEvalMaybe, but always produces a result. upfn must return Result. */
730
    template<typename Result, typename State, typename DownFn, typename UpFn>
731
    Result TreeEval(State root_state, DownFn&& downfn, UpFn upfn) const
732
0
    {
733
        // Invoke TreeEvalMaybe with upfn wrapped to return std::optional<Result>, and then
734
        // unconditionally dereference the result (it cannot be std::nullopt).
735
0
        return std::move(*TreeEvalMaybe<Result>(std::move(root_state),
736
0
            std::forward<DownFn>(downfn),
737
0
            [&upfn](State&& state, const Node& node, std::span<Result> subs) {
738
0
                Result res{upfn(std::move(state), node, subs)};
739
0
                return std::optional<Result>(std::move(res));
740
0
            }
741
0
        ));
742
0
    }
743
744
    /** Like TreeEval, but without downfn or State type.
745
     *  upfn takes (const Node&, std::span<Result>) and returns Result. */
746
    template<typename Result, typename UpFn>
747
    Result TreeEval(UpFn upfn) const
748
0
    {
749
0
        struct DummyState {};
750
0
        return std::move(*TreeEvalMaybe<Result>(DummyState{},
751
0
            [](DummyState, const Node&, size_t) { return DummyState{}; },
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}::operator()(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long) const
Unexecuted instantiation: miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}::operator()(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long) const
Unexecuted instantiation: miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long)#1}::operator()(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int> const&, unsigned long) const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, unsigned long)#1}::operator()(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<XOnlyPubKey> const&, unsigned long) const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, unsigned long)#1}::operator()(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState, miniscript::Node<XOnlyPubKey> const&, unsigned long) const
Unexecuted instantiation: miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, unsigned long)#1}::operator()(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<CPubKey> const&, unsigned long) const
Unexecuted instantiation: miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, unsigned long)#1}::operator()(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState, miniscript::Node<CPubKey> const&, unsigned long) const
752
0
            [&upfn](DummyState, const Node& node, std::span<Result> subs) {
753
0
                Result res{upfn(node, subs)};
754
0
                return std::optional<Result>(std::move(res));
755
0
            }
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}::operator()(miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>) const
Unexecuted instantiation: miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}::operator()(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>) const
Unexecuted instantiation: miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}::operator()(miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>) const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}::operator()(miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>) const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#1}::operator()(miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState, miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>) const
Unexecuted instantiation: miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}::operator()(miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const::DummyState, miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>) const
Unexecuted instantiation: miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::{lambda(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(auto:1 const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(auto:2) const::DummyState, miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#1}::operator()(miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const::DummyState, miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>) const
756
0
        ));
757
0
    }
Unexecuted instantiation: descriptor.cpp:std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > > miniscript::Node<unsigned int>::TreeEval<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: miniscript::Node<unsigned int> const* miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int> const*, miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::FindInsaneSub() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int> const*, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: miniscript::Node<unsigned int> miniscript::Node<unsigned int>::TreeEval<miniscript::Node<unsigned int>, miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}>(miniscript::Node<unsigned int>::Clone() const::{lambda(miniscript::Node<unsigned int> const&, std::span<miniscript::Node<unsigned int>, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > > miniscript::Node<XOnlyPubKey>::TreeEval<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: miniscript::internal::InputResult miniscript::Node<XOnlyPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const
Unexecuted instantiation: std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > > miniscript::Node<CPubKey>::TreeEval<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}>(miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}) const
Unexecuted instantiation: miniscript::internal::InputResult miniscript::Node<CPubKey>::TreeEval<miniscript::internal::InputResult, miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}>(miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}) const
758
759
    /** Compare two miniscript subtrees, using a non-recursive algorithm. */
760
    friend int Compare(const Node<Key>& node1, const Node<Key>& node2)
761
    {
762
        std::vector<std::pair<const Node<Key>&, const Node<Key>&>> queue;
763
        queue.emplace_back(node1, node2);
764
        while (!queue.empty()) {
765
            const auto& [a, b] = queue.back();
766
            queue.pop_back();
767
            if (std::tie(a.fragment, a.k, a.keys, a.data) < std::tie(b.fragment, b.k, b.keys, b.data)) return -1;
768
            if (std::tie(b.fragment, b.k, b.keys, b.data) < std::tie(a.fragment, a.k, a.keys, a.data)) return 1;
769
            if (a.subs.size() < b.subs.size()) return -1;
770
            if (b.subs.size() < a.subs.size()) return 1;
771
            size_t n = a.subs.size();
772
            for (size_t i = 0; i < n; ++i) {
773
                queue.emplace_back(a.subs[n - 1 - i], b.subs[n - 1 - i]);
774
            }
775
        }
776
        return 0;
777
    }
778
779
    //! Compute the type for this miniscript.
780
0
    Type CalcType() const {
781
0
        using namespace internal;
782
783
        // THRESH has a variable number of subexpressions
784
0
        std::vector<Type> sub_types;
785
0
        if (fragment == Fragment::THRESH) {
  Branch (785:13): [True: 0, False: 0]
  Branch (785:13): [True: 0, False: 0]
  Branch (785:13): [True: 0, False: 0]
786
0
            for (const auto& sub : subs) sub_types.push_back(sub.GetType());
  Branch (786:34): [True: 0, False: 0]
  Branch (786:34): [True: 0, False: 0]
  Branch (786:34): [True: 0, False: 0]
787
0
        }
788
        // All other nodes than THRESH can be computed just from the types of the 0-3 subexpressions.
789
0
        Type x = subs.size() > 0 ? subs[0].GetType() : ""_mst;
  Branch (789:18): [True: 0, False: 0]
  Branch (789:18): [True: 0, False: 0]
  Branch (789:18): [True: 0, False: 0]
790
0
        Type y = subs.size() > 1 ? subs[1].GetType() : ""_mst;
  Branch (790:18): [True: 0, False: 0]
  Branch (790:18): [True: 0, False: 0]
  Branch (790:18): [True: 0, False: 0]
791
0
        Type z = subs.size() > 2 ? subs[2].GetType() : ""_mst;
  Branch (791:18): [True: 0, False: 0]
  Branch (791:18): [True: 0, False: 0]
  Branch (791:18): [True: 0, False: 0]
792
793
0
        return SanitizeType(ComputeType(fragment, x, y, z, sub_types, k, data.size(), subs.size(), keys.size(), m_script_ctx));
794
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::CalcType() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::CalcType() const
Unexecuted instantiation: miniscript::Node<CPubKey>::CalcType() const
795
796
public:
797
    template<typename Ctx>
798
    CScript ToScript(const Ctx& ctx) const
799
0
    {
800
        // To construct the CScript for a Miniscript object, we use the TreeEval algorithm.
801
        // The State is a boolean: whether or not the node's script expansion is followed
802
        // by an OP_VERIFY (which may need to be combined with the last script opcode).
803
0
        auto downfn = [](bool verify, const Node& node, size_t index) {
804
            // For WRAP_V, the subexpression is certainly followed by OP_VERIFY.
805
0
            if (node.fragment == Fragment::WRAP_V) return true;
  Branch (805:17): [True: 0, False: 0]
806
            // The subexpression of WRAP_S, and the last subexpression of AND_V
807
            // inherit the followed-by-OP_VERIFY property from the parent.
808
0
            if (node.fragment == Fragment::WRAP_S ||
  Branch (808:17): [True: 0, False: 0]
809
0
                (node.fragment == Fragment::AND_V && index == 1)) return verify;
  Branch (809:18): [True: 0, False: 0]
  Branch (809:54): [True: 0, False: 0]
810
0
            return false;
811
0
        };
812
        // The upward function computes for a node, given its followed-by-OP_VERIFY status
813
        // and the CScripts of its child nodes, the CScript of the node.
814
0
        const bool is_tapscript{IsTapscript(m_script_ctx)};
815
0
        auto upfn = [&ctx, is_tapscript](bool verify, const Node& node, std::span<CScript> subs) -> CScript {
816
0
            switch (node.fragment) {
  Branch (816:21): [True: 0, False: 0]
817
0
                case Fragment::PK_K: return BuildScript(ctx.ToPKBytes(node.keys[0]));
  Branch (817:17): [True: 0, False: 0]
818
0
                case Fragment::PK_H: return BuildScript(OP_DUP, OP_HASH160, ctx.ToPKHBytes(node.keys[0]), OP_EQUALVERIFY);
  Branch (818:17): [True: 0, False: 0]
819
0
                case Fragment::OLDER: return BuildScript(node.k, OP_CHECKSEQUENCEVERIFY);
  Branch (819:17): [True: 0, False: 0]
820
0
                case Fragment::AFTER: return BuildScript(node.k, OP_CHECKLOCKTIMEVERIFY);
  Branch (820:17): [True: 0, False: 0]
821
0
                case Fragment::SHA256: return BuildScript(OP_SIZE, 32, OP_EQUALVERIFY, OP_SHA256, node.data, verify ? OP_EQUALVERIFY : OP_EQUAL);
  Branch (821:17): [True: 0, False: 0]
  Branch (821:110): [True: 0, False: 0]
822
0
                case Fragment::RIPEMD160: return BuildScript(OP_SIZE, 32, OP_EQUALVERIFY, OP_RIPEMD160, node.data, verify ? OP_EQUALVERIFY : OP_EQUAL);
  Branch (822:17): [True: 0, False: 0]
  Branch (822:116): [True: 0, False: 0]
823
0
                case Fragment::HASH256: return BuildScript(OP_SIZE, 32, OP_EQUALVERIFY, OP_HASH256, node.data, verify ? OP_EQUALVERIFY : OP_EQUAL);
  Branch (823:17): [True: 0, False: 0]
  Branch (823:112): [True: 0, False: 0]
824
0
                case Fragment::HASH160: return BuildScript(OP_SIZE, 32, OP_EQUALVERIFY, OP_HASH160, node.data, verify ? OP_EQUALVERIFY : OP_EQUAL);
  Branch (824:17): [True: 0, False: 0]
  Branch (824:112): [True: 0, False: 0]
825
0
                case Fragment::WRAP_A: return BuildScript(OP_TOALTSTACK, subs[0], OP_FROMALTSTACK);
  Branch (825:17): [True: 0, False: 0]
826
0
                case Fragment::WRAP_S: return BuildScript(OP_SWAP, subs[0]);
  Branch (826:17): [True: 0, False: 0]
827
0
                case Fragment::WRAP_C: return BuildScript(std::move(subs[0]), verify ? OP_CHECKSIGVERIFY : OP_CHECKSIG);
  Branch (827:17): [True: 0, False: 0]
  Branch (827:79): [True: 0, False: 0]
828
0
                case Fragment::WRAP_D: return BuildScript(OP_DUP, OP_IF, subs[0], OP_ENDIF);
  Branch (828:17): [True: 0, False: 0]
829
0
                case Fragment::WRAP_V: {
  Branch (829:17): [True: 0, False: 0]
830
0
                    if (node.subs[0].GetType() << "x"_mst) {
  Branch (830:25): [True: 0, False: 0]
831
0
                        return BuildScript(std::move(subs[0]), OP_VERIFY);
832
0
                    } else {
833
0
                        return std::move(subs[0]);
834
0
                    }
835
0
                }
836
0
                case Fragment::WRAP_J: return BuildScript(OP_SIZE, OP_0NOTEQUAL, OP_IF, subs[0], OP_ENDIF);
  Branch (836:17): [True: 0, False: 0]
837
0
                case Fragment::WRAP_N: return BuildScript(std::move(subs[0]), OP_0NOTEQUAL);
  Branch (837:17): [True: 0, False: 0]
838
0
                case Fragment::JUST_1: return BuildScript(OP_1);
  Branch (838:17): [True: 0, False: 0]
839
0
                case Fragment::JUST_0: return BuildScript(OP_0);
  Branch (839:17): [True: 0, False: 0]
840
0
                case Fragment::AND_V: return BuildScript(std::move(subs[0]), subs[1]);
  Branch (840:17): [True: 0, False: 0]
841
0
                case Fragment::AND_B: return BuildScript(std::move(subs[0]), subs[1], OP_BOOLAND);
  Branch (841:17): [True: 0, False: 0]
842
0
                case Fragment::OR_B: return BuildScript(std::move(subs[0]), subs[1], OP_BOOLOR);
  Branch (842:17): [True: 0, False: 0]
843
0
                case Fragment::OR_D: return BuildScript(std::move(subs[0]), OP_IFDUP, OP_NOTIF, subs[1], OP_ENDIF);
  Branch (843:17): [True: 0, False: 0]
844
0
                case Fragment::OR_C: return BuildScript(std::move(subs[0]), OP_NOTIF, subs[1], OP_ENDIF);
  Branch (844:17): [True: 0, False: 0]
845
0
                case Fragment::OR_I: return BuildScript(OP_IF, subs[0], OP_ELSE, subs[1], OP_ENDIF);
  Branch (845:17): [True: 0, False: 0]
846
0
                case Fragment::ANDOR: return BuildScript(std::move(subs[0]), OP_NOTIF, subs[2], OP_ELSE, subs[1], OP_ENDIF);
  Branch (846:17): [True: 0, False: 0]
847
0
                case Fragment::MULTI: {
  Branch (847:17): [True: 0, False: 0]
848
0
                    CHECK_NONFATAL(!is_tapscript);
849
0
                    CScript script = BuildScript(node.k);
850
0
                    for (const auto& key : node.keys) {
  Branch (850:42): [True: 0, False: 0]
851
0
                        script = BuildScript(std::move(script), ctx.ToPKBytes(key));
852
0
                    }
853
0
                    return BuildScript(std::move(script), node.keys.size(), verify ? OP_CHECKMULTISIGVERIFY : OP_CHECKMULTISIG);
  Branch (853:77): [True: 0, False: 0]
854
0
                }
855
0
                case Fragment::MULTI_A: {
  Branch (855:17): [True: 0, False: 0]
856
0
                    CHECK_NONFATAL(is_tapscript);
857
0
                    CScript script = BuildScript(ctx.ToPKBytes(*node.keys.begin()), OP_CHECKSIG);
858
0
                    for (auto it = node.keys.begin() + 1; it != node.keys.end(); ++it) {
  Branch (858:59): [True: 0, False: 0]
859
0
                        script = BuildScript(std::move(script), ctx.ToPKBytes(*it), OP_CHECKSIGADD);
860
0
                    }
861
0
                    return BuildScript(std::move(script), node.k, verify ? OP_NUMEQUALVERIFY : OP_NUMEQUAL);
  Branch (861:67): [True: 0, False: 0]
862
0
                }
863
0
                case Fragment::THRESH: {
  Branch (863:17): [True: 0, False: 0]
864
0
                    CScript script = std::move(subs[0]);
865
0
                    for (size_t i = 1; i < subs.size(); ++i) {
  Branch (865:40): [True: 0, False: 0]
866
0
                        script = BuildScript(std::move(script), subs[i], OP_ADD);
867
0
                    }
868
0
                    return BuildScript(std::move(script), node.k, verify ? OP_EQUALVERIFY : OP_EQUAL);
  Branch (868:67): [True: 0, False: 0]
869
0
                }
870
0
            }
871
0
            assert(false);
  Branch (871:13): [Folded - Ignored]
872
0
        };
873
0
        return TreeEval<CScript>(false, downfn, upfn);
874
0
    }
875
876
    template<typename CTx>
877
0
    std::optional<std::string> ToString(const CTx& ctx) const {
878
0
        bool dummy{false};
879
0
        return ToString(ctx, dummy);
880
0
    }
881
882
    template<typename CTx>
883
0
    std::optional<std::string> ToString(const CTx& ctx, bool& has_priv_key) const {
884
        // To construct the std::string representation for a Miniscript object, we use
885
        // the TreeEvalMaybe algorithm. The State is a boolean: whether the parent node is a
886
        // wrapper. If so, non-wrapper expressions must be prefixed with a ":".
887
0
        auto downfn = [](bool, const Node& node, size_t) {
888
0
            return (node.fragment == Fragment::WRAP_A || node.fragment == Fragment::WRAP_S ||
  Branch (888:21): [True: 0, False: 0]
  Branch (888:58): [True: 0, False: 0]
  Branch (888:21): [True: 0, False: 0]
  Branch (888:58): [True: 0, False: 0]
889
0
                    node.fragment == Fragment::WRAP_D || node.fragment == Fragment::WRAP_V ||
  Branch (889:21): [True: 0, False: 0]
  Branch (889:58): [True: 0, False: 0]
  Branch (889:21): [True: 0, False: 0]
  Branch (889:58): [True: 0, False: 0]
890
0
                    node.fragment == Fragment::WRAP_J || node.fragment == Fragment::WRAP_N ||
  Branch (890:21): [True: 0, False: 0]
  Branch (890:58): [True: 0, False: 0]
  Branch (890:21): [True: 0, False: 0]
  Branch (890:58): [True: 0, False: 0]
891
0
                    node.fragment == Fragment::WRAP_C ||
  Branch (891:21): [True: 0, False: 0]
  Branch (891:21): [True: 0, False: 0]
892
0
                    (node.fragment == Fragment::AND_V && node.subs[1].fragment == Fragment::JUST_1) ||
  Branch (892:22): [True: 0, False: 0]
  Branch (892:58): [True: 0, False: 0]
  Branch (892:22): [True: 0, False: 0]
  Branch (892:58): [True: 0, False: 0]
893
0
                    (node.fragment == Fragment::OR_I && node.subs[0].fragment == Fragment::JUST_0) ||
  Branch (893:22): [True: 0, False: 0]
  Branch (893:57): [True: 0, False: 0]
  Branch (893:22): [True: 0, False: 0]
  Branch (893:57): [True: 0, False: 0]
894
0
                    (node.fragment == Fragment::OR_I && node.subs[1].fragment == Fragment::JUST_0));
  Branch (894:22): [True: 0, False: 0]
  Branch (894:57): [True: 0, False: 0]
  Branch (894:22): [True: 0, False: 0]
  Branch (894:57): [True: 0, False: 0]
895
0
        };
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::ToString<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}::operator()(bool, miniscript::Node<unsigned int> const&, unsigned long) const
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::ToString<(anonymous namespace)::StringMaker>((anonymous namespace)::StringMaker const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, unsigned long)#1}::operator()(bool, miniscript::Node<unsigned int> const&, unsigned long) const
896
0
        auto toString = [&ctx, &has_priv_key](Key key) -> std::optional<std::string> {
897
0
            bool fragment_has_priv_key{false};
898
0
            auto key_str{ctx.ToString(key, fragment_has_priv_key)};
899
0
            if (key_str) has_priv_key = has_priv_key || fragment_has_priv_key;
  Branch (899:17): [True: 0, False: 0]
  Branch (899:41): [True: 0, False: 0]
  Branch (899:57): [True: 0, False: 0]
  Branch (899:17): [True: 0, False: 0]
  Branch (899:41): [True: 0, False: 0]
  Branch (899:57): [True: 0, False: 0]
900
0
            return key_str;
901
0
        };
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::ToString<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&, bool&) const::{lambda(unsigned int)#1}::operator()[abi:cxx11](unsigned int) const
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::ToString<(anonymous namespace)::StringMaker>((anonymous namespace)::StringMaker const&, bool&) const::{lambda(unsigned int)#1}::operator()[abi:cxx11](unsigned int) const
902
        // The upward function computes for a node, given whether its parent is a wrapper,
903
        // and the string representations of its child nodes, the string representation of the node.
904
0
        const bool is_tapscript{IsTapscript(m_script_ctx)};
905
0
        auto upfn = [is_tapscript, &toString](bool wrapped, const Node& node, std::span<std::string> subs) -> std::optional<std::string> {
906
0
            std::string ret = wrapped ? ":" : "";
  Branch (906:31): [True: 0, False: 0]
  Branch (906:31): [True: 0, False: 0]
907
908
0
            switch (node.fragment) {
909
0
                case Fragment::WRAP_A: return "a" + std::move(subs[0]);
  Branch (909:17): [True: 0, False: 0]
  Branch (909:17): [True: 0, False: 0]
910
0
                case Fragment::WRAP_S: return "s" + std::move(subs[0]);
  Branch (910:17): [True: 0, False: 0]
  Branch (910:17): [True: 0, False: 0]
911
0
                case Fragment::WRAP_C:
  Branch (911:17): [True: 0, False: 0]
  Branch (911:17): [True: 0, False: 0]
912
0
                    if (node.subs[0].fragment == Fragment::PK_K) {
  Branch (912:25): [True: 0, False: 0]
  Branch (912:25): [True: 0, False: 0]
913
                        // pk(K) is syntactic sugar for c:pk_k(K)
914
0
                        auto key_str = toString(node.subs[0].keys[0]);
915
0
                        if (!key_str) return {};
  Branch (915:29): [True: 0, False: 0]
  Branch (915:29): [True: 0, False: 0]
916
0
                        return std::move(ret) + "pk(" + std::move(*key_str) + ")";
917
0
                    }
918
0
                    if (node.subs[0].fragment == Fragment::PK_H) {
  Branch (918:25): [True: 0, False: 0]
  Branch (918:25): [True: 0, False: 0]
919
                        // pkh(K) is syntactic sugar for c:pk_h(K)
920
0
                        auto key_str = toString(node.subs[0].keys[0]);
921
0
                        if (!key_str) return {};
  Branch (921:29): [True: 0, False: 0]
  Branch (921:29): [True: 0, False: 0]
922
0
                        return std::move(ret) + "pkh(" + std::move(*key_str) + ")";
923
0
                    }
924
0
                    return "c" + std::move(subs[0]);
925
0
                case Fragment::WRAP_D: return "d" + std::move(subs[0]);
  Branch (925:17): [True: 0, False: 0]
  Branch (925:17): [True: 0, False: 0]
926
0
                case Fragment::WRAP_V: return "v" + std::move(subs[0]);
  Branch (926:17): [True: 0, False: 0]
  Branch (926:17): [True: 0, False: 0]
927
0
                case Fragment::WRAP_J: return "j" + std::move(subs[0]);
  Branch (927:17): [True: 0, False: 0]
  Branch (927:17): [True: 0, False: 0]
928
0
                case Fragment::WRAP_N: return "n" + std::move(subs[0]);
  Branch (928:17): [True: 0, False: 0]
  Branch (928:17): [True: 0, False: 0]
929
0
                case Fragment::AND_V:
  Branch (929:17): [True: 0, False: 0]
  Branch (929:17): [True: 0, False: 0]
930
                    // t:X is syntactic sugar for and_v(X,1).
931
0
                    if (node.subs[1].fragment == Fragment::JUST_1) return "t" + std::move(subs[0]);
  Branch (931:25): [True: 0, False: 0]
  Branch (931:25): [True: 0, False: 0]
932
0
                    break;
933
0
                case Fragment::OR_I:
  Branch (933:17): [True: 0, False: 0]
  Branch (933:17): [True: 0, False: 0]
934
0
                    if (node.subs[0].fragment == Fragment::JUST_0) return "l" + std::move(subs[1]);
  Branch (934:25): [True: 0, False: 0]
  Branch (934:25): [True: 0, False: 0]
935
0
                    if (node.subs[1].fragment == Fragment::JUST_0) return "u" + std::move(subs[0]);
  Branch (935:25): [True: 0, False: 0]
  Branch (935:25): [True: 0, False: 0]
936
0
                    break;
937
0
                default: break;
  Branch (937:17): [True: 0, False: 0]
  Branch (937:17): [True: 0, False: 0]
938
0
            }
939
0
            switch (node.fragment) {
940
0
                case Fragment::PK_K: {
  Branch (940:17): [True: 0, False: 0]
  Branch (940:17): [True: 0, False: 0]
941
0
                    auto key_str = toString(node.keys[0]);
942
0
                    if (!key_str) return {};
  Branch (942:25): [True: 0, False: 0]
  Branch (942:25): [True: 0, False: 0]
943
0
                    return std::move(ret) + "pk_k(" + std::move(*key_str) + ")";
944
0
                }
945
0
                case Fragment::PK_H: {
  Branch (945:17): [True: 0, False: 0]
  Branch (945:17): [True: 0, False: 0]
946
0
                    auto key_str = toString(node.keys[0]);
947
0
                    if (!key_str) return {};
  Branch (947:25): [True: 0, False: 0]
  Branch (947:25): [True: 0, False: 0]
948
0
                    return std::move(ret) + "pk_h(" + std::move(*key_str) + ")";
949
0
                }
950
0
                case Fragment::AFTER: return std::move(ret) + "after(" + util::ToString(node.k) + ")";
  Branch (950:17): [True: 0, False: 0]
  Branch (950:17): [True: 0, False: 0]
951
0
                case Fragment::OLDER: return std::move(ret) + "older(" + util::ToString(node.k) + ")";
  Branch (951:17): [True: 0, False: 0]
  Branch (951:17): [True: 0, False: 0]
952
0
                case Fragment::HASH256: return std::move(ret) + "hash256(" + HexStr(node.data) + ")";
  Branch (952:17): [True: 0, False: 0]
  Branch (952:17): [True: 0, False: 0]
953
0
                case Fragment::HASH160: return std::move(ret) + "hash160(" + HexStr(node.data) + ")";
  Branch (953:17): [True: 0, False: 0]
  Branch (953:17): [True: 0, False: 0]
954
0
                case Fragment::SHA256: return std::move(ret) + "sha256(" + HexStr(node.data) + ")";
  Branch (954:17): [True: 0, False: 0]
  Branch (954:17): [True: 0, False: 0]
955
0
                case Fragment::RIPEMD160: return std::move(ret) + "ripemd160(" + HexStr(node.data) + ")";
  Branch (955:17): [True: 0, False: 0]
  Branch (955:17): [True: 0, False: 0]
956
0
                case Fragment::JUST_1: return std::move(ret) + "1";
  Branch (956:17): [True: 0, False: 0]
  Branch (956:17): [True: 0, False: 0]
957
0
                case Fragment::JUST_0: return std::move(ret) + "0";
  Branch (957:17): [True: 0, False: 0]
  Branch (957:17): [True: 0, False: 0]
958
0
                case Fragment::AND_V: return std::move(ret) + "and_v(" + std::move(subs[0]) + "," + std::move(subs[1]) + ")";
  Branch (958:17): [True: 0, False: 0]
  Branch (958:17): [True: 0, False: 0]
959
0
                case Fragment::AND_B: return std::move(ret) + "and_b(" + std::move(subs[0]) + "," + std::move(subs[1]) + ")";
  Branch (959:17): [True: 0, False: 0]
  Branch (959:17): [True: 0, False: 0]
960
0
                case Fragment::OR_B: return std::move(ret) + "or_b(" + std::move(subs[0]) + "," + std::move(subs[1]) + ")";
  Branch (960:17): [True: 0, False: 0]
  Branch (960:17): [True: 0, False: 0]
961
0
                case Fragment::OR_D: return std::move(ret) + "or_d(" + std::move(subs[0]) + "," + std::move(subs[1]) + ")";
  Branch (961:17): [True: 0, False: 0]
  Branch (961:17): [True: 0, False: 0]
962
0
                case Fragment::OR_C: return std::move(ret) + "or_c(" + std::move(subs[0]) + "," + std::move(subs[1]) + ")";
  Branch (962:17): [True: 0, False: 0]
  Branch (962:17): [True: 0, False: 0]
963
0
                case Fragment::OR_I: return std::move(ret) + "or_i(" + std::move(subs[0]) + "," + std::move(subs[1]) + ")";
  Branch (963:17): [True: 0, False: 0]
  Branch (963:17): [True: 0, False: 0]
964
0
                case Fragment::ANDOR:
  Branch (964:17): [True: 0, False: 0]
  Branch (964:17): [True: 0, False: 0]
965
                    // and_n(X,Y) is syntactic sugar for andor(X,Y,0).
966
0
                    if (node.subs[2].fragment == Fragment::JUST_0) return std::move(ret) + "and_n(" + std::move(subs[0]) + "," + std::move(subs[1]) + ")";
  Branch (966:25): [True: 0, False: 0]
  Branch (966:25): [True: 0, False: 0]
967
0
                    return std::move(ret) + "andor(" + std::move(subs[0]) + "," + std::move(subs[1]) + "," + std::move(subs[2]) + ")";
968
0
                case Fragment::MULTI: {
  Branch (968:17): [True: 0, False: 0]
  Branch (968:17): [True: 0, False: 0]
969
0
                    CHECK_NONFATAL(!is_tapscript);
970
0
                    auto str = std::move(ret) + "multi(" + util::ToString(node.k);
971
0
                    for (const auto& key : node.keys) {
  Branch (971:42): [True: 0, False: 0]
  Branch (971:42): [True: 0, False: 0]
972
0
                        auto key_str = toString(key);
973
0
                        if (!key_str) return {};
  Branch (973:29): [True: 0, False: 0]
  Branch (973:29): [True: 0, False: 0]
974
0
                        str += "," + std::move(*key_str);
975
0
                    }
976
0
                    return std::move(str) + ")";
977
0
                }
978
0
                case Fragment::MULTI_A: {
  Branch (978:17): [True: 0, False: 0]
  Branch (978:17): [True: 0, False: 0]
979
0
                    CHECK_NONFATAL(is_tapscript);
980
0
                    auto str = std::move(ret) + "multi_a(" + util::ToString(node.k);
981
0
                    for (const auto& key : node.keys) {
  Branch (981:42): [True: 0, False: 0]
  Branch (981:42): [True: 0, False: 0]
982
0
                        auto key_str = toString(key);
983
0
                        if (!key_str) return {};
  Branch (983:29): [True: 0, False: 0]
  Branch (983:29): [True: 0, False: 0]
984
0
                        str += "," + std::move(*key_str);
985
0
                    }
986
0
                    return std::move(str) + ")";
987
0
                }
988
0
                case Fragment::THRESH: {
  Branch (988:17): [True: 0, False: 0]
  Branch (988:17): [True: 0, False: 0]
989
0
                    auto str = std::move(ret) + "thresh(" + util::ToString(node.k);
990
0
                    for (auto& sub : subs) {
  Branch (990:36): [True: 0, False: 0]
  Branch (990:36): [True: 0, False: 0]
991
0
                        str += "," + std::move(sub);
992
0
                    }
993
0
                    return std::move(str) + ")";
994
0
                }
995
0
                default: break;
  Branch (995:17): [True: 0, False: 0]
  Branch (995:17): [True: 0, False: 0]
996
0
            }
997
0
            assert(false);
  Branch (997:13): [Folded - Ignored]
  Branch (997:13): [Folded - Ignored]
998
0
        };
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::ToString<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 18446744073709551615ul>)#1}::operator()[abi:cxx11](bool, miniscript::Node<unsigned int> const&, std::span<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 18446744073709551615ul>) const
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::ToString<(anonymous namespace)::StringMaker>((anonymous namespace)::StringMaker const&, bool&) const::{lambda(bool, miniscript::Node<unsigned int> const&, std::span<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 18446744073709551615ul>)#1}::operator()[abi:cxx11](bool, miniscript::Node<unsigned int> const&, std::span<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, 18446744073709551615ul>) const
999
1000
0
        return TreeEvalMaybe<std::string>(false, downfn, upfn);
1001
0
    }
Unexecuted instantiation: descriptor.cpp:std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > miniscript::Node<unsigned int>::ToString<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&, bool&) const
Unexecuted instantiation: descriptor.cpp:std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > miniscript::Node<unsigned int>::ToString<(anonymous namespace)::StringMaker>((anonymous namespace)::StringMaker const&, bool&) const
1002
1003
private:
1004
0
    internal::Ops CalcOps() const {
1005
0
        switch (fragment) {
  Branch (1005:17): [True: 0, False: 0]
  Branch (1005:17): [True: 0, False: 0]
  Branch (1005:17): [True: 0, False: 0]
1006
0
            case Fragment::JUST_1: return {0, 0, {}};
  Branch (1006:13): [True: 0, False: 0]
  Branch (1006:13): [True: 0, False: 0]
  Branch (1006:13): [True: 0, False: 0]
1007
0
            case Fragment::JUST_0: return {0, {}, 0};
  Branch (1007:13): [True: 0, False: 0]
  Branch (1007:13): [True: 0, False: 0]
  Branch (1007:13): [True: 0, False: 0]
1008
0
            case Fragment::PK_K: return {0, 0, 0};
  Branch (1008:13): [True: 0, False: 0]
  Branch (1008:13): [True: 0, False: 0]
  Branch (1008:13): [True: 0, False: 0]
1009
0
            case Fragment::PK_H: return {3, 0, 0};
  Branch (1009:13): [True: 0, False: 0]
  Branch (1009:13): [True: 0, False: 0]
  Branch (1009:13): [True: 0, False: 0]
1010
0
            case Fragment::OLDER:
  Branch (1010:13): [True: 0, False: 0]
  Branch (1010:13): [True: 0, False: 0]
  Branch (1010:13): [True: 0, False: 0]
1011
0
            case Fragment::AFTER: return {1, 0, {}};
  Branch (1011:13): [True: 0, False: 0]
  Branch (1011:13): [True: 0, False: 0]
  Branch (1011:13): [True: 0, False: 0]
1012
0
            case Fragment::SHA256:
  Branch (1012:13): [True: 0, False: 0]
  Branch (1012:13): [True: 0, False: 0]
  Branch (1012:13): [True: 0, False: 0]
1013
0
            case Fragment::RIPEMD160:
  Branch (1013:13): [True: 0, False: 0]
  Branch (1013:13): [True: 0, False: 0]
  Branch (1013:13): [True: 0, False: 0]
1014
0
            case Fragment::HASH256:
  Branch (1014:13): [True: 0, False: 0]
  Branch (1014:13): [True: 0, False: 0]
  Branch (1014:13): [True: 0, False: 0]
1015
0
            case Fragment::HASH160: return {4, 0, {}};
  Branch (1015:13): [True: 0, False: 0]
  Branch (1015:13): [True: 0, False: 0]
  Branch (1015:13): [True: 0, False: 0]
1016
0
            case Fragment::AND_V: return {subs[0].ops.count + subs[1].ops.count, subs[0].ops.sat + subs[1].ops.sat, {}};
  Branch (1016:13): [True: 0, False: 0]
  Branch (1016:13): [True: 0, False: 0]
  Branch (1016:13): [True: 0, False: 0]
1017
0
            case Fragment::AND_B: {
  Branch (1017:13): [True: 0, False: 0]
  Branch (1017:13): [True: 0, False: 0]
  Branch (1017:13): [True: 0, False: 0]
1018
0
                const auto count{1 + subs[0].ops.count + subs[1].ops.count};
1019
0
                const auto sat{subs[0].ops.sat + subs[1].ops.sat};
1020
0
                const auto dsat{subs[0].ops.dsat + subs[1].ops.dsat};
1021
0
                return {count, sat, dsat};
1022
0
            }
1023
0
            case Fragment::OR_B: {
  Branch (1023:13): [True: 0, False: 0]
  Branch (1023:13): [True: 0, False: 0]
  Branch (1023:13): [True: 0, False: 0]
1024
0
                const auto count{1 + subs[0].ops.count + subs[1].ops.count};
1025
0
                const auto sat{(subs[0].ops.sat + subs[1].ops.dsat) | (subs[1].ops.sat + subs[0].ops.dsat)};
1026
0
                const auto dsat{subs[0].ops.dsat + subs[1].ops.dsat};
1027
0
                return {count, sat, dsat};
1028
0
            }
1029
0
            case Fragment::OR_D: {
  Branch (1029:13): [True: 0, False: 0]
  Branch (1029:13): [True: 0, False: 0]
  Branch (1029:13): [True: 0, False: 0]
1030
0
                const auto count{3 + subs[0].ops.count + subs[1].ops.count};
1031
0
                const auto sat{subs[0].ops.sat | (subs[1].ops.sat + subs[0].ops.dsat)};
1032
0
                const auto dsat{subs[0].ops.dsat + subs[1].ops.dsat};
1033
0
                return {count, sat, dsat};
1034
0
            }
1035
0
            case Fragment::OR_C: {
  Branch (1035:13): [True: 0, False: 0]
  Branch (1035:13): [True: 0, False: 0]
  Branch (1035:13): [True: 0, False: 0]
1036
0
                const auto count{2 + subs[0].ops.count + subs[1].ops.count};
1037
0
                const auto sat{subs[0].ops.sat | (subs[1].ops.sat + subs[0].ops.dsat)};
1038
0
                return {count, sat, {}};
1039
0
            }
1040
0
            case Fragment::OR_I: {
  Branch (1040:13): [True: 0, False: 0]
  Branch (1040:13): [True: 0, False: 0]
  Branch (1040:13): [True: 0, False: 0]
1041
0
                const auto count{3 + subs[0].ops.count + subs[1].ops.count};
1042
0
                const auto sat{subs[0].ops.sat | subs[1].ops.sat};
1043
0
                const auto dsat{subs[0].ops.dsat | subs[1].ops.dsat};
1044
0
                return {count, sat, dsat};
1045
0
            }
1046
0
            case Fragment::ANDOR: {
  Branch (1046:13): [True: 0, False: 0]
  Branch (1046:13): [True: 0, False: 0]
  Branch (1046:13): [True: 0, False: 0]
1047
0
                const auto count{3 + subs[0].ops.count + subs[1].ops.count + subs[2].ops.count};
1048
0
                const auto sat{(subs[1].ops.sat + subs[0].ops.sat) | (subs[0].ops.dsat + subs[2].ops.sat)};
1049
0
                const auto dsat{subs[0].ops.dsat + subs[2].ops.dsat};
1050
0
                return {count, sat, dsat};
1051
0
            }
1052
0
            case Fragment::MULTI: return {1, (uint32_t)keys.size(), (uint32_t)keys.size()};
  Branch (1052:13): [True: 0, False: 0]
  Branch (1052:13): [True: 0, False: 0]
  Branch (1052:13): [True: 0, False: 0]
1053
0
            case Fragment::MULTI_A: return {(uint32_t)keys.size() + 1, 0, 0};
  Branch (1053:13): [True: 0, False: 0]
  Branch (1053:13): [True: 0, False: 0]
  Branch (1053:13): [True: 0, False: 0]
1054
0
            case Fragment::WRAP_S:
  Branch (1054:13): [True: 0, False: 0]
  Branch (1054:13): [True: 0, False: 0]
  Branch (1054:13): [True: 0, False: 0]
1055
0
            case Fragment::WRAP_C:
  Branch (1055:13): [True: 0, False: 0]
  Branch (1055:13): [True: 0, False: 0]
  Branch (1055:13): [True: 0, False: 0]
1056
0
            case Fragment::WRAP_N: return {1 + subs[0].ops.count, subs[0].ops.sat, subs[0].ops.dsat};
  Branch (1056:13): [True: 0, False: 0]
  Branch (1056:13): [True: 0, False: 0]
  Branch (1056:13): [True: 0, False: 0]
1057
0
            case Fragment::WRAP_A: return {2 + subs[0].ops.count, subs[0].ops.sat, subs[0].ops.dsat};
  Branch (1057:13): [True: 0, False: 0]
  Branch (1057:13): [True: 0, False: 0]
  Branch (1057:13): [True: 0, False: 0]
1058
0
            case Fragment::WRAP_D: return {3 + subs[0].ops.count, subs[0].ops.sat, 0};
  Branch (1058:13): [True: 0, False: 0]
  Branch (1058:13): [True: 0, False: 0]
  Branch (1058:13): [True: 0, False: 0]
1059
0
            case Fragment::WRAP_J: return {4 + subs[0].ops.count, subs[0].ops.sat, 0};
  Branch (1059:13): [True: 0, False: 0]
  Branch (1059:13): [True: 0, False: 0]
  Branch (1059:13): [True: 0, False: 0]
1060
0
            case Fragment::WRAP_V: return {subs[0].ops.count + (subs[0].GetType() << "x"_mst), subs[0].ops.sat, {}};
  Branch (1060:13): [True: 0, False: 0]
  Branch (1060:13): [True: 0, False: 0]
  Branch (1060:13): [True: 0, False: 0]
1061
0
            case Fragment::THRESH: {
  Branch (1061:13): [True: 0, False: 0]
  Branch (1061:13): [True: 0, False: 0]
  Branch (1061:13): [True: 0, False: 0]
1062
0
                uint32_t count = 0;
1063
0
                auto sats = Vector(internal::MaxInt<uint32_t>(0));
1064
0
                for (const auto& sub : subs) {
  Branch (1064:38): [True: 0, False: 0]
  Branch (1064:38): [True: 0, False: 0]
  Branch (1064:38): [True: 0, False: 0]
1065
0
                    count += sub.ops.count + 1;
1066
0
                    auto next_sats = Vector(sats[0] + sub.ops.dsat);
1067
0
                    for (size_t j = 1; j < sats.size(); ++j) next_sats.push_back((sats[j] + sub.ops.dsat) | (sats[j - 1] + sub.ops.sat));
  Branch (1067:40): [True: 0, False: 0]
  Branch (1067:40): [True: 0, False: 0]
  Branch (1067:40): [True: 0, False: 0]
1068
0
                    next_sats.push_back(sats[sats.size() - 1] + sub.ops.sat);
1069
0
                    sats = std::move(next_sats);
1070
0
                }
1071
0
                assert(k < sats.size());
  Branch (1071:17): [True: 0, False: 0]
  Branch (1071:17): [True: 0, False: 0]
  Branch (1071:17): [True: 0, False: 0]
1072
0
                return {count, sats[k], sats[0]};
1073
0
            }
1074
0
        }
1075
0
        assert(false);
  Branch (1075:9): [Folded - Ignored]
  Branch (1075:9): [Folded - Ignored]
  Branch (1075:9): [Folded - Ignored]
1076
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::CalcOps() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::CalcOps() const
Unexecuted instantiation: miniscript::Node<CPubKey>::CalcOps() const
1077
1078
0
    internal::StackSize CalcStackSize() const {
1079
0
        using namespace internal;
1080
0
        switch (fragment) {
  Branch (1080:17): [True: 0, False: 0]
  Branch (1080:17): [True: 0, False: 0]
  Branch (1080:17): [True: 0, False: 0]
1081
0
            case Fragment::JUST_0: return {{}, SatInfo::Push()};
  Branch (1081:13): [True: 0, False: 0]
  Branch (1081:13): [True: 0, False: 0]
  Branch (1081:13): [True: 0, False: 0]
1082
0
            case Fragment::JUST_1: return {SatInfo::Push(), {}};
  Branch (1082:13): [True: 0, False: 0]
  Branch (1082:13): [True: 0, False: 0]
  Branch (1082:13): [True: 0, False: 0]
1083
0
            case Fragment::OLDER:
  Branch (1083:13): [True: 0, False: 0]
  Branch (1083:13): [True: 0, False: 0]
  Branch (1083:13): [True: 0, False: 0]
1084
0
            case Fragment::AFTER: return {SatInfo::Push() + SatInfo::Nop(), {}};
  Branch (1084:13): [True: 0, False: 0]
  Branch (1084:13): [True: 0, False: 0]
  Branch (1084:13): [True: 0, False: 0]
1085
0
            case Fragment::PK_K: return {SatInfo::Push()};
  Branch (1085:13): [True: 0, False: 0]
  Branch (1085:13): [True: 0, False: 0]
  Branch (1085:13): [True: 0, False: 0]
1086
0
            case Fragment::PK_H: return {SatInfo::OP_DUP() + SatInfo::Hash() + SatInfo::Push() + SatInfo::OP_EQUALVERIFY()};
  Branch (1086:13): [True: 0, False: 0]
  Branch (1086:13): [True: 0, False: 0]
  Branch (1086:13): [True: 0, False: 0]
1087
0
            case Fragment::SHA256:
  Branch (1087:13): [True: 0, False: 0]
  Branch (1087:13): [True: 0, False: 0]
  Branch (1087:13): [True: 0, False: 0]
1088
0
            case Fragment::RIPEMD160:
  Branch (1088:13): [True: 0, False: 0]
  Branch (1088:13): [True: 0, False: 0]
  Branch (1088:13): [True: 0, False: 0]
1089
0
            case Fragment::HASH256:
  Branch (1089:13): [True: 0, False: 0]
  Branch (1089:13): [True: 0, False: 0]
  Branch (1089:13): [True: 0, False: 0]
1090
0
            case Fragment::HASH160: return {
  Branch (1090:13): [True: 0, False: 0]
  Branch (1090:13): [True: 0, False: 0]
  Branch (1090:13): [True: 0, False: 0]
1091
0
                SatInfo::OP_SIZE() + SatInfo::Push() + SatInfo::OP_EQUALVERIFY() + SatInfo::Hash() + SatInfo::Push() + SatInfo::OP_EQUAL(),
1092
0
                {}
1093
0
            };
1094
0
            case Fragment::ANDOR: {
  Branch (1094:13): [True: 0, False: 0]
  Branch (1094:13): [True: 0, False: 0]
  Branch (1094:13): [True: 0, False: 0]
1095
0
                const auto& x{subs[0].ss};
1096
0
                const auto& y{subs[1].ss};
1097
0
                const auto& z{subs[2].ss};
1098
0
                return {
1099
0
                    (x.Sat() + SatInfo::If() + y.Sat()) | (x.Dsat() + SatInfo::If() + z.Sat()),
1100
0
                    x.Dsat() + SatInfo::If() + z.Dsat()
1101
0
                };
1102
0
            }
1103
0
            case Fragment::AND_V: {
  Branch (1103:13): [True: 0, False: 0]
  Branch (1103:13): [True: 0, False: 0]
  Branch (1103:13): [True: 0, False: 0]
1104
0
                const auto& x{subs[0].ss};
1105
0
                const auto& y{subs[1].ss};
1106
0
                return {x.Sat() + y.Sat(), {}};
1107
0
            }
1108
0
            case Fragment::AND_B: {
  Branch (1108:13): [True: 0, False: 0]
  Branch (1108:13): [True: 0, False: 0]
  Branch (1108:13): [True: 0, False: 0]
1109
0
                const auto& x{subs[0].ss};
1110
0
                const auto& y{subs[1].ss};
1111
0
                return {x.Sat() + y.Sat() + SatInfo::BinaryOp(), x.Dsat() + y.Dsat() + SatInfo::BinaryOp()};
1112
0
            }
1113
0
            case Fragment::OR_B: {
  Branch (1113:13): [True: 0, False: 0]
  Branch (1113:13): [True: 0, False: 0]
  Branch (1113:13): [True: 0, False: 0]
1114
0
                const auto& x{subs[0].ss};
1115
0
                const auto& y{subs[1].ss};
1116
0
                return {
1117
0
                    ((x.Sat() + y.Dsat()) | (x.Dsat() + y.Sat())) + SatInfo::BinaryOp(),
1118
0
                    x.Dsat() + y.Dsat() + SatInfo::BinaryOp()
1119
0
                };
1120
0
            }
1121
0
            case Fragment::OR_C: {
  Branch (1121:13): [True: 0, False: 0]
  Branch (1121:13): [True: 0, False: 0]
  Branch (1121:13): [True: 0, False: 0]
1122
0
                const auto& x{subs[0].ss};
1123
0
                const auto& y{subs[1].ss};
1124
0
                return {(x.Sat() + SatInfo::If()) | (x.Dsat() + SatInfo::If() + y.Sat()), {}};
1125
0
            }
1126
0
            case Fragment::OR_D: {
  Branch (1126:13): [True: 0, False: 0]
  Branch (1126:13): [True: 0, False: 0]
  Branch (1126:13): [True: 0, False: 0]
1127
0
                const auto& x{subs[0].ss};
1128
0
                const auto& y{subs[1].ss};
1129
0
                return {
1130
0
                    (x.Sat() + SatInfo::OP_IFDUP(true) + SatInfo::If()) | (x.Dsat() + SatInfo::OP_IFDUP(false) + SatInfo::If() + y.Sat()),
1131
0
                    x.Dsat() + SatInfo::OP_IFDUP(false) + SatInfo::If() + y.Dsat()
1132
0
                };
1133
0
            }
1134
0
            case Fragment::OR_I: {
  Branch (1134:13): [True: 0, False: 0]
  Branch (1134:13): [True: 0, False: 0]
  Branch (1134:13): [True: 0, False: 0]
1135
0
                const auto& x{subs[0].ss};
1136
0
                const auto& y{subs[1].ss};
1137
0
                return {SatInfo::If() + (x.Sat() | y.Sat()), SatInfo::If() + (x.Dsat() | y.Dsat())};
1138
0
            }
1139
            // multi(k, key1, key2, ..., key_n) starts off with k+1 stack elements (a 0, plus k
1140
            // signatures), then reaches n+k+3 stack elements after pushing the n keys, plus k and
1141
            // n itself, and ends with 1 stack element (success or failure). Thus, it net removes
1142
            // k elements (from k+1 to 1), while reaching k+n+2 more than it ends with.
1143
0
            case Fragment::MULTI: return {SatInfo(k, k + keys.size() + 2)};
  Branch (1143:13): [True: 0, False: 0]
  Branch (1143:13): [True: 0, False: 0]
  Branch (1143:13): [True: 0, False: 0]
1144
            // multi_a(k, key1, key2, ..., key_n) starts off with n stack elements (the
1145
            // signatures), reaches 1 more (after the first key push), and ends with 1. Thus it net
1146
            // removes n-1 elements (from n to 1) while reaching n more than it ends with.
1147
0
            case Fragment::MULTI_A: return {SatInfo(keys.size() - 1, keys.size())};
  Branch (1147:13): [True: 0, False: 0]
  Branch (1147:13): [True: 0, False: 0]
  Branch (1147:13): [True: 0, False: 0]
1148
0
            case Fragment::WRAP_A:
  Branch (1148:13): [True: 0, False: 0]
  Branch (1148:13): [True: 0, False: 0]
  Branch (1148:13): [True: 0, False: 0]
1149
0
            case Fragment::WRAP_N:
  Branch (1149:13): [True: 0, False: 0]
  Branch (1149:13): [True: 0, False: 0]
  Branch (1149:13): [True: 0, False: 0]
1150
0
            case Fragment::WRAP_S: return subs[0].ss;
  Branch (1150:13): [True: 0, False: 0]
  Branch (1150:13): [True: 0, False: 0]
  Branch (1150:13): [True: 0, False: 0]
1151
0
            case Fragment::WRAP_C: return {
  Branch (1151:13): [True: 0, False: 0]
  Branch (1151:13): [True: 0, False: 0]
  Branch (1151:13): [True: 0, False: 0]
1152
0
                subs[0].ss.Sat() + SatInfo::OP_CHECKSIG(),
1153
0
                subs[0].ss.Dsat() + SatInfo::OP_CHECKSIG()
1154
0
            };
1155
0
            case Fragment::WRAP_D: return {
  Branch (1155:13): [True: 0, False: 0]
  Branch (1155:13): [True: 0, False: 0]
  Branch (1155:13): [True: 0, False: 0]
1156
0
                SatInfo::OP_DUP() + SatInfo::If() + subs[0].ss.Sat(),
1157
0
                SatInfo::OP_DUP() + SatInfo::If()
1158
0
            };
1159
0
            case Fragment::WRAP_V: return {subs[0].ss.Sat() + SatInfo::OP_VERIFY(), {}};
  Branch (1159:13): [True: 0, False: 0]
  Branch (1159:13): [True: 0, False: 0]
  Branch (1159:13): [True: 0, False: 0]
1160
0
            case Fragment::WRAP_J: return {
  Branch (1160:13): [True: 0, False: 0]
  Branch (1160:13): [True: 0, False: 0]
  Branch (1160:13): [True: 0, False: 0]
1161
0
                SatInfo::OP_SIZE() + SatInfo::OP_0NOTEQUAL() + SatInfo::If() + subs[0].ss.Sat(),
1162
0
                SatInfo::OP_SIZE() + SatInfo::OP_0NOTEQUAL() + SatInfo::If()
1163
0
            };
1164
0
            case Fragment::THRESH: {
  Branch (1164:13): [True: 0, False: 0]
  Branch (1164:13): [True: 0, False: 0]
  Branch (1164:13): [True: 0, False: 0]
1165
                // sats[j] is the SatInfo corresponding to all traces reaching j satisfactions.
1166
0
                auto sats = Vector(SatInfo::Empty());
1167
0
                for (size_t i = 0; i < subs.size(); ++i) {
  Branch (1167:36): [True: 0, False: 0]
  Branch (1167:36): [True: 0, False: 0]
  Branch (1167:36): [True: 0, False: 0]
1168
                    // Loop over the subexpressions, processing them one by one. After adding
1169
                    // element i we need to add OP_ADD (if i>0).
1170
0
                    auto add = i ? SatInfo::BinaryOp() : SatInfo::Empty();
  Branch (1170:32): [True: 0, False: 0]
  Branch (1170:32): [True: 0, False: 0]
  Branch (1170:32): [True: 0, False: 0]
1171
                    // Construct a variable that will become the next sats, starting with index 0.
1172
0
                    auto next_sats = Vector(sats[0] + subs[i].ss.Dsat() + add);
1173
                    // Then loop to construct next_sats[1..i].
1174
0
                    for (size_t j = 1; j < sats.size(); ++j) {
  Branch (1174:40): [True: 0, False: 0]
  Branch (1174:40): [True: 0, False: 0]
  Branch (1174:40): [True: 0, False: 0]
1175
0
                        next_sats.push_back(((sats[j] + subs[i].ss.Dsat()) | (sats[j - 1] + subs[i].ss.Sat())) + add);
1176
0
                    }
1177
                    // Finally construct next_sats[i+1].
1178
0
                    next_sats.push_back(sats[sats.size() - 1] + subs[i].ss.Sat() + add);
1179
                    // Switch over.
1180
0
                    sats = std::move(next_sats);
1181
0
                }
1182
                // To satisfy thresh we need k satisfactions; to dissatisfy we need 0. In both
1183
                // cases a push of k and an OP_EQUAL follow.
1184
0
                return {
1185
0
                    sats[k] + SatInfo::Push() + SatInfo::OP_EQUAL(),
1186
0
                    sats[0] + SatInfo::Push() + SatInfo::OP_EQUAL()
1187
0
                };
1188
0
            }
1189
0
        }
1190
0
        assert(false);
  Branch (1190:9): [Folded - Ignored]
  Branch (1190:9): [Folded - Ignored]
  Branch (1190:9): [Folded - Ignored]
1191
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::CalcStackSize() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::CalcStackSize() const
Unexecuted instantiation: miniscript::Node<CPubKey>::CalcStackSize() const
1192
1193
0
    internal::WitnessSize CalcWitnessSize() const {
1194
0
        const uint32_t sig_size = IsTapscript(m_script_ctx) ? 1 + 65 : 1 + 72;
  Branch (1194:35): [True: 0, False: 0]
  Branch (1194:35): [True: 0, False: 0]
  Branch (1194:35): [True: 0, False: 0]
1195
0
        const uint32_t pubkey_size = IsTapscript(m_script_ctx) ? 1 + 32 : 1 + 33;
  Branch (1195:38): [True: 0, False: 0]
  Branch (1195:38): [True: 0, False: 0]
  Branch (1195:38): [True: 0, False: 0]
1196
0
        switch (fragment) {
  Branch (1196:17): [True: 0, False: 0]
  Branch (1196:17): [True: 0, False: 0]
  Branch (1196:17): [True: 0, False: 0]
1197
0
            case Fragment::JUST_0: return {{}, 0};
  Branch (1197:13): [True: 0, False: 0]
  Branch (1197:13): [True: 0, False: 0]
  Branch (1197:13): [True: 0, False: 0]
1198
0
            case Fragment::JUST_1:
  Branch (1198:13): [True: 0, False: 0]
  Branch (1198:13): [True: 0, False: 0]
  Branch (1198:13): [True: 0, False: 0]
1199
0
            case Fragment::OLDER:
  Branch (1199:13): [True: 0, False: 0]
  Branch (1199:13): [True: 0, False: 0]
  Branch (1199:13): [True: 0, False: 0]
1200
0
            case Fragment::AFTER: return {0, {}};
  Branch (1200:13): [True: 0, False: 0]
  Branch (1200:13): [True: 0, False: 0]
  Branch (1200:13): [True: 0, False: 0]
1201
0
            case Fragment::PK_K: return {sig_size, 1};
  Branch (1201:13): [True: 0, False: 0]
  Branch (1201:13): [True: 0, False: 0]
  Branch (1201:13): [True: 0, False: 0]
1202
0
            case Fragment::PK_H: return {sig_size + pubkey_size, 1 + pubkey_size};
  Branch (1202:13): [True: 0, False: 0]
  Branch (1202:13): [True: 0, False: 0]
  Branch (1202:13): [True: 0, False: 0]
1203
0
            case Fragment::SHA256:
  Branch (1203:13): [True: 0, False: 0]
  Branch (1203:13): [True: 0, False: 0]
  Branch (1203:13): [True: 0, False: 0]
1204
0
            case Fragment::RIPEMD160:
  Branch (1204:13): [True: 0, False: 0]
  Branch (1204:13): [True: 0, False: 0]
  Branch (1204:13): [True: 0, False: 0]
1205
0
            case Fragment::HASH256:
  Branch (1205:13): [True: 0, False: 0]
  Branch (1205:13): [True: 0, False: 0]
  Branch (1205:13): [True: 0, False: 0]
1206
0
            case Fragment::HASH160: return {1 + 32, {}};
  Branch (1206:13): [True: 0, False: 0]
  Branch (1206:13): [True: 0, False: 0]
  Branch (1206:13): [True: 0, False: 0]
1207
0
            case Fragment::ANDOR: {
  Branch (1207:13): [True: 0, False: 0]
  Branch (1207:13): [True: 0, False: 0]
  Branch (1207:13): [True: 0, False: 0]
1208
0
                const auto sat{(subs[0].ws.sat + subs[1].ws.sat) | (subs[0].ws.dsat + subs[2].ws.sat)};
1209
0
                const auto dsat{subs[0].ws.dsat + subs[2].ws.dsat};
1210
0
                return {sat, dsat};
1211
0
            }
1212
0
            case Fragment::AND_V: return {subs[0].ws.sat + subs[1].ws.sat, {}};
  Branch (1212:13): [True: 0, False: 0]
  Branch (1212:13): [True: 0, False: 0]
  Branch (1212:13): [True: 0, False: 0]
1213
0
            case Fragment::AND_B: return {subs[0].ws.sat + subs[1].ws.sat, subs[0].ws.dsat + subs[1].ws.dsat};
  Branch (1213:13): [True: 0, False: 0]
  Branch (1213:13): [True: 0, False: 0]
  Branch (1213:13): [True: 0, False: 0]
1214
0
            case Fragment::OR_B: {
  Branch (1214:13): [True: 0, False: 0]
  Branch (1214:13): [True: 0, False: 0]
  Branch (1214:13): [True: 0, False: 0]
1215
0
                const auto sat{(subs[0].ws.dsat + subs[1].ws.sat) | (subs[0].ws.sat + subs[1].ws.dsat)};
1216
0
                const auto dsat{subs[0].ws.dsat + subs[1].ws.dsat};
1217
0
                return {sat, dsat};
1218
0
            }
1219
0
            case Fragment::OR_C: return {subs[0].ws.sat | (subs[0].ws.dsat + subs[1].ws.sat), {}};
  Branch (1219:13): [True: 0, False: 0]
  Branch (1219:13): [True: 0, False: 0]
  Branch (1219:13): [True: 0, False: 0]
1220
0
            case Fragment::OR_D: return {subs[0].ws.sat | (subs[0].ws.dsat + subs[1].ws.sat), subs[0].ws.dsat + subs[1].ws.dsat};
  Branch (1220:13): [True: 0, False: 0]
  Branch (1220:13): [True: 0, False: 0]
  Branch (1220:13): [True: 0, False: 0]
1221
0
            case Fragment::OR_I: return {(subs[0].ws.sat + 1 + 1) | (subs[1].ws.sat + 1), (subs[0].ws.dsat + 1 + 1) | (subs[1].ws.dsat + 1)};
  Branch (1221:13): [True: 0, False: 0]
  Branch (1221:13): [True: 0, False: 0]
  Branch (1221:13): [True: 0, False: 0]
1222
0
            case Fragment::MULTI: return {k * sig_size + 1, k + 1};
  Branch (1222:13): [True: 0, False: 0]
  Branch (1222:13): [True: 0, False: 0]
  Branch (1222:13): [True: 0, False: 0]
1223
0
            case Fragment::MULTI_A: return {k * sig_size + static_cast<uint32_t>(keys.size()) - k, static_cast<uint32_t>(keys.size())};
  Branch (1223:13): [True: 0, False: 0]
  Branch (1223:13): [True: 0, False: 0]
  Branch (1223:13): [True: 0, False: 0]
1224
0
            case Fragment::WRAP_A:
  Branch (1224:13): [True: 0, False: 0]
  Branch (1224:13): [True: 0, False: 0]
  Branch (1224:13): [True: 0, False: 0]
1225
0
            case Fragment::WRAP_N:
  Branch (1225:13): [True: 0, False: 0]
  Branch (1225:13): [True: 0, False: 0]
  Branch (1225:13): [True: 0, False: 0]
1226
0
            case Fragment::WRAP_S:
  Branch (1226:13): [True: 0, False: 0]
  Branch (1226:13): [True: 0, False: 0]
  Branch (1226:13): [True: 0, False: 0]
1227
0
            case Fragment::WRAP_C: return subs[0].ws;
  Branch (1227:13): [True: 0, False: 0]
  Branch (1227:13): [True: 0, False: 0]
  Branch (1227:13): [True: 0, False: 0]
1228
0
            case Fragment::WRAP_D: return {1 + 1 + subs[0].ws.sat, 1};
  Branch (1228:13): [True: 0, False: 0]
  Branch (1228:13): [True: 0, False: 0]
  Branch (1228:13): [True: 0, False: 0]
1229
0
            case Fragment::WRAP_V: return {subs[0].ws.sat, {}};
  Branch (1229:13): [True: 0, False: 0]
  Branch (1229:13): [True: 0, False: 0]
  Branch (1229:13): [True: 0, False: 0]
1230
0
            case Fragment::WRAP_J: return {subs[0].ws.sat, 1};
  Branch (1230:13): [True: 0, False: 0]
  Branch (1230:13): [True: 0, False: 0]
  Branch (1230:13): [True: 0, False: 0]
1231
0
            case Fragment::THRESH: {
  Branch (1231:13): [True: 0, False: 0]
  Branch (1231:13): [True: 0, False: 0]
  Branch (1231:13): [True: 0, False: 0]
1232
0
                auto sats = Vector(internal::MaxInt<uint32_t>(0));
1233
0
                for (const auto& sub : subs) {
  Branch (1233:38): [True: 0, False: 0]
  Branch (1233:38): [True: 0, False: 0]
  Branch (1233:38): [True: 0, False: 0]
1234
0
                    auto next_sats = Vector(sats[0] + sub.ws.dsat);
1235
0
                    for (size_t j = 1; j < sats.size(); ++j) next_sats.push_back((sats[j] + sub.ws.dsat) | (sats[j - 1] + sub.ws.sat));
  Branch (1235:40): [True: 0, False: 0]
  Branch (1235:40): [True: 0, False: 0]
  Branch (1235:40): [True: 0, False: 0]
1236
0
                    next_sats.push_back(sats[sats.size() - 1] + sub.ws.sat);
1237
0
                    sats = std::move(next_sats);
1238
0
                }
1239
0
                assert(k < sats.size());
  Branch (1239:17): [True: 0, False: 0]
  Branch (1239:17): [True: 0, False: 0]
  Branch (1239:17): [True: 0, False: 0]
1240
0
                return {sats[k], sats[0]};
1241
0
            }
1242
0
        }
1243
0
        assert(false);
  Branch (1243:9): [Folded - Ignored]
  Branch (1243:9): [Folded - Ignored]
  Branch (1243:9): [Folded - Ignored]
1244
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::CalcWitnessSize() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::CalcWitnessSize() const
Unexecuted instantiation: miniscript::Node<CPubKey>::CalcWitnessSize() const
1245
1246
    template<typename Ctx>
1247
0
    internal::InputResult ProduceInput(const Ctx& ctx) const {
1248
0
        using namespace internal;
1249
1250
        // Internal function which is invoked for every tree node, constructing satisfaction/dissatisfactions
1251
        // given those of its subnodes.
1252
0
        auto helper = [&ctx](const Node& node, std::span<InputResult> subres) -> InputResult {
1253
0
            switch (node.fragment) {
  Branch (1253:21): [True: 0, False: 0]
  Branch (1253:21): [True: 0, False: 0]
1254
0
                case Fragment::PK_K: {
  Branch (1254:17): [True: 0, False: 0]
  Branch (1254:17): [True: 0, False: 0]
1255
0
                    std::vector<unsigned char> sig;
1256
0
                    Availability avail = ctx.Sign(node.keys[0], sig);
1257
0
                    return {ZERO, InputStack(std::move(sig)).SetWithSig().SetAvailable(avail)};
1258
0
                }
1259
0
                case Fragment::PK_H: {
  Branch (1259:17): [True: 0, False: 0]
  Branch (1259:17): [True: 0, False: 0]
1260
0
                    std::vector<unsigned char> key = ctx.ToPKBytes(node.keys[0]), sig;
1261
0
                    Availability avail = ctx.Sign(node.keys[0], sig);
1262
0
                    return {ZERO + InputStack(key), (InputStack(std::move(sig)).SetWithSig() + InputStack(key)).SetAvailable(avail)};
1263
0
                }
1264
0
                case Fragment::MULTI_A: {
  Branch (1264:17): [True: 0, False: 0]
  Branch (1264:17): [True: 0, False: 0]
1265
                    // sats[j] represents the best stack containing j valid signatures (out of the first i keys).
1266
                    // In the loop below, these stacks are built up using a dynamic programming approach.
1267
0
                    std::vector<InputStack> sats = Vector(EMPTY);
1268
0
                    for (size_t i = 0; i < node.keys.size(); ++i) {
  Branch (1268:40): [True: 0, False: 0]
  Branch (1268:40): [True: 0, False: 0]
1269
                        // Get the signature for the i'th key in reverse order (the signature for the first key needs to
1270
                        // be at the top of the stack, contrary to CHECKMULTISIG's satisfaction).
1271
0
                        std::vector<unsigned char> sig;
1272
0
                        Availability avail = ctx.Sign(node.keys[node.keys.size() - 1 - i], sig);
1273
                        // Compute signature stack for just this key.
1274
0
                        auto sat = InputStack(std::move(sig)).SetWithSig().SetAvailable(avail);
1275
                        // Compute the next sats vector: next_sats[0] is a copy of sats[0] (no signatures). All further
1276
                        // next_sats[j] are equal to either the existing sats[j] + ZERO, or sats[j-1] plus a signature
1277
                        // for the current (i'th) key. The very last element needs all signatures filled.
1278
0
                        std::vector<InputStack> next_sats;
1279
0
                        next_sats.push_back(sats[0] + ZERO);
1280
0
                        for (size_t j = 1; j < sats.size(); ++j) next_sats.push_back((sats[j] + ZERO) | (std::move(sats[j - 1]) + sat));
  Branch (1280:44): [True: 0, False: 0]
  Branch (1280:44): [True: 0, False: 0]
1281
0
                        next_sats.push_back(std::move(sats[sats.size() - 1]) + std::move(sat));
1282
                        // Switch over.
1283
0
                        sats = std::move(next_sats);
1284
0
                    }
1285
                    // The dissatisfaction consists of as many empty vectors as there are keys, which is the same as
1286
                    // satisfying 0 keys.
1287
0
                    auto& nsat{sats[0]};
1288
0
                    CHECK_NONFATAL(node.k != 0);
1289
0
                    assert(node.k < sats.size());
  Branch (1289:21): [True: 0, False: 0]
  Branch (1289:21): [True: 0, False: 0]
1290
0
                    return {std::move(nsat), std::move(sats[node.k])};
1291
0
                }
1292
0
                case Fragment::MULTI: {
  Branch (1292:17): [True: 0, False: 0]
  Branch (1292:17): [True: 0, False: 0]
1293
                    // sats[j] represents the best stack containing j valid signatures (out of the first i keys).
1294
                    // In the loop below, these stacks are built up using a dynamic programming approach.
1295
                    // sats[0] starts off being {0}, due to the CHECKMULTISIG bug that pops off one element too many.
1296
0
                    std::vector<InputStack> sats = Vector(ZERO);
1297
0
                    for (size_t i = 0; i < node.keys.size(); ++i) {
  Branch (1297:40): [True: 0, False: 0]
  Branch (1297:40): [True: 0, False: 0]
1298
0
                        std::vector<unsigned char> sig;
1299
0
                        Availability avail = ctx.Sign(node.keys[i], sig);
1300
                        // Compute signature stack for just the i'th key.
1301
0
                        auto sat = InputStack(std::move(sig)).SetWithSig().SetAvailable(avail);
1302
                        // Compute the next sats vector: next_sats[0] is a copy of sats[0] (no signatures). All further
1303
                        // next_sats[j] are equal to either the existing sats[j], or sats[j-1] plus a signature for the
1304
                        // current (i'th) key. The very last element needs all signatures filled.
1305
0
                        std::vector<InputStack> next_sats;
1306
0
                        next_sats.push_back(sats[0]);
1307
0
                        for (size_t j = 1; j < sats.size(); ++j) next_sats.push_back(sats[j] | (std::move(sats[j - 1]) + sat));
  Branch (1307:44): [True: 0, False: 0]
  Branch (1307:44): [True: 0, False: 0]
1308
0
                        next_sats.push_back(std::move(sats[sats.size() - 1]) + std::move(sat));
1309
                        // Switch over.
1310
0
                        sats = std::move(next_sats);
1311
0
                    }
1312
                    // The dissatisfaction consists of k+1 stack elements all equal to 0.
1313
0
                    InputStack nsat = ZERO;
1314
0
                    for (size_t i = 0; i < node.k; ++i) nsat = std::move(nsat) + ZERO;
  Branch (1314:40): [True: 0, False: 0]
  Branch (1314:40): [True: 0, False: 0]
1315
0
                    assert(node.k < sats.size());
  Branch (1315:21): [True: 0, False: 0]
  Branch (1315:21): [True: 0, False: 0]
1316
0
                    return {std::move(nsat), std::move(sats[node.k])};
1317
0
                }
1318
0
                case Fragment::THRESH: {
  Branch (1318:17): [True: 0, False: 0]
  Branch (1318:17): [True: 0, False: 0]
1319
                    // sats[k] represents the best stack that satisfies k out of the *last* i subexpressions.
1320
                    // In the loop below, these stacks are built up using a dynamic programming approach.
1321
                    // sats[0] starts off empty.
1322
0
                    std::vector<InputStack> sats = Vector(EMPTY);
1323
0
                    for (size_t i = 0; i < subres.size(); ++i) {
  Branch (1323:40): [True: 0, False: 0]
  Branch (1323:40): [True: 0, False: 0]
1324
                        // Introduce an alias for the i'th last satisfaction/dissatisfaction.
1325
0
                        auto& res = subres[subres.size() - i - 1];
1326
                        // Compute the next sats vector: next_sats[0] is sats[0] plus res.nsat (thus containing all dissatisfactions
1327
                        // so far. next_sats[j] is either sats[j] + res.nsat (reusing j earlier satisfactions) or sats[j-1] + res.sat
1328
                        // (reusing j-1 earlier satisfactions plus a new one). The very last next_sats[j] is all satisfactions.
1329
0
                        std::vector<InputStack> next_sats;
1330
0
                        next_sats.push_back(sats[0] + res.nsat);
1331
0
                        for (size_t j = 1; j < sats.size(); ++j) next_sats.push_back((sats[j] + res.nsat) | (std::move(sats[j - 1]) + res.sat));
  Branch (1331:44): [True: 0, False: 0]
  Branch (1331:44): [True: 0, False: 0]
1332
0
                        next_sats.push_back(std::move(sats[sats.size() - 1]) + std::move(res.sat));
1333
                        // Switch over.
1334
0
                        sats = std::move(next_sats);
1335
0
                    }
1336
                    // At this point, sats[k].sat is the best satisfaction for the overall thresh() node. The best dissatisfaction
1337
                    // is computed by gathering all sats[i].nsat for i != k.
1338
0
                    InputStack nsat = INVALID;
1339
0
                    for (size_t i = 0; i < sats.size(); ++i) {
  Branch (1339:40): [True: 0, False: 0]
  Branch (1339:40): [True: 0, False: 0]
1340
                        // i==k is the satisfaction; i==0 is the canonical dissatisfaction;
1341
                        // the rest are non-canonical (a no-signature dissatisfaction - the i=0
1342
                        // form - is always available) and malleable (due to overcompleteness).
1343
                        // Marking the solutions malleable here is not strictly necessary, as they
1344
                        // should already never be picked in non-malleable solutions due to the
1345
                        // availability of the i=0 form.
1346
0
                        if (i != 0 && i != node.k) sats[i].SetMalleable().SetNonCanon();
  Branch (1346:29): [True: 0, False: 0]
  Branch (1346:39): [True: 0, False: 0]
  Branch (1346:29): [True: 0, False: 0]
  Branch (1346:39): [True: 0, False: 0]
1347
                        // Include all dissatisfactions (even these non-canonical ones) in nsat.
1348
0
                        if (i != node.k) nsat = std::move(nsat) | std::move(sats[i]);
  Branch (1348:29): [True: 0, False: 0]
  Branch (1348:29): [True: 0, False: 0]
1349
0
                    }
1350
0
                    assert(node.k < sats.size());
  Branch (1350:21): [True: 0, False: 0]
  Branch (1350:21): [True: 0, False: 0]
1351
0
                    return {std::move(nsat), std::move(sats[node.k])};
1352
0
                }
1353
0
                case Fragment::OLDER: {
  Branch (1353:17): [True: 0, False: 0]
  Branch (1353:17): [True: 0, False: 0]
1354
0
                    return {INVALID, ctx.CheckOlder(node.k) ? EMPTY : INVALID};
  Branch (1354:38): [True: 0, False: 0]
  Branch (1354:38): [True: 0, False: 0]
1355
0
                }
1356
0
                case Fragment::AFTER: {
  Branch (1356:17): [True: 0, False: 0]
  Branch (1356:17): [True: 0, False: 0]
1357
0
                    return {INVALID, ctx.CheckAfter(node.k) ? EMPTY : INVALID};
  Branch (1357:38): [True: 0, False: 0]
  Branch (1357:38): [True: 0, False: 0]
1358
0
                }
1359
0
                case Fragment::SHA256: {
  Branch (1359:17): [True: 0, False: 0]
  Branch (1359:17): [True: 0, False: 0]
1360
0
                    std::vector<unsigned char> preimage;
1361
0
                    Availability avail = ctx.SatSHA256(node.data, preimage);
1362
0
                    return {ZERO32, InputStack(std::move(preimage)).SetAvailable(avail)};
1363
0
                }
1364
0
                case Fragment::RIPEMD160: {
  Branch (1364:17): [True: 0, False: 0]
  Branch (1364:17): [True: 0, False: 0]
1365
0
                    std::vector<unsigned char> preimage;
1366
0
                    Availability avail = ctx.SatRIPEMD160(node.data, preimage);
1367
0
                    return {ZERO32, InputStack(std::move(preimage)).SetAvailable(avail)};
1368
0
                }
1369
0
                case Fragment::HASH256: {
  Branch (1369:17): [True: 0, False: 0]
  Branch (1369:17): [True: 0, False: 0]
1370
0
                    std::vector<unsigned char> preimage;
1371
0
                    Availability avail = ctx.SatHASH256(node.data, preimage);
1372
0
                    return {ZERO32, InputStack(std::move(preimage)).SetAvailable(avail)};
1373
0
                }
1374
0
                case Fragment::HASH160: {
  Branch (1374:17): [True: 0, False: 0]
  Branch (1374:17): [True: 0, False: 0]
1375
0
                    std::vector<unsigned char> preimage;
1376
0
                    Availability avail = ctx.SatHASH160(node.data, preimage);
1377
0
                    return {ZERO32, InputStack(std::move(preimage)).SetAvailable(avail)};
1378
0
                }
1379
0
                case Fragment::AND_V: {
  Branch (1379:17): [True: 0, False: 0]
  Branch (1379:17): [True: 0, False: 0]
1380
0
                    auto& x = subres[0], &y = subres[1];
1381
                    // As the dissatisfaction here only consist of a single option, it doesn't
1382
                    // actually need to be listed (it's not required for reasoning about malleability of
1383
                    // other options), and is never required (no valid miniscript relies on the ability
1384
                    // to satisfy the type V left subexpression). It's still listed here for
1385
                    // completeness, as a hypothetical (not currently implemented) satisfier that doesn't
1386
                    // care about malleability might in some cases prefer it still.
1387
0
                    return {(y.nsat + x.sat).SetNonCanon(), y.sat + x.sat};
1388
0
                }
1389
0
                case Fragment::AND_B: {
  Branch (1389:17): [True: 0, False: 0]
  Branch (1389:17): [True: 0, False: 0]
1390
0
                    auto& x = subres[0], &y = subres[1];
1391
                    // Note that it is not strictly necessary to mark the 2nd and 3rd dissatisfaction here
1392
                    // as malleable. While they are definitely malleable, they are also non-canonical due
1393
                    // to the guaranteed existence of a no-signature other dissatisfaction (the 1st)
1394
                    // option. Because of that, the 2nd and 3rd option will never be chosen, even if they
1395
                    // weren't marked as malleable.
1396
0
                    return {(y.nsat + x.nsat) | (y.sat + x.nsat).SetMalleable().SetNonCanon() | (y.nsat + x.sat).SetMalleable().SetNonCanon(), y.sat + x.sat};
1397
0
                }
1398
0
                case Fragment::OR_B: {
  Branch (1398:17): [True: 0, False: 0]
  Branch (1398:17): [True: 0, False: 0]
1399
0
                    auto& x = subres[0], &z = subres[1];
1400
                    // The (sat(Z) sat(X)) solution is overcomplete (attacker can change either into dsat).
1401
0
                    return {z.nsat + x.nsat, (z.nsat + x.sat) | (z.sat + x.nsat) | (z.sat + x.sat).SetMalleable().SetNonCanon()};
1402
0
                }
1403
0
                case Fragment::OR_C: {
  Branch (1403:17): [True: 0, False: 0]
  Branch (1403:17): [True: 0, False: 0]
1404
0
                    auto& x = subres[0], &z = subres[1];
1405
0
                    return {INVALID, std::move(x.sat) | (z.sat + x.nsat)};
1406
0
                }
1407
0
                case Fragment::OR_D: {
  Branch (1407:17): [True: 0, False: 0]
  Branch (1407:17): [True: 0, False: 0]
1408
0
                    auto& x = subres[0], &z = subres[1];
1409
0
                    return {z.nsat + x.nsat, std::move(x.sat) | (z.sat + x.nsat)};
1410
0
                }
1411
0
                case Fragment::OR_I: {
  Branch (1411:17): [True: 0, False: 0]
  Branch (1411:17): [True: 0, False: 0]
1412
0
                    auto& x = subres[0], &z = subres[1];
1413
0
                    return {(x.nsat + ONE) | (z.nsat + ZERO), (x.sat + ONE) | (z.sat + ZERO)};
1414
0
                }
1415
0
                case Fragment::ANDOR: {
  Branch (1415:17): [True: 0, False: 0]
  Branch (1415:17): [True: 0, False: 0]
1416
0
                    auto& x = subres[0], &y = subres[1], &z = subres[2];
1417
0
                    return {(y.nsat + x.sat).SetNonCanon() | (z.nsat + x.nsat), (y.sat + x.sat) | (z.sat + x.nsat)};
1418
0
                }
1419
0
                case Fragment::WRAP_A:
  Branch (1419:17): [True: 0, False: 0]
  Branch (1419:17): [True: 0, False: 0]
1420
0
                case Fragment::WRAP_S:
  Branch (1420:17): [True: 0, False: 0]
  Branch (1420:17): [True: 0, False: 0]
1421
0
                case Fragment::WRAP_C:
  Branch (1421:17): [True: 0, False: 0]
  Branch (1421:17): [True: 0, False: 0]
1422
0
                case Fragment::WRAP_N:
  Branch (1422:17): [True: 0, False: 0]
  Branch (1422:17): [True: 0, False: 0]
1423
0
                    return std::move(subres[0]);
1424
0
                case Fragment::WRAP_D: {
  Branch (1424:17): [True: 0, False: 0]
  Branch (1424:17): [True: 0, False: 0]
1425
0
                    auto &x = subres[0];
1426
0
                    return {ZERO, x.sat + ONE};
1427
0
                }
1428
0
                case Fragment::WRAP_J: {
  Branch (1428:17): [True: 0, False: 0]
  Branch (1428:17): [True: 0, False: 0]
1429
0
                    auto &x = subres[0];
1430
                    // If a dissatisfaction with a nonzero top stack element exists, an alternative dissatisfaction exists.
1431
                    // As the dissatisfaction logic currently doesn't keep track of this nonzeroness property, and thus even
1432
                    // if a dissatisfaction with a top zero element is found, we don't know whether another one with a
1433
                    // nonzero top stack element exists. Make the conservative assumption that whenever the subexpression is weakly
1434
                    // dissatisfiable, this alternative dissatisfaction exists and leads to malleability.
1435
0
                    return {InputStack(ZERO).SetMalleable(x.nsat.available != Availability::NO && !x.nsat.has_sig), std::move(x.sat)};
  Branch (1435:59): [True: 0, False: 0]
  Branch (1435:99): [True: 0, False: 0]
  Branch (1435:59): [True: 0, False: 0]
  Branch (1435:99): [True: 0, False: 0]
1436
0
                }
1437
0
                case Fragment::WRAP_V: {
  Branch (1437:17): [True: 0, False: 0]
  Branch (1437:17): [True: 0, False: 0]
1438
0
                    auto &x = subres[0];
1439
0
                    return {INVALID, std::move(x.sat)};
1440
0
                }
1441
0
                case Fragment::JUST_0: return {EMPTY, INVALID};
  Branch (1441:17): [True: 0, False: 0]
  Branch (1441:17): [True: 0, False: 0]
1442
0
                case Fragment::JUST_1: return {INVALID, EMPTY};
  Branch (1442:17): [True: 0, False: 0]
  Branch (1442:17): [True: 0, False: 0]
1443
0
            }
1444
0
            assert(false);
  Branch (1444:13): [Folded - Ignored]
  Branch (1444:13): [Folded - Ignored]
1445
0
            return {INVALID, INVALID};
1446
0
        };
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#1}::operator()(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>) const
Unexecuted instantiation: miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#1}::operator()(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>) const
1447
1448
0
        auto tester = [&helper](const Node& node, std::span<InputResult> subres) -> InputResult {
1449
0
            auto ret = helper(node, subres);
1450
1451
            // Do a consistency check between the satisfaction code and the type checker
1452
            // (the actual satisfaction code in ProduceInputHelper does not use GetType)
1453
1454
            // For 'z' nodes, available satisfactions/dissatisfactions must have stack size 0.
1455
0
            if (node.GetType() << "z"_mst && ret.nsat.available != Availability::NO) CHECK_NONFATAL(ret.nsat.stack.size() == 0);
  Branch (1455:17): [True: 0, False: 0]
  Branch (1455:17): [True: 0, False: 0]
  Branch (1455:46): [True: 0, False: 0]
  Branch (1455:17): [True: 0, False: 0]
  Branch (1455:17): [True: 0, False: 0]
  Branch (1455:46): [True: 0, False: 0]
1456
0
            if (node.GetType() << "z"_mst && ret.sat.available != Availability::NO) CHECK_NONFATAL(ret.sat.stack.size() == 0);
  Branch (1456:17): [True: 0, False: 0]
  Branch (1456:17): [True: 0, False: 0]
  Branch (1456:46): [True: 0, False: 0]
  Branch (1456:17): [True: 0, False: 0]
  Branch (1456:17): [True: 0, False: 0]
  Branch (1456:46): [True: 0, False: 0]
1457
1458
            // For 'o' nodes, available satisfactions/dissatisfactions must have stack size 1.
1459
0
            if (node.GetType() << "o"_mst && ret.nsat.available != Availability::NO) CHECK_NONFATAL(ret.nsat.stack.size() == 1);
  Branch (1459:17): [True: 0, False: 0]
  Branch (1459:17): [True: 0, False: 0]
  Branch (1459:46): [True: 0, False: 0]
  Branch (1459:17): [True: 0, False: 0]
  Branch (1459:17): [True: 0, False: 0]
  Branch (1459:46): [True: 0, False: 0]
1460
0
            if (node.GetType() << "o"_mst && ret.sat.available != Availability::NO) CHECK_NONFATAL(ret.sat.stack.size() == 1);
  Branch (1460:17): [True: 0, False: 0]
  Branch (1460:17): [True: 0, False: 0]
  Branch (1460:46): [True: 0, False: 0]
  Branch (1460:17): [True: 0, False: 0]
  Branch (1460:17): [True: 0, False: 0]
  Branch (1460:46): [True: 0, False: 0]
1461
1462
            // For 'n' nodes, available satisfactions/dissatisfactions must have stack size 1 or larger. For satisfactions,
1463
            // the top element cannot be 0.
1464
0
            if (node.GetType() << "n"_mst && ret.sat.available != Availability::NO) CHECK_NONFATAL(ret.sat.stack.size() >= 1);
  Branch (1464:17): [True: 0, False: 0]
  Branch (1464:17): [True: 0, False: 0]
  Branch (1464:46): [True: 0, False: 0]
  Branch (1464:17): [True: 0, False: 0]
  Branch (1464:17): [True: 0, False: 0]
  Branch (1464:46): [True: 0, False: 0]
1465
0
            if (node.GetType() << "n"_mst && ret.nsat.available != Availability::NO) CHECK_NONFATAL(ret.nsat.stack.size() >= 1);
  Branch (1465:17): [True: 0, False: 0]
  Branch (1465:17): [True: 0, False: 0]
  Branch (1465:46): [True: 0, False: 0]
  Branch (1465:17): [True: 0, False: 0]
  Branch (1465:17): [True: 0, False: 0]
  Branch (1465:46): [True: 0, False: 0]
1466
0
            if (node.GetType() << "n"_mst && ret.sat.available != Availability::NO) CHECK_NONFATAL(!ret.sat.stack.back().empty());
  Branch (1466:17): [True: 0, False: 0]
  Branch (1466:17): [True: 0, False: 0]
  Branch (1466:46): [True: 0, False: 0]
  Branch (1466:17): [True: 0, False: 0]
  Branch (1466:17): [True: 0, False: 0]
  Branch (1466:46): [True: 0, False: 0]
1467
1468
            // For 'd' nodes, a dissatisfaction must exist, and they must not need a signature. If it is non-malleable,
1469
            // it must be canonical.
1470
0
            if (node.GetType() << "d"_mst) CHECK_NONFATAL(ret.nsat.available != Availability::NO);
  Branch (1470:17): [True: 0, False: 0]
  Branch (1470:17): [True: 0, False: 0]
1471
0
            if (node.GetType() << "d"_mst) CHECK_NONFATAL(!ret.nsat.has_sig);
  Branch (1471:17): [True: 0, False: 0]
  Branch (1471:17): [True: 0, False: 0]
1472
0
            if (node.GetType() << "d"_mst && !ret.nsat.malleable) CHECK_NONFATAL(!ret.nsat.non_canon);
  Branch (1472:17): [True: 0, False: 0]
  Branch (1472:17): [True: 0, False: 0]
  Branch (1472:46): [True: 0, False: 0]
  Branch (1472:17): [True: 0, False: 0]
  Branch (1472:17): [True: 0, False: 0]
  Branch (1472:46): [True: 0, False: 0]
1473
1474
            // For 'f'/'s' nodes, dissatisfactions/satisfactions must have a signature.
1475
0
            if (node.GetType() << "f"_mst && ret.nsat.available != Availability::NO) CHECK_NONFATAL(ret.nsat.has_sig);
  Branch (1475:17): [True: 0, False: 0]
  Branch (1475:17): [True: 0, False: 0]
  Branch (1475:46): [True: 0, False: 0]
  Branch (1475:17): [True: 0, False: 0]
  Branch (1475:17): [True: 0, False: 0]
  Branch (1475:46): [True: 0, False: 0]
1476
0
            if (node.GetType() << "s"_mst && ret.sat.available != Availability::NO) CHECK_NONFATAL(ret.sat.has_sig);
  Branch (1476:17): [True: 0, False: 0]
  Branch (1476:17): [True: 0, False: 0]
  Branch (1476:46): [True: 0, False: 0]
  Branch (1476:17): [True: 0, False: 0]
  Branch (1476:17): [True: 0, False: 0]
  Branch (1476:46): [True: 0, False: 0]
1477
1478
            // For non-malleable 'e' nodes, a non-malleable dissatisfaction must exist.
1479
0
            if (node.GetType() << "me"_mst) CHECK_NONFATAL(ret.nsat.available != Availability::NO);
  Branch (1479:17): [True: 0, False: 0]
  Branch (1479:17): [True: 0, False: 0]
1480
0
            if (node.GetType() << "me"_mst) CHECK_NONFATAL(!ret.nsat.malleable);
  Branch (1480:17): [True: 0, False: 0]
  Branch (1480:17): [True: 0, False: 0]
1481
1482
            // For 'm' nodes, if a satisfaction exists, it must be non-malleable.
1483
0
            if (node.GetType() << "m"_mst && ret.sat.available != Availability::NO) CHECK_NONFATAL(!ret.sat.malleable);
  Branch (1483:17): [True: 0, False: 0]
  Branch (1483:17): [True: 0, False: 0]
  Branch (1483:46): [True: 0, False: 0]
  Branch (1483:17): [True: 0, False: 0]
  Branch (1483:17): [True: 0, False: 0]
  Branch (1483:46): [True: 0, False: 0]
1484
1485
            // If a non-malleable satisfaction exists, it must be canonical.
1486
0
            if (ret.sat.available != Availability::NO && !ret.sat.malleable) CHECK_NONFATAL(!ret.sat.non_canon);
  Branch (1486:17): [True: 0, False: 0]
  Branch (1486:58): [True: 0, False: 0]
  Branch (1486:17): [True: 0, False: 0]
  Branch (1486:58): [True: 0, False: 0]
1487
1488
0
            return ret;
1489
0
        };
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}::operator()(miniscript::Node<XOnlyPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>) const
Unexecuted instantiation: miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>)#2}::operator()(miniscript::Node<CPubKey> const&, std::span<miniscript::internal::InputResult, 18446744073709551615ul>) const
1490
1491
0
        return TreeEval<InputResult>(tester);
1492
0
    }
Unexecuted instantiation: miniscript::internal::InputResult miniscript::Node<XOnlyPubKey>::ProduceInput<TapSatisfier>(TapSatisfier const&) const
Unexecuted instantiation: miniscript::internal::InputResult miniscript::Node<CPubKey>::ProduceInput<WshSatisfier>(WshSatisfier const&) const
1493
1494
public:
1495
    /** Update duplicate key information in this Node.
1496
     *
1497
     * This uses a custom key comparator provided by the context in order to still detect duplicates
1498
     * for more complicated types.
1499
     */
1500
    template<typename Ctx> void DuplicateKeyCheck(const Ctx& ctx) const
1501
0
    {
1502
        // We cannot use a lambda here, as lambdas are non assignable, and the set operations
1503
        // below require moving the comparators around.
1504
0
        struct Comp {
1505
0
            const Ctx* ctx_ptr;
1506
0
            Comp(const Ctx& ctx) : ctx_ptr(&ctx) {}
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp::Comp((anonymous namespace)::KeyParser const&)
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp::Comp(TapSatisfier const&)
Unexecuted instantiation: miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp::Comp(WshSatisfier const&)
1507
0
            bool operator()(const Key& a, const Key& b) const { return ctx_ptr->KeyCompare(a, b); }
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp::operator()(unsigned int const&, unsigned int const&) const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp::operator()(XOnlyPubKey const&, XOnlyPubKey const&) const
Unexecuted instantiation: miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp::operator()(CPubKey const&, CPubKey const&) const
1508
0
        };
1509
1510
        // state in the recursive computation:
1511
        // - std::nullopt means "this node has duplicates"
1512
        // - an std::set means "this node has no duplicate keys, and they are: ...".
1513
0
        using keyset = std::set<Key, Comp>;
1514
0
        using state = std::optional<keyset>;
1515
1516
0
        auto upfn = [&ctx](const Node& node, std::span<state> subs) -> state {
1517
            // If this node is already known to have duplicates, nothing left to do.
1518
0
            if (node.has_duplicate_keys.has_value() && *node.has_duplicate_keys) return {};
  Branch (1518:17): [True: 0, False: 0]
  Branch (1518:56): [True: 0, False: 0]
  Branch (1518:17): [True: 0, False: 0]
  Branch (1518:56): [True: 0, False: 0]
  Branch (1518:17): [True: 0, False: 0]
  Branch (1518:56): [True: 0, False: 0]
1519
1520
            // Check if one of the children is already known to have duplicates.
1521
0
            for (auto& sub : subs) {
  Branch (1521:28): [True: 0, False: 0]
  Branch (1521:28): [True: 0, False: 0]
  Branch (1521:28): [True: 0, False: 0]
1522
0
                if (!sub.has_value()) {
  Branch (1522:21): [True: 0, False: 0]
  Branch (1522:21): [True: 0, False: 0]
  Branch (1522:21): [True: 0, False: 0]
1523
0
                    node.has_duplicate_keys = true;
1524
0
                    return {};
1525
0
                }
1526
0
            }
1527
1528
            // Start building the set of keys involved in this node and children.
1529
            // Start by keys in this node directly.
1530
0
            size_t keys_count = node.keys.size();
1531
0
            keyset key_set{node.keys.begin(), node.keys.end(), Comp(ctx)};
1532
0
            if (key_set.size() != keys_count) {
  Branch (1532:17): [True: 0, False: 0]
  Branch (1532:17): [True: 0, False: 0]
  Branch (1532:17): [True: 0, False: 0]
1533
                // It already has duplicates; bail out.
1534
0
                node.has_duplicate_keys = true;
1535
0
                return {};
1536
0
            }
1537
1538
            // Merge the keys from the children into this set.
1539
0
            for (auto& sub : subs) {
  Branch (1539:28): [True: 0, False: 0]
  Branch (1539:28): [True: 0, False: 0]
  Branch (1539:28): [True: 0, False: 0]
1540
0
                keys_count += sub->size();
1541
                // Small optimization: std::set::merge is linear in the size of the second arg but
1542
                // logarithmic in the size of the first.
1543
0
                if (key_set.size() < sub->size()) std::swap(key_set, *sub);
  Branch (1543:21): [True: 0, False: 0]
  Branch (1543:21): [True: 0, False: 0]
  Branch (1543:21): [True: 0, False: 0]
1544
0
                key_set.merge(*sub);
1545
0
                if (key_set.size() != keys_count) {
  Branch (1545:21): [True: 0, False: 0]
  Branch (1545:21): [True: 0, False: 0]
  Branch (1545:21): [True: 0, False: 0]
1546
0
                    node.has_duplicate_keys = true;
1547
0
                    return {};
1548
0
                }
1549
0
            }
1550
1551
0
            node.has_duplicate_keys = false;
1552
0
            return key_set;
1553
0
        };
Unexecuted instantiation: descriptor.cpp:miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::{lambda(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>(auto:1 const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>)#1}::operator()(miniscript::Node<unsigned int> const&, std::span<std::optional<std::set<unsigned int, miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const::Comp, std::allocator<unsigned int> > >, 18446744073709551615ul>) const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::{lambda(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(auto:1 const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>)#1}::operator()(miniscript::Node<XOnlyPubKey> const&, std::span<std::optional<std::set<XOnlyPubKey, miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const::Comp, std::allocator<XOnlyPubKey> > >, 18446744073709551615ul>) const
Unexecuted instantiation: miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::{lambda(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(auto:1 const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>)#1}::operator()(miniscript::Node<CPubKey> const&, std::span<std::optional<std::set<CPubKey, miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const::Comp, std::allocator<CPubKey> > >, 18446744073709551615ul>) const
1554
1555
0
        TreeEval<state>(upfn);
1556
0
    }
Unexecuted instantiation: descriptor.cpp:void miniscript::Node<unsigned int>::DuplicateKeyCheck<(anonymous namespace)::KeyParser>((anonymous namespace)::KeyParser const&) const
Unexecuted instantiation: void miniscript::Node<XOnlyPubKey>::DuplicateKeyCheck<TapSatisfier>(TapSatisfier const&) const
Unexecuted instantiation: void miniscript::Node<CPubKey>::DuplicateKeyCheck<WshSatisfier>(WshSatisfier const&) const
1557
1558
    //! Return the size of the script for this expression (faster than ToScript().size()).
1559
0
    size_t ScriptSize() const { return scriptlen; }
Unexecuted instantiation: miniscript::Node<unsigned int>::ScriptSize() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::ScriptSize() const
Unexecuted instantiation: miniscript::Node<CPubKey>::ScriptSize() const
1560
1561
    //! Return the maximum number of ops needed to satisfy this script non-malleably.
1562
0
    std::optional<uint32_t> GetOps() const {
1563
0
        if (!ops.sat.Valid()) return {};
  Branch (1563:13): [True: 0, False: 0]
1564
0
        return ops.count + ops.sat.Value();
1565
0
    }
1566
1567
    //! Return the number of ops in the script (not counting the dynamic ones that depend on execution).
1568
    uint32_t GetStaticOps() const { return ops.count; }
1569
1570
    //! Check the ops limit of this script against the consensus limit.
1571
0
    bool CheckOpsLimit() const {
1572
0
        if (IsTapscript(m_script_ctx)) return true;
  Branch (1572:13): [True: 0, False: 0]
1573
0
        if (const auto ops = GetOps()) return *ops <= MAX_OPS_PER_SCRIPT;
  Branch (1573:24): [True: 0, False: 0]
1574
0
        return true;
1575
0
    }
1576
1577
    /** Whether this node is of type B, K or W. (That is, anything but V.) */
1578
0
    bool IsBKW() const {
1579
0
        return !((GetType() & "BKW"_mst) == ""_mst);
1580
0
    }
1581
1582
    /** Return the maximum number of stack elements needed to satisfy this script non-malleably. */
1583
0
    std::optional<uint32_t> GetStackSize() const {
1584
0
        if (!ss.Sat().Valid()) return {};
  Branch (1584:13): [True: 0, False: 0]
1585
0
        return ss.Sat().NetDiff() + static_cast<int32_t>(IsBKW());
1586
0
    }
1587
1588
    //! Return the maximum size of the stack during execution of this script.
1589
0
    std::optional<uint32_t> GetExecStackSize() const {
1590
0
        if (!ss.Sat().Valid()) return {};
  Branch (1590:13): [True: 0, False: 0]
1591
0
        return ss.Sat().Exec() + static_cast<int32_t>(IsBKW());
1592
0
    }
1593
1594
    //! Check the maximum stack size for this script against the policy limit.
1595
0
    bool CheckStackSize() const {
1596
        // Since in Tapscript there is no standardness limit on the script and witness sizes, we may run
1597
        // into the maximum stack size while executing the script. Make sure it doesn't happen.
1598
0
        if (IsTapscript(m_script_ctx)) {
  Branch (1598:13): [True: 0, False: 0]
1599
0
            if (const auto exec_ss = GetExecStackSize()) return exec_ss <= MAX_STACK_SIZE;
  Branch (1599:28): [True: 0, False: 0]
1600
0
            return true;
1601
0
        }
1602
0
        if (const auto ss = GetStackSize()) return *ss <= MAX_STANDARD_P2WSH_STACK_ITEMS;
  Branch (1602:24): [True: 0, False: 0]
1603
0
        return true;
1604
0
    }
1605
1606
    //! Whether no satisfaction exists for this node.
1607
0
    bool IsNotSatisfiable() const { return !GetStackSize(); }
1608
1609
    /** Return the maximum size in bytes of a witness to satisfy this script non-malleably. Note this does
1610
     * not include the witness script push. */
1611
0
    std::optional<uint32_t> GetWitnessSize() const {
1612
0
        if (!ws.sat.Valid()) return {};
  Branch (1612:13): [True: 0, False: 0]
1613
0
        return ws.sat.Value();
1614
0
    }
1615
1616
    //! Return the expression type.
1617
0
    Type GetType() const { return typ; }
Unexecuted instantiation: miniscript::Node<unsigned int>::GetType() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::GetType() const
Unexecuted instantiation: miniscript::Node<CPubKey>::GetType() const
1618
1619
    //! Return the script context for this node.
1620
0
    MiniscriptContext GetMsCtx() const { return m_script_ctx; }
1621
1622
    //! Find an insane subnode which has no insane children. Nullptr if there is none.
1623
0
    const Node* FindInsaneSub() const {
1624
0
        return TreeEval<const Node*>([](const Node& node, std::span<const Node*> subs) -> const Node* {
1625
0
            for (auto& sub: subs) if (sub) return sub;
  Branch (1625:27): [True: 0, False: 0]
  Branch (1625:39): [True: 0, False: 0]
1626
0
            if (!node.IsSaneSubexpression()) return &node;
  Branch (1626:17): [True: 0, False: 0]
1627
0
            return nullptr;
1628
0
        });
1629
0
    }
1630
1631
    //! Determine whether a Miniscript node is satisfiable. fn(node) will be invoked for all
1632
    //! key, time, and hashing nodes, and should return their satisfiability.
1633
    template<typename F>
1634
    bool IsSatisfiable(F fn) const
1635
    {
1636
        // TreeEval() doesn't support bool as NodeType, so use int instead.
1637
        return TreeEval<int>([&fn](const Node& node, std::span<int> subs) -> bool {
1638
            switch (node.fragment) {
1639
                case Fragment::JUST_0:
1640
                    return false;
1641
                case Fragment::JUST_1:
1642
                    return true;
1643
                case Fragment::PK_K:
1644
                case Fragment::PK_H:
1645
                case Fragment::MULTI:
1646
                case Fragment::MULTI_A:
1647
                case Fragment::AFTER:
1648
                case Fragment::OLDER:
1649
                case Fragment::HASH256:
1650
                case Fragment::HASH160:
1651
                case Fragment::SHA256:
1652
                case Fragment::RIPEMD160:
1653
                    return bool{fn(node)};
1654
                case Fragment::ANDOR:
1655
                    return (subs[0] && subs[1]) || subs[2];
1656
                case Fragment::AND_V:
1657
                case Fragment::AND_B:
1658
                    return subs[0] && subs[1];
1659
                case Fragment::OR_B:
1660
                case Fragment::OR_C:
1661
                case Fragment::OR_D:
1662
                case Fragment::OR_I:
1663
                    return subs[0] || subs[1];
1664
                case Fragment::THRESH:
1665
                    return static_cast<uint32_t>(std::count(subs.begin(), subs.end(), true)) >= node.k;
1666
                default: // wrappers
1667
                    assert(subs.size() >= 1);
1668
                    CHECK_NONFATAL(subs.size() == 1);
1669
                    return subs[0];
1670
            }
1671
        });
1672
    }
1673
1674
    //! Check whether this node is valid at all.
1675
0
    bool IsValid() const {
1676
0
        if (GetType() == ""_mst) return false;
  Branch (1676:13): [True: 0, False: 0]
  Branch (1676:13): [True: 0, False: 0]
  Branch (1676:13): [True: 0, False: 0]
1677
0
        return ScriptSize() <= internal::MaxScriptSize(m_script_ctx);
1678
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::IsValid() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::IsValid() const
Unexecuted instantiation: miniscript::Node<CPubKey>::IsValid() const
1679
1680
    //! Check whether this node is valid as a script on its own.
1681
0
    bool IsValidTopLevel() const { return IsValid() && GetType() << "B"_mst; }
Unexecuted instantiation: miniscript::Node<unsigned int>::IsValidTopLevel() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::IsValidTopLevel() const
Unexecuted instantiation: miniscript::Node<CPubKey>::IsValidTopLevel() const
  Branch (1681:43): [True: 0, False: 0]
  Branch (1681:56): [True: 0, False: 0]
  Branch (1681:43): [True: 0, False: 0]
  Branch (1681:56): [True: 0, False: 0]
  Branch (1681:43): [True: 0, False: 0]
  Branch (1681:56): [True: 0, False: 0]
1682
1683
    //! Check whether this script can always be satisfied in a non-malleable way.
1684
0
    bool IsNonMalleable() const { return GetType() << "m"_mst; }
1685
1686
    //! Check whether this script always needs a signature.
1687
0
    bool NeedsSignature() const { return GetType() << "s"_mst; }
1688
1689
    //! Check whether there is no satisfaction path that contains both timelocks and heightlocks
1690
0
    bool CheckTimeLocksMix() const { return GetType() << "k"_mst; }
1691
1692
    //! Check whether there is no duplicate key across this fragment and all its sub-fragments.
1693
0
    bool CheckDuplicateKey() const { return has_duplicate_keys && !*has_duplicate_keys; }
  Branch (1693:45): [True: 0, False: 0]
  Branch (1693:67): [True: 0, False: 0]
1694
1695
    //! Whether successful non-malleable satisfactions are guaranteed to be valid.
1696
0
    bool ValidSatisfactions() const { return IsValid() && CheckOpsLimit() && CheckStackSize(); }
  Branch (1696:46): [True: 0, False: 0]
  Branch (1696:59): [True: 0, False: 0]
  Branch (1696:78): [True: 0, False: 0]
1697
1698
    //! Whether the apparent policy of this node matches its script semantics. Doesn't guarantee it is a safe script on its own.
1699
0
    bool IsSaneSubexpression() const { return ValidSatisfactions() && IsNonMalleable() && CheckTimeLocksMix() && CheckDuplicateKey(); }
  Branch (1699:47): [True: 0, False: 0]
  Branch (1699:71): [True: 0, False: 0]
  Branch (1699:91): [True: 0, False: 0]
  Branch (1699:114): [True: 0, False: 0]
1700
1701
    //! Check whether this node is safe as a script on its own.
1702
0
    bool IsSane() const { return IsValidTopLevel() && IsSaneSubexpression() && NeedsSignature(); }
  Branch (1702:34): [True: 0, False: 0]
  Branch (1702:55): [True: 0, False: 0]
  Branch (1702:80): [True: 0, False: 0]
1703
1704
    //! Produce a witness for this script, if possible and given the information available in the context.
1705
    //! The non-malleable satisfaction is guaranteed to be valid if it exists, and ValidSatisfaction()
1706
    //! is true. If IsSane() holds, this satisfaction is guaranteed to succeed in case the node's
1707
    //! conditions are satisfied (private keys and hash preimages available, locktimes satisfied).
1708
    template<typename Ctx>
1709
0
    Availability Satisfy(const Ctx& ctx, std::vector<std::vector<unsigned char>>& stack, bool nonmalleable = true) const {
1710
0
        auto ret = ProduceInput(ctx);
1711
0
        if (nonmalleable && (ret.sat.malleable || !ret.sat.has_sig)) return Availability::NO;
  Branch (1711:13): [True: 0, False: 0]
  Branch (1711:30): [True: 0, False: 0]
  Branch (1711:51): [True: 0, False: 0]
  Branch (1711:13): [True: 0, False: 0]
  Branch (1711:30): [True: 0, False: 0]
  Branch (1711:51): [True: 0, False: 0]
1712
0
        stack = std::move(ret.sat.stack);
1713
0
        return ret.sat.available;
1714
0
    }
Unexecuted instantiation: miniscript::Availability miniscript::Node<XOnlyPubKey>::Satisfy<TapSatisfier>(TapSatisfier const&, std::vector<std::vector<unsigned char, std::allocator<unsigned char> >, std::allocator<std::vector<unsigned char, std::allocator<unsigned char> > > >&, bool) const
Unexecuted instantiation: miniscript::Availability miniscript::Node<CPubKey>::Satisfy<WshSatisfier>(WshSatisfier const&, std::vector<std::vector<unsigned char, std::allocator<unsigned char> >, std::allocator<std::vector<unsigned char, std::allocator<unsigned char> > > >&, bool) const
1715
1716
    //! Equality testing.
1717
    bool operator==(const Node<Key>& arg) const { return Compare(*this, arg) == 0; }
1718
1719
    // Constructors with various argument combinations, which bypass the duplicate key check.
1720
    Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, std::vector<Node> sub, std::vector<unsigned char> arg, uint32_t val = 0)
1721
        : fragment(nt), k(val), data(std::move(arg)), subs(std::move(sub)), m_script_ctx{script_ctx}, ops(CalcOps()), ss(CalcStackSize()), ws(CalcWitnessSize()), typ(CalcType()), scriptlen(CalcScriptLen()) {}
1722
    Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, std::vector<unsigned char> arg, uint32_t val = 0)
1723
0
        : fragment(nt), k(val), data(std::move(arg)), m_script_ctx{script_ctx}, ops(CalcOps()), ss(CalcStackSize()), ws(CalcWitnessSize()), typ(CalcType()), scriptlen(CalcScriptLen()) {}
Unexecuted instantiation: miniscript::Node<unsigned int>::Node(miniscript::internal::NoDupCheck, miniscript::MiniscriptContext, miniscript::Fragment, std::vector<unsigned char, std::allocator<unsigned char> >, unsigned int)
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::Node(miniscript::internal::NoDupCheck, miniscript::MiniscriptContext, miniscript::Fragment, std::vector<unsigned char, std::allocator<unsigned char> >, unsigned int)
Unexecuted instantiation: miniscript::Node<CPubKey>::Node(miniscript::internal::NoDupCheck, miniscript::MiniscriptContext, miniscript::Fragment, std::vector<unsigned char, std::allocator<unsigned char> >, unsigned int)
1724
    Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, std::vector<Node> sub, std::vector<Key> key, uint32_t val = 0)
1725
        : fragment(nt), k(val), keys(std::move(key)), m_script_ctx{script_ctx}, subs(std::move(sub)), ops(CalcOps()), ss(CalcStackSize()), ws(CalcWitnessSize()), typ(CalcType()), scriptlen(CalcScriptLen()) {}
1726
    Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, std::vector<Key> key, uint32_t val = 0)
1727
0
        : fragment(nt), k(val), keys(std::move(key)), m_script_ctx{script_ctx}, ops(CalcOps()), ss(CalcStackSize()), ws(CalcWitnessSize()), typ(CalcType()), scriptlen(CalcScriptLen()) {}
Unexecuted instantiation: miniscript::Node<unsigned int>::Node(miniscript::internal::NoDupCheck, miniscript::MiniscriptContext, miniscript::Fragment, std::vector<unsigned int, std::allocator<unsigned int> >, unsigned int)
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::Node(miniscript::internal::NoDupCheck, miniscript::MiniscriptContext, miniscript::Fragment, std::vector<XOnlyPubKey, std::allocator<XOnlyPubKey> >, unsigned int)
Unexecuted instantiation: miniscript::Node<CPubKey>::Node(miniscript::internal::NoDupCheck, miniscript::MiniscriptContext, miniscript::Fragment, std::vector<CPubKey, std::allocator<CPubKey> >, unsigned int)
1728
    Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, std::vector<Node> sub, uint32_t val = 0)
1729
0
        : fragment(nt), k(val), subs(std::move(sub)), m_script_ctx{script_ctx}, ops(CalcOps()), ss(CalcStackSize()), ws(CalcWitnessSize()), typ(CalcType()), scriptlen(CalcScriptLen()) {}
Unexecuted instantiation: miniscript::Node<unsigned int>::Node(miniscript::internal::NoDupCheck, miniscript::MiniscriptContext, miniscript::Fragment, std::vector<miniscript::Node<unsigned int>, std::allocator<miniscript::Node<unsigned int> > >, unsigned int)
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::Node(miniscript::internal::NoDupCheck, miniscript::MiniscriptContext, miniscript::Fragment, std::vector<miniscript::Node<XOnlyPubKey>, std::allocator<miniscript::Node<XOnlyPubKey> > >, unsigned int)
Unexecuted instantiation: miniscript::Node<CPubKey>::Node(miniscript::internal::NoDupCheck, miniscript::MiniscriptContext, miniscript::Fragment, std::vector<miniscript::Node<CPubKey>, std::allocator<miniscript::Node<CPubKey> > >, unsigned int)
1730
    Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, uint32_t val = 0)
1731
0
        : fragment(nt), k(val), m_script_ctx{script_ctx}, ops(CalcOps()), ss(CalcStackSize()), ws(CalcWitnessSize()), typ(CalcType()), scriptlen(CalcScriptLen()) {}
Unexecuted instantiation: miniscript::Node<unsigned int>::Node(miniscript::internal::NoDupCheck, miniscript::MiniscriptContext, miniscript::Fragment, unsigned int)
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::Node(miniscript::internal::NoDupCheck, miniscript::MiniscriptContext, miniscript::Fragment, unsigned int)
Unexecuted instantiation: miniscript::Node<CPubKey>::Node(miniscript::internal::NoDupCheck, miniscript::MiniscriptContext, miniscript::Fragment, unsigned int)
1732
1733
    // Constructors with various argument combinations, which do perform the duplicate key check.
1734
    template <typename Ctx> Node(const Ctx& ctx, enum Fragment nt, std::vector<Node> sub, std::vector<unsigned char> arg, uint32_t val = 0)
1735
        : Node(internal::NoDupCheck{}, ctx.MsContext(), nt, std::move(sub), std::move(arg), val) { DuplicateKeyCheck(ctx); }
1736
    template <typename Ctx> Node(const Ctx& ctx, enum Fragment nt, std::vector<unsigned char> arg, uint32_t val = 0)
1737
        : Node(internal::NoDupCheck{}, ctx.MsContext(), nt, std::move(arg), val) { DuplicateKeyCheck(ctx);}
1738
    template <typename Ctx> Node(const Ctx& ctx, enum Fragment nt, std::vector<Node> sub, std::vector<Key> key, uint32_t val = 0)
1739
        : Node(internal::NoDupCheck{}, ctx.MsContext(), nt, std::move(sub), std::move(key), val) { DuplicateKeyCheck(ctx); }
1740
    template <typename Ctx> Node(const Ctx& ctx, enum Fragment nt, std::vector<Key> key, uint32_t val = 0)
1741
        : Node(internal::NoDupCheck{}, ctx.MsContext(), nt, std::move(key), val) { DuplicateKeyCheck(ctx); }
1742
    template <typename Ctx> Node(const Ctx& ctx, enum Fragment nt, std::vector<Node> sub, uint32_t val = 0)
1743
        : Node(internal::NoDupCheck{}, ctx.MsContext(), nt, std::move(sub), val) { DuplicateKeyCheck(ctx); }
1744
    template <typename Ctx> Node(const Ctx& ctx, enum Fragment nt, uint32_t val = 0)
1745
        : Node(internal::NoDupCheck{}, ctx.MsContext(), nt, val) { DuplicateKeyCheck(ctx); }
1746
1747
    // Delete copy constructor and assignment operator, use Clone() instead
1748
    Node(const Node&) = delete;
1749
    Node& operator=(const Node&) = delete;
1750
1751
    // subs is movable, circumventing recursion, so these are permitted.
1752
0
    Node(Node&&) noexcept = default;
Unexecuted instantiation: miniscript::Node<unsigned int>::Node(miniscript::Node<unsigned int>&&)
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::Node(miniscript::Node<XOnlyPubKey>&&)
Unexecuted instantiation: miniscript::Node<CPubKey>::Node(miniscript::Node<CPubKey>&&)
1753
0
    Node& operator=(Node&&) noexcept = default;
Unexecuted instantiation: miniscript::Node<unsigned int>::operator=(miniscript::Node<unsigned int>&&)
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::operator=(miniscript::Node<XOnlyPubKey>&&)
Unexecuted instantiation: miniscript::Node<CPubKey>::operator=(miniscript::Node<CPubKey>&&)
1754
};
1755
1756
namespace internal {
1757
1758
enum class ParseContext {
1759
    /** An expression which may be begin with wrappers followed by a colon. */
1760
    WRAPPED_EXPR,
1761
    /** A miniscript expression which does not begin with wrappers. */
1762
    EXPR,
1763
1764
    /** SWAP wraps the top constructed node with s: */
1765
    SWAP,
1766
    /** ALT wraps the top constructed node with a: */
1767
    ALT,
1768
    /** CHECK wraps the top constructed node with c: */
1769
    CHECK,
1770
    /** DUP_IF wraps the top constructed node with d: */
1771
    DUP_IF,
1772
    /** VERIFY wraps the top constructed node with v: */
1773
    VERIFY,
1774
    /** NON_ZERO wraps the top constructed node with j: */
1775
    NON_ZERO,
1776
    /** ZERO_NOTEQUAL wraps the top constructed node with n: */
1777
    ZERO_NOTEQUAL,
1778
    /** WRAP_U will construct an or_i(X,0) node from the top constructed node. */
1779
    WRAP_U,
1780
    /** WRAP_T will construct an and_v(X,1) node from the top constructed node. */
1781
    WRAP_T,
1782
1783
    /** AND_N will construct an andor(X,Y,0) node from the last two constructed nodes. */
1784
    AND_N,
1785
    /** AND_V will construct an and_v node from the last two constructed nodes. */
1786
    AND_V,
1787
    /** AND_B will construct an and_b node from the last two constructed nodes. */
1788
    AND_B,
1789
    /** ANDOR will construct an andor node from the last three constructed nodes. */
1790
    ANDOR,
1791
    /** OR_B will construct an or_b node from the last two constructed nodes. */
1792
    OR_B,
1793
    /** OR_C will construct an or_c node from the last two constructed nodes. */
1794
    OR_C,
1795
    /** OR_D will construct an or_d node from the last two constructed nodes. */
1796
    OR_D,
1797
    /** OR_I will construct an or_i node from the last two constructed nodes. */
1798
    OR_I,
1799
1800
    /** THRESH will read a wrapped expression, and then look for a COMMA. If
1801
     * no comma follows, it will construct a thresh node from the appropriate
1802
     * number of constructed children. Otherwise, it will recurse with another
1803
     * THRESH. */
1804
    THRESH,
1805
1806
    /** COMMA expects the next element to be ',' and fails if not. */
1807
    COMMA,
1808
    /** CLOSE_BRACKET expects the next element to be ')' and fails if not. */
1809
    CLOSE_BRACKET,
1810
};
1811
1812
int FindNextChar(std::span<const char> in, char m);
1813
1814
/** Parse a key expression fully contained within a fragment with the name given by 'func' */
1815
template<typename Key, typename Ctx>
1816
std::optional<Key> ParseKey(const std::string& func, std::span<const char>& in, const Ctx& ctx)
1817
0
{
1818
0
    std::span<const char> expr = script::Expr(in);
1819
0
    if (!script::Func(func, expr)) return {};
  Branch (1819:9): [True: 0, False: 0]
1820
0
    return ctx.FromString(expr);
1821
0
}
1822
1823
/** Parse a hex string fully contained within a fragment with the name given by 'func' */
1824
template<typename Ctx>
1825
std::optional<std::vector<unsigned char>> ParseHexStr(const std::string& func, std::span<const char>& in, const size_t expected_size,
1826
                                                                         const Ctx& ctx)
1827
0
{
1828
0
    std::span<const char> expr = script::Expr(in);
1829
0
    if (!script::Func(func, expr)) return {};
  Branch (1829:9): [True: 0, False: 0]
1830
0
    std::string val = std::string(expr.begin(), expr.end());
1831
0
    if (!IsHex(val)) return {};
  Branch (1831:9): [True: 0, False: 0]
1832
0
    auto hash = ParseHex(val);
1833
0
    if (hash.size() != expected_size) return {};
  Branch (1833:9): [True: 0, False: 0]
1834
0
    return hash;
1835
0
}
1836
1837
/** BuildBack pops the last two elements off `constructed` and wraps them in the specified Fragment */
1838
template<typename Key>
1839
void BuildBack(const MiniscriptContext script_ctx, Fragment nt, std::vector<Node<Key>>& constructed, const bool reverse = false)
1840
0
{
1841
0
    Node<Key> child{std::move(constructed.back())};
1842
0
    constructed.pop_back();
1843
0
    if (reverse) {
  Branch (1843:9): [True: 0, False: 0]
  Branch (1843:9): [True: 0, False: 0]
  Branch (1843:9): [True: 0, False: 0]
1844
0
        constructed.back() = Node<Key>{internal::NoDupCheck{}, script_ctx, nt, Vector(std::move(child), std::move(constructed.back()))};
1845
0
    } else {
1846
0
        constructed.back() = Node<Key>{internal::NoDupCheck{}, script_ctx, nt, Vector(std::move(constructed.back()), std::move(child))};
1847
0
    }
1848
0
}
Unexecuted instantiation: void miniscript::internal::BuildBack<unsigned int>(miniscript::MiniscriptContext, miniscript::Fragment, std::vector<miniscript::Node<unsigned int>, std::allocator<miniscript::Node<unsigned int> > >&, bool)
Unexecuted instantiation: void miniscript::internal::BuildBack<XOnlyPubKey>(miniscript::MiniscriptContext, miniscript::Fragment, std::vector<miniscript::Node<XOnlyPubKey>, std::allocator<miniscript::Node<XOnlyPubKey> > >&, bool)
Unexecuted instantiation: void miniscript::internal::BuildBack<CPubKey>(miniscript::MiniscriptContext, miniscript::Fragment, std::vector<miniscript::Node<CPubKey>, std::allocator<miniscript::Node<CPubKey> > >&, bool)
1849
1850
/**
1851
 * Parse a miniscript from its textual descriptor form.
1852
 * This does not check whether the script is valid, let alone sane. The caller is expected to use
1853
 * the `IsValidTopLevel()` and `IsSaneTopLevel()` to check for these properties on the node.
1854
 */
1855
template <typename Key, typename Ctx>
1856
inline std::optional<Node<Key>> Parse(std::span<const char> in, const Ctx& ctx)
1857
0
{
1858
0
    using namespace script;
1859
1860
    // Account for the minimum script size for all parsed fragments so far. It "borrows" 1
1861
    // script byte from all leaf nodes, counting it instead whenever a space for a recursive
1862
    // expression is added (through andor, and_*, or_*, thresh). This guarantees that all fragments
1863
    // increment the script_size by at least one, except for:
1864
    // - "0", "1": these leafs are only a single byte, so their subtracted-from increment is 0.
1865
    //   This is not an issue however, as "space" for them has to be created by combinators,
1866
    //   which do increment script_size.
1867
    // - "v:": the v wrapper adds nothing as in some cases it results in no opcode being added
1868
    //   (instead transforming another opcode into its VERIFY form). However, the v: wrapper has
1869
    //   to be interleaved with other fragments to be valid, so this is not a concern.
1870
0
    size_t script_size{1};
1871
0
    size_t max_size{internal::MaxScriptSize(ctx.MsContext())};
1872
1873
    // The two integers are used to hold state for thresh()
1874
0
    std::vector<std::tuple<ParseContext, int64_t, int64_t>> to_parse;
1875
0
    std::vector<Node<Key>> constructed;
1876
1877
0
    to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
1878
1879
    // Parses a multi() or multi_a() from its string representation. Returns false on parsing error.
1880
0
    const auto parse_multi_exp = [&](std::span<const char>& in, const bool is_multi_a) -> bool {
1881
0
        const auto max_keys{is_multi_a ? MAX_PUBKEYS_PER_MULTI_A : MAX_PUBKEYS_PER_MULTISIG};
  Branch (1881:29): [True: 0, False: 0]
1882
0
        const auto required_ctx{is_multi_a ? MiniscriptContext::TAPSCRIPT : MiniscriptContext::P2WSH};
  Branch (1882:33): [True: 0, False: 0]
1883
0
        if (ctx.MsContext() != required_ctx) return false;
  Branch (1883:13): [True: 0, False: 0]
1884
        // Get threshold
1885
0
        int next_comma = FindNextChar(in, ',');
1886
0
        if (next_comma < 1) return false;
  Branch (1886:13): [True: 0, False: 0]
1887
0
        const auto k_to_integral{ToIntegral<int64_t>(std::string_view(in.data(), next_comma))};
1888
0
        if (!k_to_integral.has_value()) return false;
  Branch (1888:13): [True: 0, False: 0]
1889
0
        const int64_t k{k_to_integral.value()};
1890
0
        in = in.subspan(next_comma + 1);
1891
        // Get keys. It is compatible for both compressed and x-only keys.
1892
0
        std::vector<Key> keys;
1893
0
        while (next_comma != -1) {
  Branch (1893:16): [True: 0, False: 0]
1894
0
            next_comma = FindNextChar(in, ',');
1895
0
            int key_length = (next_comma == -1) ? FindNextChar(in, ')') : next_comma;
  Branch (1895:30): [True: 0, False: 0]
1896
0
            if (key_length < 1) return false;
  Branch (1896:17): [True: 0, False: 0]
1897
0
            std::span<const char> sp{in.begin(), in.begin() + key_length};
1898
0
            auto key = ctx.FromString(sp);
1899
0
            if (!key) return false;
  Branch (1899:17): [True: 0, False: 0]
1900
0
            keys.push_back(std::move(*key));
1901
0
            in = in.subspan(key_length + 1);
1902
0
        }
1903
0
        if (keys.size() < 1 || keys.size() > max_keys) return false;
  Branch (1903:13): [True: 0, False: 0]
  Branch (1903:32): [True: 0, False: 0]
1904
0
        if (k < 1 || k > (int64_t)keys.size()) return false;
  Branch (1904:13): [True: 0, False: 0]
  Branch (1904:22): [True: 0, False: 0]
1905
0
        if (is_multi_a) {
  Branch (1905:13): [True: 0, False: 0]
1906
            // (push + xonly-key + CHECKSIG[ADD]) * n + k + OP_NUMEQUAL(VERIFY), minus one.
1907
0
            script_size += (1 + 32 + 1) * keys.size() + BuildScript(k).size();
1908
0
            constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::MULTI_A, std::move(keys), k);
1909
0
        } else {
1910
0
            script_size += 2 + (keys.size() > 16) + (k > 16) + 34 * keys.size();
1911
0
            constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::MULTI, std::move(keys), k);
1912
0
        }
1913
0
        return true;
1914
0
    };
1915
1916
0
    while (!to_parse.empty()) {
  Branch (1916:12): [True: 0, False: 0]
1917
0
        if (script_size > max_size) return {};
  Branch (1917:13): [True: 0, False: 0]
1918
1919
        // Get the current context we are decoding within
1920
0
        auto [cur_context, n, k] = to_parse.back();
1921
0
        to_parse.pop_back();
1922
1923
0
        switch (cur_context) {
  Branch (1923:17): [True: 0, False: 0]
1924
0
        case ParseContext::WRAPPED_EXPR: {
  Branch (1924:9): [True: 0, False: 0]
1925
0
            std::optional<size_t> colon_index{};
1926
0
            for (size_t i = 1; i < in.size(); ++i) {
  Branch (1926:32): [True: 0, False: 0]
1927
0
                if (in[i] == ':') {
  Branch (1927:21): [True: 0, False: 0]
1928
0
                    colon_index = i;
1929
0
                    break;
1930
0
                }
1931
0
                if (in[i] < 'a' || in[i] > 'z') break;
  Branch (1931:21): [True: 0, False: 0]
  Branch (1931:36): [True: 0, False: 0]
1932
0
            }
1933
            // If there is no colon, this loop won't execute
1934
0
            bool last_was_v{false};
1935
0
            for (size_t j = 0; colon_index && j < *colon_index; ++j) {
  Branch (1935:32): [True: 0, False: 0]
  Branch (1935:47): [True: 0, False: 0]
1936
0
                if (script_size > max_size) return {};
  Branch (1936:21): [True: 0, False: 0]
1937
0
                if (in[j] == 'a') {
  Branch (1937:21): [True: 0, False: 0]
1938
0
                    script_size += 2;
1939
0
                    to_parse.emplace_back(ParseContext::ALT, -1, -1);
1940
0
                } else if (in[j] == 's') {
  Branch (1940:28): [True: 0, False: 0]
1941
0
                    script_size += 1;
1942
0
                    to_parse.emplace_back(ParseContext::SWAP, -1, -1);
1943
0
                } else if (in[j] == 'c') {
  Branch (1943:28): [True: 0, False: 0]
1944
0
                    script_size += 1;
1945
0
                    to_parse.emplace_back(ParseContext::CHECK, -1, -1);
1946
0
                } else if (in[j] == 'd') {
  Branch (1946:28): [True: 0, False: 0]
1947
0
                    script_size += 3;
1948
0
                    to_parse.emplace_back(ParseContext::DUP_IF, -1, -1);
1949
0
                } else if (in[j] == 'j') {
  Branch (1949:28): [True: 0, False: 0]
1950
0
                    script_size += 4;
1951
0
                    to_parse.emplace_back(ParseContext::NON_ZERO, -1, -1);
1952
0
                } else if (in[j] == 'n') {
  Branch (1952:28): [True: 0, False: 0]
1953
0
                    script_size += 1;
1954
0
                    to_parse.emplace_back(ParseContext::ZERO_NOTEQUAL, -1, -1);
1955
0
                } else if (in[j] == 'v') {
  Branch (1955:28): [True: 0, False: 0]
1956
                    // do not permit "...vv...:"; it's not valid, and also doesn't trigger early
1957
                    // failure as script_size isn't incremented.
1958
0
                    if (last_was_v) return {};
  Branch (1958:25): [True: 0, False: 0]
1959
0
                    to_parse.emplace_back(ParseContext::VERIFY, -1, -1);
1960
0
                } else if (in[j] == 'u') {
  Branch (1960:28): [True: 0, False: 0]
1961
0
                    script_size += 4;
1962
0
                    to_parse.emplace_back(ParseContext::WRAP_U, -1, -1);
1963
0
                } else if (in[j] == 't') {
  Branch (1963:28): [True: 0, False: 0]
1964
0
                    script_size += 1;
1965
0
                    to_parse.emplace_back(ParseContext::WRAP_T, -1, -1);
1966
0
                } else if (in[j] == 'l') {
  Branch (1966:28): [True: 0, False: 0]
1967
                    // The l: wrapper is equivalent to or_i(0,X)
1968
0
                    script_size += 4;
1969
0
                    constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::JUST_0);
1970
0
                    to_parse.emplace_back(ParseContext::OR_I, -1, -1);
1971
0
                } else {
1972
0
                    return {};
1973
0
                }
1974
0
                last_was_v = (in[j] == 'v');
1975
0
            }
1976
0
            to_parse.emplace_back(ParseContext::EXPR, -1, -1);
1977
0
            if (colon_index) in = in.subspan(*colon_index + 1);
  Branch (1977:17): [True: 0, False: 0]
1978
0
            break;
1979
0
        }
1980
0
        case ParseContext::EXPR: {
  Branch (1980:9): [True: 0, False: 0]
1981
0
            if (Const("0", in)) {
  Branch (1981:17): [True: 0, False: 0]
1982
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::JUST_0);
1983
0
            } else if (Const("1", in)) {
  Branch (1983:24): [True: 0, False: 0]
1984
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::JUST_1);
1985
0
            } else if (Const("pk(", in, /*skip=*/false)) {
  Branch (1985:24): [True: 0, False: 0]
1986
0
                std::optional<Key> key = ParseKey<Key, Ctx>("pk", in, ctx);
1987
0
                if (!key) return {};
  Branch (1987:21): [True: 0, False: 0]
1988
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_C, Vector(Node<Key>(internal::NoDupCheck{}, ctx.MsContext(), Fragment::PK_K, Vector(std::move(*key)))));
1989
0
                script_size += IsTapscript(ctx.MsContext()) ? 33 : 34;
  Branch (1989:32): [True: 0, False: 0]
1990
0
            } else if (Const("pkh(", in, /*skip=*/false)) {
  Branch (1990:24): [True: 0, False: 0]
1991
0
                std::optional<Key> key = ParseKey<Key, Ctx>("pkh", in, ctx);
1992
0
                if (!key) return {};
  Branch (1992:21): [True: 0, False: 0]
1993
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_C, Vector(Node<Key>(internal::NoDupCheck{}, ctx.MsContext(), Fragment::PK_H, Vector(std::move(*key)))));
1994
0
                script_size += 24;
1995
0
            } else if (Const("pk_k(", in, /*skip=*/false)) {
  Branch (1995:24): [True: 0, False: 0]
1996
0
                std::optional<Key> key = ParseKey<Key, Ctx>("pk_k", in, ctx);
1997
0
                if (!key) return {};
  Branch (1997:21): [True: 0, False: 0]
1998
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::PK_K, Vector(std::move(*key)));
1999
0
                script_size += IsTapscript(ctx.MsContext()) ? 32 : 33;
  Branch (1999:32): [True: 0, False: 0]
2000
0
            } else if (Const("pk_h(", in, /*skip=*/false)) {
  Branch (2000:24): [True: 0, False: 0]
2001
0
                std::optional<Key> key = ParseKey<Key, Ctx>("pk_h", in, ctx);
2002
0
                if (!key) return {};
  Branch (2002:21): [True: 0, False: 0]
2003
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::PK_H, Vector(std::move(*key)));
2004
0
                script_size += 23;
2005
0
            } else if (Const("sha256(", in, /*skip=*/false)) {
  Branch (2005:24): [True: 0, False: 0]
2006
0
                std::optional<std::vector<unsigned char>> hash = ParseHexStr("sha256", in, 32, ctx);
2007
0
                if (!hash) return {};
  Branch (2007:21): [True: 0, False: 0]
2008
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::SHA256, std::move(*hash));
2009
0
                script_size += 38;
2010
0
            } else if (Const("ripemd160(", in, /*skip=*/false)) {
  Branch (2010:24): [True: 0, False: 0]
2011
0
                std::optional<std::vector<unsigned char>> hash = ParseHexStr("ripemd160", in, 20, ctx);
2012
0
                if (!hash) return {};
  Branch (2012:21): [True: 0, False: 0]
2013
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::RIPEMD160, std::move(*hash));
2014
0
                script_size += 26;
2015
0
            } else if (Const("hash256(", in, /*skip=*/false)) {
  Branch (2015:24): [True: 0, False: 0]
2016
0
                std::optional<std::vector<unsigned char>> hash = ParseHexStr("hash256", in, 32, ctx);
2017
0
                if (!hash) return {};
  Branch (2017:21): [True: 0, False: 0]
2018
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::HASH256, std::move(*hash));
2019
0
                script_size += 38;
2020
0
            } else if (Const("hash160(", in, /*skip=*/false)) {
  Branch (2020:24): [True: 0, False: 0]
2021
0
                std::optional<std::vector<unsigned char>> hash = ParseHexStr("hash160", in, 20, ctx);
2022
0
                if (!hash) return {};
  Branch (2022:21): [True: 0, False: 0]
2023
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::HASH160, std::move(*hash));
2024
0
                script_size += 26;
2025
0
            } else if (Const("after(", in, /*skip=*/false)) {
  Branch (2025:24): [True: 0, False: 0]
2026
0
                auto expr = Expr(in);
2027
0
                if (!Func("after", expr)) return {};
  Branch (2027:21): [True: 0, False: 0]
2028
0
                const auto num{ToIntegral<int64_t>(std::string_view(expr.begin(), expr.end()))};
2029
0
                if (!num.has_value() || *num < 1 || *num >= 0x80000000L) return {};
  Branch (2029:21): [True: 0, False: 0]
  Branch (2029:41): [True: 0, False: 0]
  Branch (2029:53): [True: 0, False: 0]
2030
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::AFTER, *num);
2031
0
                script_size += 1 + (*num > 16) + (*num > 0x7f) + (*num > 0x7fff) + (*num > 0x7fffff);
2032
0
            } else if (Const("older(", in, /*skip=*/false)) {
  Branch (2032:24): [True: 0, False: 0]
2033
0
                auto expr = Expr(in);
2034
0
                if (!Func("older", expr)) return {};
  Branch (2034:21): [True: 0, False: 0]
2035
0
                const auto num{ToIntegral<int64_t>(std::string_view(expr.begin(), expr.end()))};
2036
0
                if (!num.has_value() || *num < 1 || *num >= 0x80000000L) return {};
  Branch (2036:21): [True: 0, False: 0]
  Branch (2036:41): [True: 0, False: 0]
  Branch (2036:53): [True: 0, False: 0]
2037
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::OLDER, *num);
2038
0
                script_size += 1 + (*num > 16) + (*num > 0x7f) + (*num > 0x7fff) + (*num > 0x7fffff);
2039
0
            } else if (Const("multi(", in)) {
  Branch (2039:24): [True: 0, False: 0]
2040
0
                if (!parse_multi_exp(in, /* is_multi_a = */false)) return {};
  Branch (2040:21): [True: 0, False: 0]
2041
0
            } else if (Const("multi_a(", in)) {
  Branch (2041:24): [True: 0, False: 0]
2042
0
                if (!parse_multi_exp(in, /* is_multi_a = */true)) return {};
  Branch (2042:21): [True: 0, False: 0]
2043
0
            } else if (Const("thresh(", in)) {
  Branch (2043:24): [True: 0, False: 0]
2044
0
                int next_comma = FindNextChar(in, ',');
2045
0
                if (next_comma < 1) return {};
  Branch (2045:21): [True: 0, False: 0]
2046
0
                const auto k{ToIntegral<int64_t>(std::string_view(in.data(), next_comma))};
2047
0
                if (!k.has_value() || *k < 1) return {};
  Branch (2047:21): [True: 0, False: 0]
  Branch (2047:39): [True: 0, False: 0]
2048
0
                in = in.subspan(next_comma + 1);
2049
                // n = 1 here because we read the first WRAPPED_EXPR before reaching THRESH
2050
0
                to_parse.emplace_back(ParseContext::THRESH, 1, *k);
2051
0
                to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
2052
0
                script_size += 2 + (*k > 16) + (*k > 0x7f) + (*k > 0x7fff) + (*k > 0x7fffff);
2053
0
            } else if (Const("andor(", in)) {
  Branch (2053:24): [True: 0, False: 0]
2054
0
                to_parse.emplace_back(ParseContext::ANDOR, -1, -1);
2055
0
                to_parse.emplace_back(ParseContext::CLOSE_BRACKET, -1, -1);
2056
0
                to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
2057
0
                to_parse.emplace_back(ParseContext::COMMA, -1, -1);
2058
0
                to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
2059
0
                to_parse.emplace_back(ParseContext::COMMA, -1, -1);
2060
0
                to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
2061
0
                script_size += 5;
2062
0
            } else {
2063
0
                if (Const("and_n(", in)) {
  Branch (2063:21): [True: 0, False: 0]
2064
0
                    to_parse.emplace_back(ParseContext::AND_N, -1, -1);
2065
0
                    script_size += 5;
2066
0
                } else if (Const("and_b(", in)) {
  Branch (2066:28): [True: 0, False: 0]
2067
0
                    to_parse.emplace_back(ParseContext::AND_B, -1, -1);
2068
0
                    script_size += 2;
2069
0
                } else if (Const("and_v(", in)) {
  Branch (2069:28): [True: 0, False: 0]
2070
0
                    to_parse.emplace_back(ParseContext::AND_V, -1, -1);
2071
0
                    script_size += 1;
2072
0
                } else if (Const("or_b(", in)) {
  Branch (2072:28): [True: 0, False: 0]
2073
0
                    to_parse.emplace_back(ParseContext::OR_B, -1, -1);
2074
0
                    script_size += 2;
2075
0
                } else if (Const("or_c(", in)) {
  Branch (2075:28): [True: 0, False: 0]
2076
0
                    to_parse.emplace_back(ParseContext::OR_C, -1, -1);
2077
0
                    script_size += 3;
2078
0
                } else if (Const("or_d(", in)) {
  Branch (2078:28): [True: 0, False: 0]
2079
0
                    to_parse.emplace_back(ParseContext::OR_D, -1, -1);
2080
0
                    script_size += 4;
2081
0
                } else if (Const("or_i(", in)) {
  Branch (2081:28): [True: 0, False: 0]
2082
0
                    to_parse.emplace_back(ParseContext::OR_I, -1, -1);
2083
0
                    script_size += 4;
2084
0
                } else {
2085
0
                    return {};
2086
0
                }
2087
0
                to_parse.emplace_back(ParseContext::CLOSE_BRACKET, -1, -1);
2088
0
                to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
2089
0
                to_parse.emplace_back(ParseContext::COMMA, -1, -1);
2090
0
                to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
2091
0
            }
2092
0
            break;
2093
0
        }
2094
0
        case ParseContext::ALT: {
  Branch (2094:9): [True: 0, False: 0]
2095
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_A, Vector(std::move(constructed.back()))};
2096
0
            break;
2097
0
        }
2098
0
        case ParseContext::SWAP: {
  Branch (2098:9): [True: 0, False: 0]
2099
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_S, Vector(std::move(constructed.back()))};
2100
0
            break;
2101
0
        }
2102
0
        case ParseContext::CHECK: {
  Branch (2102:9): [True: 0, False: 0]
2103
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_C, Vector(std::move(constructed.back()))};
2104
0
            break;
2105
0
        }
2106
0
        case ParseContext::DUP_IF: {
  Branch (2106:9): [True: 0, False: 0]
2107
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_D, Vector(std::move(constructed.back()))};
2108
0
            break;
2109
0
        }
2110
0
        case ParseContext::NON_ZERO: {
  Branch (2110:9): [True: 0, False: 0]
2111
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_J, Vector(std::move(constructed.back()))};
2112
0
            break;
2113
0
        }
2114
0
        case ParseContext::ZERO_NOTEQUAL: {
  Branch (2114:9): [True: 0, False: 0]
2115
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_N, Vector(std::move(constructed.back()))};
2116
0
            break;
2117
0
        }
2118
0
        case ParseContext::VERIFY: {
  Branch (2118:9): [True: 0, False: 0]
2119
0
            script_size += (constructed.back().GetType() << "x"_mst);
2120
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_V, Vector(std::move(constructed.back()))};
2121
0
            break;
2122
0
        }
2123
0
        case ParseContext::WRAP_U: {
  Branch (2123:9): [True: 0, False: 0]
2124
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::OR_I, Vector(std::move(constructed.back()), Node<Key>{internal::NoDupCheck{}, ctx.MsContext(), Fragment::JUST_0})};
2125
0
            break;
2126
0
        }
2127
0
        case ParseContext::WRAP_T: {
  Branch (2127:9): [True: 0, False: 0]
2128
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::AND_V, Vector(std::move(constructed.back()), Node<Key>{internal::NoDupCheck{}, ctx.MsContext(), Fragment::JUST_1})};
2129
0
            break;
2130
0
        }
2131
0
        case ParseContext::AND_B: {
  Branch (2131:9): [True: 0, False: 0]
2132
0
            BuildBack(ctx.MsContext(), Fragment::AND_B, constructed);
2133
0
            break;
2134
0
        }
2135
0
        case ParseContext::AND_N: {
  Branch (2135:9): [True: 0, False: 0]
2136
0
            auto mid = std::move(constructed.back());
2137
0
            constructed.pop_back();
2138
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::ANDOR, Vector(std::move(constructed.back()), std::move(mid), Node<Key>{internal::NoDupCheck{}, ctx.MsContext(), Fragment::JUST_0})};
2139
0
            break;
2140
0
        }
2141
0
        case ParseContext::AND_V: {
  Branch (2141:9): [True: 0, False: 0]
2142
0
            BuildBack(ctx.MsContext(), Fragment::AND_V, constructed);
2143
0
            break;
2144
0
        }
2145
0
        case ParseContext::OR_B: {
  Branch (2145:9): [True: 0, False: 0]
2146
0
            BuildBack(ctx.MsContext(), Fragment::OR_B, constructed);
2147
0
            break;
2148
0
        }
2149
0
        case ParseContext::OR_C: {
  Branch (2149:9): [True: 0, False: 0]
2150
0
            BuildBack(ctx.MsContext(), Fragment::OR_C, constructed);
2151
0
            break;
2152
0
        }
2153
0
        case ParseContext::OR_D: {
  Branch (2153:9): [True: 0, False: 0]
2154
0
            BuildBack(ctx.MsContext(), Fragment::OR_D, constructed);
2155
0
            break;
2156
0
        }
2157
0
        case ParseContext::OR_I: {
  Branch (2157:9): [True: 0, False: 0]
2158
0
            BuildBack(ctx.MsContext(), Fragment::OR_I, constructed);
2159
0
            break;
2160
0
        }
2161
0
        case ParseContext::ANDOR: {
  Branch (2161:9): [True: 0, False: 0]
2162
0
            auto right = std::move(constructed.back());
2163
0
            constructed.pop_back();
2164
0
            auto mid = std::move(constructed.back());
2165
0
            constructed.pop_back();
2166
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::ANDOR, Vector(std::move(constructed.back()), std::move(mid), std::move(right))};
2167
0
            break;
2168
0
        }
2169
0
        case ParseContext::THRESH: {
  Branch (2169:9): [True: 0, False: 0]
2170
0
            if (in.size() < 1) return {};
  Branch (2170:17): [True: 0, False: 0]
2171
0
            if (in[0] == ',') {
  Branch (2171:17): [True: 0, False: 0]
2172
0
                in = in.subspan(1);
2173
0
                to_parse.emplace_back(ParseContext::THRESH, n+1, k);
2174
0
                to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
2175
0
                script_size += 2;
2176
0
            } else if (in[0] == ')') {
  Branch (2176:24): [True: 0, False: 0]
2177
0
                if (k > n) return {};
  Branch (2177:21): [True: 0, False: 0]
2178
0
                in = in.subspan(1);
2179
                // Children are constructed in reverse order, so iterate from end to beginning
2180
0
                std::vector<Node<Key>> subs;
2181
0
                for (int i = 0; i < n; ++i) {
  Branch (2181:33): [True: 0, False: 0]
2182
0
                    subs.push_back(std::move(constructed.back()));
2183
0
                    constructed.pop_back();
2184
0
                }
2185
0
                std::reverse(subs.begin(), subs.end());
2186
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::THRESH, std::move(subs), k);
2187
0
            } else {
2188
0
                return {};
2189
0
            }
2190
0
            break;
2191
0
        }
2192
0
        case ParseContext::COMMA: {
  Branch (2192:9): [True: 0, False: 0]
2193
0
            if (in.size() < 1 || in[0] != ',') return {};
  Branch (2193:17): [True: 0, False: 0]
  Branch (2193:34): [True: 0, False: 0]
2194
0
            in = in.subspan(1);
2195
0
            break;
2196
0
        }
2197
0
        case ParseContext::CLOSE_BRACKET: {
  Branch (2197:9): [True: 0, False: 0]
2198
0
            if (in.size() < 1 || in[0] != ')') return {};
  Branch (2198:17): [True: 0, False: 0]
  Branch (2198:34): [True: 0, False: 0]
2199
0
            in = in.subspan(1);
2200
0
            break;
2201
0
        }
2202
0
        }
2203
0
    }
2204
2205
    // Sanity checks on the produced miniscript
2206
0
    assert(constructed.size() >= 1);
  Branch (2206:5): [True: 0, False: 0]
2207
0
    CHECK_NONFATAL(constructed.size() == 1);
2208
0
    assert(constructed[0].ScriptSize() == script_size);
  Branch (2208:5): [True: 0, False: 0]
2209
0
    if (in.size() > 0) return {};
  Branch (2209:9): [True: 0, False: 0]
2210
0
    Node<Key> tl_node{std::move(constructed.front())};
2211
0
    tl_node.DuplicateKeyCheck(ctx);
2212
0
    return tl_node;
2213
0
}
2214
2215
/** Decode a script into opcode/push pairs.
2216
 *
2217
 * Construct a vector with one element per opcode in the script, in reverse order.
2218
 * Each element is a pair consisting of the opcode, as well as the data pushed by
2219
 * the opcode (including OP_n), if any. OP_CHECKSIGVERIFY, OP_CHECKMULTISIGVERIFY,
2220
 * OP_NUMEQUALVERIFY and OP_EQUALVERIFY are decomposed into OP_CHECKSIG, OP_CHECKMULTISIG,
2221
 * OP_EQUAL and OP_NUMEQUAL respectively, plus OP_VERIFY.
2222
 */
2223
std::optional<std::vector<Opcode>> DecomposeScript(const CScript& script);
2224
2225
/** Determine whether the passed pair (created by DecomposeScript) is pushing a number. */
2226
std::optional<int64_t> ParseScriptNumber(const Opcode& in);
2227
2228
enum class DecodeContext {
2229
    /** A single expression of type B, K, or V. Specifically, this can't be an
2230
     * and_v or an expression of type W (a: and s: wrappers). */
2231
    SINGLE_BKV_EXPR,
2232
    /** Potentially multiple SINGLE_BKV_EXPRs as children of (potentially multiple)
2233
     * and_v expressions. Syntactic sugar for MAYBE_AND_V + SINGLE_BKV_EXPR. */
2234
    BKV_EXPR,
2235
    /** An expression of type W (a: or s: wrappers). */
2236
    W_EXPR,
2237
2238
    /** SWAP expects the next element to be OP_SWAP (inside a W-type expression that
2239
     * didn't end with FROMALTSTACK), and wraps the top of the constructed stack
2240
     * with s: */
2241
    SWAP,
2242
    /** ALT expects the next element to be TOALTSTACK (we must have already read a
2243
     * FROMALTSTACK earlier), and wraps the top of the constructed stack with a: */
2244
    ALT,
2245
    /** CHECK wraps the top constructed node with c: */
2246
    CHECK,
2247
    /** DUP_IF wraps the top constructed node with d: */
2248
    DUP_IF,
2249
    /** VERIFY wraps the top constructed node with v: */
2250
    VERIFY,
2251
    /** NON_ZERO wraps the top constructed node with j: */
2252
    NON_ZERO,
2253
    /** ZERO_NOTEQUAL wraps the top constructed node with n: */
2254
    ZERO_NOTEQUAL,
2255
2256
    /** MAYBE_AND_V will check if the next part of the script could be a valid
2257
     * miniscript sub-expression, and if so it will push AND_V and SINGLE_BKV_EXPR
2258
     * to decode it and construct the and_v node. This is recursive, to deal with
2259
     * multiple and_v nodes inside each other. */
2260
    MAYBE_AND_V,
2261
    /** AND_V will construct an and_v node from the last two constructed nodes. */
2262
    AND_V,
2263
    /** AND_B will construct an and_b node from the last two constructed nodes. */
2264
    AND_B,
2265
    /** ANDOR will construct an andor node from the last three constructed nodes. */
2266
    ANDOR,
2267
    /** OR_B will construct an or_b node from the last two constructed nodes. */
2268
    OR_B,
2269
    /** OR_C will construct an or_c node from the last two constructed nodes. */
2270
    OR_C,
2271
    /** OR_D will construct an or_d node from the last two constructed nodes. */
2272
    OR_D,
2273
2274
    /** In a thresh expression, all sub-expressions other than the first are W-type,
2275
     * and end in OP_ADD. THRESH_W will check for this OP_ADD and either push a W_EXPR
2276
     * or a SINGLE_BKV_EXPR and jump to THRESH_E accordingly. */
2277
    THRESH_W,
2278
    /** THRESH_E constructs a thresh node from the appropriate number of constructed
2279
     * children. */
2280
    THRESH_E,
2281
2282
    /** ENDIF signals that we are inside some sort of OP_IF structure, which could be
2283
     * or_d, or_c, or_i, andor, d:, or j: wrapper, depending on what follows. We read
2284
     * a BKV_EXPR and then deal with the next opcode case-by-case. */
2285
    ENDIF,
2286
    /** If, inside an ENDIF context, we find an OP_NOTIF before finding an OP_ELSE,
2287
     * we could either be in an or_d or an or_c node. We then check for IFDUP to
2288
     * distinguish these cases. */
2289
    ENDIF_NOTIF,
2290
    /** If, inside an ENDIF context, we find an OP_ELSE, then we could be in either an
2291
     * or_i or an andor node. Read the next BKV_EXPR and find either an OP_IF or an
2292
     * OP_NOTIF. */
2293
    ENDIF_ELSE,
2294
};
2295
2296
//! Parse a miniscript from a bitcoin script
2297
template <typename Key, typename Ctx, typename I>
2298
inline std::optional<Node<Key>> DecodeScript(I& in, I last, const Ctx& ctx)
2299
0
{
2300
    // The two integers are used to hold state for thresh()
2301
0
    std::vector<std::tuple<DecodeContext, int64_t, int64_t>> to_parse;
2302
0
    std::vector<Node<Key>> constructed;
2303
2304
    // This is the top level, so we assume the type is B
2305
    // (in particular, disallowing top level W expressions)
2306
0
    to_parse.emplace_back(DecodeContext::BKV_EXPR, -1, -1);
2307
2308
0
    while (!to_parse.empty()) {
  Branch (2308:12): [True: 0, False: 0]
  Branch (2308:12): [True: 0, False: 0]
  Branch (2308:12): [True: 0, False: 0]
2309
        // Exit early if the Miniscript is not going to be valid.
2310
0
        if (!constructed.empty() && !constructed.back().IsValid()) return {};
  Branch (2310:13): [True: 0, False: 0]
  Branch (2310:37): [True: 0, False: 0]
  Branch (2310:13): [True: 0, False: 0]
  Branch (2310:37): [True: 0, False: 0]
  Branch (2310:13): [True: 0, False: 0]
  Branch (2310:37): [True: 0, False: 0]
2311
2312
        // Get the current context we are decoding within
2313
0
        auto [cur_context, n, k] = to_parse.back();
2314
0
        to_parse.pop_back();
2315
2316
0
        switch(cur_context) {
  Branch (2316:16): [True: 0, False: 0]
  Branch (2316:16): [True: 0, False: 0]
  Branch (2316:16): [True: 0, False: 0]
2317
0
        case DecodeContext::SINGLE_BKV_EXPR: {
  Branch (2317:9): [True: 0, False: 0]
  Branch (2317:9): [True: 0, False: 0]
  Branch (2317:9): [True: 0, False: 0]
2318
0
            if (in >= last) return {};
  Branch (2318:17): [True: 0, False: 0]
  Branch (2318:17): [True: 0, False: 0]
  Branch (2318:17): [True: 0, False: 0]
2319
2320
            // Constants
2321
0
            if (in[0].first == OP_1) {
  Branch (2321:17): [True: 0, False: 0]
  Branch (2321:17): [True: 0, False: 0]
  Branch (2321:17): [True: 0, False: 0]
2322
0
                ++in;
2323
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::JUST_1);
2324
0
                break;
2325
0
            }
2326
0
            if (in[0].first == OP_0) {
  Branch (2326:17): [True: 0, False: 0]
  Branch (2326:17): [True: 0, False: 0]
  Branch (2326:17): [True: 0, False: 0]
2327
0
                ++in;
2328
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::JUST_0);
2329
0
                break;
2330
0
            }
2331
            // Public keys
2332
0
            if (in[0].second.size() == 33 || in[0].second.size() == 32) {
  Branch (2332:17): [True: 0, False: 0]
  Branch (2332:46): [True: 0, False: 0]
  Branch (2332:17): [True: 0, False: 0]
  Branch (2332:46): [True: 0, False: 0]
  Branch (2332:17): [True: 0, False: 0]
  Branch (2332:46): [True: 0, False: 0]
2333
0
                auto key = ctx.FromPKBytes(in[0].second.begin(), in[0].second.end());
2334
0
                if (!key) return {};
  Branch (2334:21): [True: 0, False: 0]
  Branch (2334:21): [True: 0, False: 0]
  Branch (2334:21): [True: 0, False: 0]
2335
0
                ++in;
2336
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::PK_K, Vector(std::move(*key)));
2337
0
                break;
2338
0
            }
2339
0
            if (last - in >= 5 && in[0].first == OP_VERIFY && in[1].first == OP_EQUAL && in[3].first == OP_HASH160 && in[4].first == OP_DUP && in[2].second.size() == 20) {
  Branch (2339:17): [True: 0, False: 0]
  Branch (2339:35): [True: 0, False: 0]
  Branch (2339:63): [True: 0, False: 0]
  Branch (2339:90): [True: 0, False: 0]
  Branch (2339:119): [True: 0, False: 0]
  Branch (2339:144): [True: 0, False: 0]
  Branch (2339:17): [True: 0, False: 0]
  Branch (2339:35): [True: 0, False: 0]
  Branch (2339:63): [True: 0, False: 0]
  Branch (2339:90): [True: 0, False: 0]
  Branch (2339:119): [True: 0, False: 0]
  Branch (2339:144): [True: 0, False: 0]
  Branch (2339:17): [True: 0, False: 0]
  Branch (2339:35): [True: 0, False: 0]
  Branch (2339:63): [True: 0, False: 0]
  Branch (2339:90): [True: 0, False: 0]
  Branch (2339:119): [True: 0, False: 0]
  Branch (2339:144): [True: 0, False: 0]
2340
0
                auto key = ctx.FromPKHBytes(in[2].second.begin(), in[2].second.end());
2341
0
                if (!key) return {};
  Branch (2341:21): [True: 0, False: 0]
  Branch (2341:21): [True: 0, False: 0]
  Branch (2341:21): [True: 0, False: 0]
2342
0
                in += 5;
2343
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::PK_H, Vector(std::move(*key)));
2344
0
                break;
2345
0
            }
2346
            // Time locks
2347
0
            std::optional<int64_t> num;
2348
0
            if (last - in >= 2 && in[0].first == OP_CHECKSEQUENCEVERIFY && (num = ParseScriptNumber(in[1]))) {
  Branch (2348:17): [True: 0, False: 0]
  Branch (2348:17): [True: 0, False: 0]
  Branch (2348:35): [True: 0, False: 0]
  Branch (2348:76): [True: 0, False: 0]
  Branch (2348:17): [True: 0, False: 0]
  Branch (2348:17): [True: 0, False: 0]
  Branch (2348:35): [True: 0, False: 0]
  Branch (2348:76): [True: 0, False: 0]
  Branch (2348:17): [True: 0, False: 0]
  Branch (2348:17): [True: 0, False: 0]
  Branch (2348:35): [True: 0, False: 0]
  Branch (2348:76): [True: 0, False: 0]
2349
0
                in += 2;
2350
0
                if (*num < 1 || *num > 0x7FFFFFFFL) return {};
  Branch (2350:21): [True: 0, False: 0]
  Branch (2350:33): [True: 0, False: 0]
  Branch (2350:21): [True: 0, False: 0]
  Branch (2350:33): [True: 0, False: 0]
  Branch (2350:21): [True: 0, False: 0]
  Branch (2350:33): [True: 0, False: 0]
2351
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::OLDER, *num);
2352
0
                break;
2353
0
            }
2354
0
            if (last - in >= 2 && in[0].first == OP_CHECKLOCKTIMEVERIFY && (num = ParseScriptNumber(in[1]))) {
  Branch (2354:17): [True: 0, False: 0]
  Branch (2354:17): [True: 0, False: 0]
  Branch (2354:35): [True: 0, False: 0]
  Branch (2354:76): [True: 0, False: 0]
  Branch (2354:17): [True: 0, False: 0]
  Branch (2354:17): [True: 0, False: 0]
  Branch (2354:35): [True: 0, False: 0]
  Branch (2354:76): [True: 0, False: 0]
  Branch (2354:17): [True: 0, False: 0]
  Branch (2354:17): [True: 0, False: 0]
  Branch (2354:35): [True: 0, False: 0]
  Branch (2354:76): [True: 0, False: 0]
2355
0
                in += 2;
2356
0
                if (num < 1 || num > 0x7FFFFFFFL) return {};
  Branch (2356:21): [True: 0, False: 0]
  Branch (2356:21): [True: 0, False: 0]
  Branch (2356:32): [True: 0, False: 0]
  Branch (2356:21): [True: 0, False: 0]
  Branch (2356:21): [True: 0, False: 0]
  Branch (2356:32): [True: 0, False: 0]
  Branch (2356:21): [True: 0, False: 0]
  Branch (2356:21): [True: 0, False: 0]
  Branch (2356:32): [True: 0, False: 0]
2357
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::AFTER, *num);
2358
0
                break;
2359
0
            }
2360
            // Hashes
2361
0
            if (last - in >= 7 && in[0].first == OP_EQUAL && in[3].first == OP_VERIFY && in[4].first == OP_EQUAL && (num = ParseScriptNumber(in[5])) && num == 32 && in[6].first == OP_SIZE) {
  Branch (2361:17): [True: 0, False: 0]
  Branch (2361:17): [True: 0, False: 0]
  Branch (2361:35): [True: 0, False: 0]
  Branch (2361:62): [True: 0, False: 0]
  Branch (2361:90): [True: 0, False: 0]
  Branch (2361:117): [True: 0, False: 0]
  Branch (2361:153): [True: 0, False: 0]
  Branch (2361:166): [True: 0, False: 0]
  Branch (2361:17): [True: 0, False: 0]
  Branch (2361:17): [True: 0, False: 0]
  Branch (2361:35): [True: 0, False: 0]
  Branch (2361:62): [True: 0, False: 0]
  Branch (2361:90): [True: 0, False: 0]
  Branch (2361:117): [True: 0, False: 0]
  Branch (2361:153): [True: 0, False: 0]
  Branch (2361:166): [True: 0, False: 0]
  Branch (2361:17): [True: 0, False: 0]
  Branch (2361:17): [True: 0, False: 0]
  Branch (2361:35): [True: 0, False: 0]
  Branch (2361:62): [True: 0, False: 0]
  Branch (2361:90): [True: 0, False: 0]
  Branch (2361:117): [True: 0, False: 0]
  Branch (2361:153): [True: 0, False: 0]
  Branch (2361:166): [True: 0, False: 0]
2362
0
                if (in[2].first == OP_SHA256 && in[1].second.size() == 32) {
  Branch (2362:21): [True: 0, False: 0]
  Branch (2362:49): [True: 0, False: 0]
  Branch (2362:21): [True: 0, False: 0]
  Branch (2362:49): [True: 0, False: 0]
  Branch (2362:21): [True: 0, False: 0]
  Branch (2362:49): [True: 0, False: 0]
2363
0
                    constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::SHA256, in[1].second);
2364
0
                    in += 7;
2365
0
                    break;
2366
0
                } else if (in[2].first == OP_RIPEMD160 && in[1].second.size() == 20) {
  Branch (2366:28): [True: 0, False: 0]
  Branch (2366:59): [True: 0, False: 0]
  Branch (2366:28): [True: 0, False: 0]
  Branch (2366:59): [True: 0, False: 0]
  Branch (2366:28): [True: 0, False: 0]
  Branch (2366:59): [True: 0, False: 0]
2367
0
                    constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::RIPEMD160, in[1].second);
2368
0
                    in += 7;
2369
0
                    break;
2370
0
                } else if (in[2].first == OP_HASH256 && in[1].second.size() == 32) {
  Branch (2370:28): [True: 0, False: 0]
  Branch (2370:57): [True: 0, False: 0]
  Branch (2370:28): [True: 0, False: 0]
  Branch (2370:57): [True: 0, False: 0]
  Branch (2370:28): [True: 0, False: 0]
  Branch (2370:57): [True: 0, False: 0]
2371
0
                    constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::HASH256, in[1].second);
2372
0
                    in += 7;
2373
0
                    break;
2374
0
                } else if (in[2].first == OP_HASH160 && in[1].second.size() == 20) {
  Branch (2374:28): [True: 0, False: 0]
  Branch (2374:57): [True: 0, False: 0]
  Branch (2374:28): [True: 0, False: 0]
  Branch (2374:57): [True: 0, False: 0]
  Branch (2374:28): [True: 0, False: 0]
  Branch (2374:57): [True: 0, False: 0]
2375
0
                    constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::HASH160, in[1].second);
2376
0
                    in += 7;
2377
0
                    break;
2378
0
                }
2379
0
            }
2380
            // Multi
2381
0
            if (last - in >= 3 && in[0].first == OP_CHECKMULTISIG) {
  Branch (2381:17): [True: 0, False: 0]
  Branch (2381:35): [True: 0, False: 0]
  Branch (2381:17): [True: 0, False: 0]
  Branch (2381:35): [True: 0, False: 0]
  Branch (2381:17): [True: 0, False: 0]
  Branch (2381:35): [True: 0, False: 0]
2382
0
                if (IsTapscript(ctx.MsContext())) return {};
  Branch (2382:21): [True: 0, False: 0]
  Branch (2382:21): [True: 0, False: 0]
  Branch (2382:21): [True: 0, False: 0]
2383
0
                std::vector<Key> keys;
2384
0
                const auto n = ParseScriptNumber(in[1]);
2385
0
                if (!n || last - in < 3 + *n) return {};
  Branch (2385:21): [True: 0, False: 0]
  Branch (2385:27): [True: 0, False: 0]
  Branch (2385:21): [True: 0, False: 0]
  Branch (2385:27): [True: 0, False: 0]
  Branch (2385:21): [True: 0, False: 0]
  Branch (2385:27): [True: 0, False: 0]
2386
0
                if (*n < 1 || *n > 20) return {};
  Branch (2386:21): [True: 0, False: 0]
  Branch (2386:31): [True: 0, False: 0]
  Branch (2386:21): [True: 0, False: 0]
  Branch (2386:31): [True: 0, False: 0]
  Branch (2386:21): [True: 0, False: 0]
  Branch (2386:31): [True: 0, False: 0]
2387
0
                for (int i = 0; i < *n; ++i) {
  Branch (2387:33): [True: 0, False: 0]
  Branch (2387:33): [True: 0, False: 0]
  Branch (2387:33): [True: 0, False: 0]
2388
0
                    if (in[2 + i].second.size() != 33) return {};
  Branch (2388:25): [True: 0, False: 0]
  Branch (2388:25): [True: 0, False: 0]
  Branch (2388:25): [True: 0, False: 0]
2389
0
                    auto key = ctx.FromPKBytes(in[2 + i].second.begin(), in[2 + i].second.end());
2390
0
                    if (!key) return {};
  Branch (2390:25): [True: 0, False: 0]
  Branch (2390:25): [True: 0, False: 0]
  Branch (2390:25): [True: 0, False: 0]
2391
0
                    keys.push_back(std::move(*key));
2392
0
                }
2393
0
                const auto k = ParseScriptNumber(in[2 + *n]);
2394
0
                if (!k || *k < 1 || *k > *n) return {};
  Branch (2394:21): [True: 0, False: 0]
  Branch (2394:27): [True: 0, False: 0]
  Branch (2394:37): [True: 0, False: 0]
  Branch (2394:21): [True: 0, False: 0]
  Branch (2394:27): [True: 0, False: 0]
  Branch (2394:37): [True: 0, False: 0]
  Branch (2394:21): [True: 0, False: 0]
  Branch (2394:27): [True: 0, False: 0]
  Branch (2394:37): [True: 0, False: 0]
2395
0
                in += 3 + *n;
2396
0
                std::reverse(keys.begin(), keys.end());
2397
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::MULTI, std::move(keys), *k);
2398
0
                break;
2399
0
            }
2400
            // Tapscript's equivalent of multi
2401
0
            if (last - in >= 4 && in[0].first == OP_NUMEQUAL) {
  Branch (2401:17): [True: 0, False: 0]
  Branch (2401:35): [True: 0, False: 0]
  Branch (2401:17): [True: 0, False: 0]
  Branch (2401:35): [True: 0, False: 0]
  Branch (2401:17): [True: 0, False: 0]
  Branch (2401:35): [True: 0, False: 0]
2402
0
                if (!IsTapscript(ctx.MsContext())) return {};
  Branch (2402:21): [True: 0, False: 0]
  Branch (2402:21): [True: 0, False: 0]
  Branch (2402:21): [True: 0, False: 0]
2403
                // The necessary threshold of signatures.
2404
0
                const auto k = ParseScriptNumber(in[1]);
2405
0
                if (!k) return {};
  Branch (2405:21): [True: 0, False: 0]
  Branch (2405:21): [True: 0, False: 0]
  Branch (2405:21): [True: 0, False: 0]
2406
0
                if (*k < 1 || *k > MAX_PUBKEYS_PER_MULTI_A) return {};
  Branch (2406:21): [True: 0, False: 0]
  Branch (2406:31): [True: 0, False: 0]
  Branch (2406:21): [True: 0, False: 0]
  Branch (2406:31): [True: 0, False: 0]
  Branch (2406:21): [True: 0, False: 0]
  Branch (2406:31): [True: 0, False: 0]
2407
0
                if (last - in < 2 + *k * 2) return {};
  Branch (2407:21): [True: 0, False: 0]
  Branch (2407:21): [True: 0, False: 0]
  Branch (2407:21): [True: 0, False: 0]
2408
0
                std::vector<Key> keys;
2409
0
                keys.reserve(*k);
2410
                // Walk through the expected (pubkey, CHECKSIG[ADD]) pairs.
2411
0
                for (int pos = 2;; pos += 2) {
2412
0
                    if (last - in < pos + 2) return {};
  Branch (2412:25): [True: 0, False: 0]
  Branch (2412:25): [True: 0, False: 0]
  Branch (2412:25): [True: 0, False: 0]
2413
                    // Make sure it's indeed an x-only pubkey and a CHECKSIG[ADD], then parse the key.
2414
0
                    if (in[pos].first != OP_CHECKSIGADD && in[pos].first != OP_CHECKSIG) return {};
  Branch (2414:25): [True: 0, False: 0]
  Branch (2414:60): [True: 0, False: 0]
  Branch (2414:25): [True: 0, False: 0]
  Branch (2414:60): [True: 0, False: 0]
  Branch (2414:25): [True: 0, False: 0]
  Branch (2414:60): [True: 0, False: 0]
2415
0
                    if (in[pos + 1].second.size() != 32) return {};
  Branch (2415:25): [True: 0, False: 0]
  Branch (2415:25): [True: 0, False: 0]
  Branch (2415:25): [True: 0, False: 0]
2416
0
                    auto key = ctx.FromPKBytes(in[pos + 1].second.begin(), in[pos + 1].second.end());
2417
0
                    if (!key) return {};
  Branch (2417:25): [True: 0, False: 0]
  Branch (2417:25): [True: 0, False: 0]
  Branch (2417:25): [True: 0, False: 0]
2418
0
                    keys.push_back(std::move(*key));
2419
                    // Make sure early we don't parse an arbitrary large expression.
2420
0
                    if (keys.size() > MAX_PUBKEYS_PER_MULTI_A) return {};
  Branch (2420:25): [True: 0, False: 0]
  Branch (2420:25): [True: 0, False: 0]
  Branch (2420:25): [True: 0, False: 0]
2421
                    // OP_CHECKSIG means it was the last one to parse.
2422
0
                    if (in[pos].first == OP_CHECKSIG) break;
  Branch (2422:25): [True: 0, False: 0]
  Branch (2422:25): [True: 0, False: 0]
  Branch (2422:25): [True: 0, False: 0]
2423
0
                }
2424
0
                if (keys.size() < (size_t)*k) return {};
  Branch (2424:21): [True: 0, False: 0]
  Branch (2424:21): [True: 0, False: 0]
  Branch (2424:21): [True: 0, False: 0]
2425
0
                in += 2 + keys.size() * 2;
2426
0
                std::reverse(keys.begin(), keys.end());
2427
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::MULTI_A, std::move(keys), *k);
2428
0
                break;
2429
0
            }
2430
            /** In the following wrappers, we only need to push SINGLE_BKV_EXPR rather
2431
             * than BKV_EXPR, because and_v commutes with these wrappers. For example,
2432
             * c:and_v(X,Y) produces the same script as and_v(X,c:Y). */
2433
            // c: wrapper
2434
0
            if (in[0].first == OP_CHECKSIG) {
  Branch (2434:17): [True: 0, False: 0]
  Branch (2434:17): [True: 0, False: 0]
  Branch (2434:17): [True: 0, False: 0]
2435
0
                ++in;
2436
0
                to_parse.emplace_back(DecodeContext::CHECK, -1, -1);
2437
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2438
0
                break;
2439
0
            }
2440
            // v: wrapper
2441
0
            if (in[0].first == OP_VERIFY) {
  Branch (2441:17): [True: 0, False: 0]
  Branch (2441:17): [True: 0, False: 0]
  Branch (2441:17): [True: 0, False: 0]
2442
0
                ++in;
2443
0
                to_parse.emplace_back(DecodeContext::VERIFY, -1, -1);
2444
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2445
0
                break;
2446
0
            }
2447
            // n: wrapper
2448
0
            if (in[0].first == OP_0NOTEQUAL) {
  Branch (2448:17): [True: 0, False: 0]
  Branch (2448:17): [True: 0, False: 0]
  Branch (2448:17): [True: 0, False: 0]
2449
0
                ++in;
2450
0
                to_parse.emplace_back(DecodeContext::ZERO_NOTEQUAL, -1, -1);
2451
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2452
0
                break;
2453
0
            }
2454
            // Thresh
2455
0
            if (last - in >= 3 && in[0].first == OP_EQUAL && (num = ParseScriptNumber(in[1]))) {
  Branch (2455:17): [True: 0, False: 0]
  Branch (2455:17): [True: 0, False: 0]
  Branch (2455:35): [True: 0, False: 0]
  Branch (2455:62): [True: 0, False: 0]
  Branch (2455:17): [True: 0, False: 0]
  Branch (2455:17): [True: 0, False: 0]
  Branch (2455:35): [True: 0, False: 0]
  Branch (2455:62): [True: 0, False: 0]
  Branch (2455:17): [True: 0, False: 0]
  Branch (2455:17): [True: 0, False: 0]
  Branch (2455:35): [True: 0, False: 0]
  Branch (2455:62): [True: 0, False: 0]
2456
0
                if (*num < 1) return {};
  Branch (2456:21): [True: 0, False: 0]
  Branch (2456:21): [True: 0, False: 0]
  Branch (2456:21): [True: 0, False: 0]
2457
0
                in += 2;
2458
0
                to_parse.emplace_back(DecodeContext::THRESH_W, 0, *num);
2459
0
                break;
2460
0
            }
2461
            // OP_ENDIF can be WRAP_J, WRAP_D, ANDOR, OR_C, OR_D, or OR_I
2462
0
            if (in[0].first == OP_ENDIF) {
  Branch (2462:17): [True: 0, False: 0]
  Branch (2462:17): [True: 0, False: 0]
  Branch (2462:17): [True: 0, False: 0]
2463
0
                ++in;
2464
0
                to_parse.emplace_back(DecodeContext::ENDIF, -1, -1);
2465
0
                to_parse.emplace_back(DecodeContext::BKV_EXPR, -1, -1);
2466
0
                break;
2467
0
            }
2468
            /** In and_b and or_b nodes, we only look for SINGLE_BKV_EXPR, because
2469
             * or_b(and_v(X,Y),Z) has script [X] [Y] [Z] OP_BOOLOR, the same as
2470
             * and_v(X,or_b(Y,Z)). In this example, the former of these is invalid as
2471
             * miniscript, while the latter is valid. So we leave the and_v "outside"
2472
             * while decoding. */
2473
            // and_b
2474
0
            if (in[0].first == OP_BOOLAND) {
  Branch (2474:17): [True: 0, False: 0]
  Branch (2474:17): [True: 0, False: 0]
  Branch (2474:17): [True: 0, False: 0]
2475
0
                ++in;
2476
0
                to_parse.emplace_back(DecodeContext::AND_B, -1, -1);
2477
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2478
0
                to_parse.emplace_back(DecodeContext::W_EXPR, -1, -1);
2479
0
                break;
2480
0
            }
2481
            // or_b
2482
0
            if (in[0].first == OP_BOOLOR) {
  Branch (2482:17): [True: 0, False: 0]
  Branch (2482:17): [True: 0, False: 0]
  Branch (2482:17): [True: 0, False: 0]
2483
0
                ++in;
2484
0
                to_parse.emplace_back(DecodeContext::OR_B, -1, -1);
2485
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2486
0
                to_parse.emplace_back(DecodeContext::W_EXPR, -1, -1);
2487
0
                break;
2488
0
            }
2489
            // Unrecognised expression
2490
0
            return {};
2491
0
        }
2492
0
        case DecodeContext::BKV_EXPR: {
  Branch (2492:9): [True: 0, False: 0]
  Branch (2492:9): [True: 0, False: 0]
  Branch (2492:9): [True: 0, False: 0]
2493
0
            to_parse.emplace_back(DecodeContext::MAYBE_AND_V, -1, -1);
2494
0
            to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2495
0
            break;
2496
0
        }
2497
0
        case DecodeContext::W_EXPR: {
  Branch (2497:9): [True: 0, False: 0]
  Branch (2497:9): [True: 0, False: 0]
  Branch (2497:9): [True: 0, False: 0]
2498
            // a: wrapper
2499
0
            if (in >= last) return {};
  Branch (2499:17): [True: 0, False: 0]
  Branch (2499:17): [True: 0, False: 0]
  Branch (2499:17): [True: 0, False: 0]
2500
0
            if (in[0].first == OP_FROMALTSTACK) {
  Branch (2500:17): [True: 0, False: 0]
  Branch (2500:17): [True: 0, False: 0]
  Branch (2500:17): [True: 0, False: 0]
2501
0
                ++in;
2502
0
                to_parse.emplace_back(DecodeContext::ALT, -1, -1);
2503
0
            } else {
2504
0
                to_parse.emplace_back(DecodeContext::SWAP, -1, -1);
2505
0
            }
2506
0
            to_parse.emplace_back(DecodeContext::BKV_EXPR, -1, -1);
2507
0
            break;
2508
0
        }
2509
0
        case DecodeContext::MAYBE_AND_V: {
  Branch (2509:9): [True: 0, False: 0]
  Branch (2509:9): [True: 0, False: 0]
  Branch (2509:9): [True: 0, False: 0]
2510
            // If we reach a potential AND_V top-level, check if the next part of the script could be another AND_V child
2511
            // These op-codes cannot end any well-formed miniscript so cannot be used in an and_v node.
2512
0
            if (in < last && in[0].first != OP_IF && in[0].first != OP_ELSE && in[0].first != OP_NOTIF && in[0].first != OP_TOALTSTACK && in[0].first != OP_SWAP) {
  Branch (2512:17): [True: 0, False: 0]
  Branch (2512:30): [True: 0, False: 0]
  Branch (2512:54): [True: 0, False: 0]
  Branch (2512:80): [True: 0, False: 0]
  Branch (2512:107): [True: 0, False: 0]
  Branch (2512:139): [True: 0, False: 0]
  Branch (2512:17): [True: 0, False: 0]
  Branch (2512:30): [True: 0, False: 0]
  Branch (2512:54): [True: 0, False: 0]
  Branch (2512:80): [True: 0, False: 0]
  Branch (2512:107): [True: 0, False: 0]
  Branch (2512:139): [True: 0, False: 0]
  Branch (2512:17): [True: 0, False: 0]
  Branch (2512:30): [True: 0, False: 0]
  Branch (2512:54): [True: 0, False: 0]
  Branch (2512:80): [True: 0, False: 0]
  Branch (2512:107): [True: 0, False: 0]
  Branch (2512:139): [True: 0, False: 0]
2513
0
                to_parse.emplace_back(DecodeContext::AND_V, -1, -1);
2514
                // BKV_EXPR can contain more AND_V nodes
2515
0
                to_parse.emplace_back(DecodeContext::BKV_EXPR, -1, -1);
2516
0
            }
2517
0
            break;
2518
0
        }
2519
0
        case DecodeContext::SWAP: {
  Branch (2519:9): [True: 0, False: 0]
  Branch (2519:9): [True: 0, False: 0]
  Branch (2519:9): [True: 0, False: 0]
2520
0
            if (in >= last || in[0].first != OP_SWAP || constructed.empty()) return {};
  Branch (2520:17): [True: 0, False: 0]
  Branch (2520:31): [True: 0, False: 0]
  Branch (2520:57): [True: 0, False: 0]
  Branch (2520:17): [True: 0, False: 0]
  Branch (2520:31): [True: 0, False: 0]
  Branch (2520:57): [True: 0, False: 0]
  Branch (2520:17): [True: 0, False: 0]
  Branch (2520:31): [True: 0, False: 0]
  Branch (2520:57): [True: 0, False: 0]
2521
0
            ++in;
2522
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_S, Vector(std::move(constructed.back()))};
2523
0
            break;
2524
0
        }
2525
0
        case DecodeContext::ALT: {
  Branch (2525:9): [True: 0, False: 0]
  Branch (2525:9): [True: 0, False: 0]
  Branch (2525:9): [True: 0, False: 0]
2526
0
            if (in >= last || in[0].first != OP_TOALTSTACK || constructed.empty()) return {};
  Branch (2526:17): [True: 0, False: 0]
  Branch (2526:31): [True: 0, False: 0]
  Branch (2526:63): [True: 0, False: 0]
  Branch (2526:17): [True: 0, False: 0]
  Branch (2526:31): [True: 0, False: 0]
  Branch (2526:63): [True: 0, False: 0]
  Branch (2526:17): [True: 0, False: 0]
  Branch (2526:31): [True: 0, False: 0]
  Branch (2526:63): [True: 0, False: 0]
2527
0
            ++in;
2528
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_A, Vector(std::move(constructed.back()))};
2529
0
            break;
2530
0
        }
2531
0
        case DecodeContext::CHECK: {
  Branch (2531:9): [True: 0, False: 0]
  Branch (2531:9): [True: 0, False: 0]
  Branch (2531:9): [True: 0, False: 0]
2532
0
            if (constructed.empty()) return {};
  Branch (2532:17): [True: 0, False: 0]
  Branch (2532:17): [True: 0, False: 0]
  Branch (2532:17): [True: 0, False: 0]
2533
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_C, Vector(std::move(constructed.back()))};
2534
0
            break;
2535
0
        }
2536
0
        case DecodeContext::DUP_IF: {
  Branch (2536:9): [True: 0, False: 0]
  Branch (2536:9): [True: 0, False: 0]
  Branch (2536:9): [True: 0, False: 0]
2537
0
            if (constructed.empty()) return {};
  Branch (2537:17): [True: 0, False: 0]
  Branch (2537:17): [True: 0, False: 0]
  Branch (2537:17): [True: 0, False: 0]
2538
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_D, Vector(std::move(constructed.back()))};
2539
0
            break;
2540
0
        }
2541
0
        case DecodeContext::VERIFY: {
  Branch (2541:9): [True: 0, False: 0]
  Branch (2541:9): [True: 0, False: 0]
  Branch (2541:9): [True: 0, False: 0]
2542
0
            if (constructed.empty()) return {};
  Branch (2542:17): [True: 0, False: 0]
  Branch (2542:17): [True: 0, False: 0]
  Branch (2542:17): [True: 0, False: 0]
2543
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_V, Vector(std::move(constructed.back()))};
2544
0
            break;
2545
0
        }
2546
0
        case DecodeContext::NON_ZERO: {
  Branch (2546:9): [True: 0, False: 0]
  Branch (2546:9): [True: 0, False: 0]
  Branch (2546:9): [True: 0, False: 0]
2547
0
            if (constructed.empty()) return {};
  Branch (2547:17): [True: 0, False: 0]
  Branch (2547:17): [True: 0, False: 0]
  Branch (2547:17): [True: 0, False: 0]
2548
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_J, Vector(std::move(constructed.back()))};
2549
0
            break;
2550
0
        }
2551
0
        case DecodeContext::ZERO_NOTEQUAL: {
  Branch (2551:9): [True: 0, False: 0]
  Branch (2551:9): [True: 0, False: 0]
  Branch (2551:9): [True: 0, False: 0]
2552
0
            if (constructed.empty()) return {};
  Branch (2552:17): [True: 0, False: 0]
  Branch (2552:17): [True: 0, False: 0]
  Branch (2552:17): [True: 0, False: 0]
2553
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_N, Vector(std::move(constructed.back()))};
2554
0
            break;
2555
0
        }
2556
0
        case DecodeContext::AND_V: {
  Branch (2556:9): [True: 0, False: 0]
  Branch (2556:9): [True: 0, False: 0]
  Branch (2556:9): [True: 0, False: 0]
2557
0
            if (constructed.size() < 2) return {};
  Branch (2557:17): [True: 0, False: 0]
  Branch (2557:17): [True: 0, False: 0]
  Branch (2557:17): [True: 0, False: 0]
2558
0
            BuildBack(ctx.MsContext(), Fragment::AND_V, constructed, /*reverse=*/true);
2559
0
            break;
2560
0
        }
2561
0
        case DecodeContext::AND_B: {
  Branch (2561:9): [True: 0, False: 0]
  Branch (2561:9): [True: 0, False: 0]
  Branch (2561:9): [True: 0, False: 0]
2562
0
            if (constructed.size() < 2) return {};
  Branch (2562:17): [True: 0, False: 0]
  Branch (2562:17): [True: 0, False: 0]
  Branch (2562:17): [True: 0, False: 0]
2563
0
            BuildBack(ctx.MsContext(), Fragment::AND_B, constructed, /*reverse=*/true);
2564
0
            break;
2565
0
        }
2566
0
        case DecodeContext::OR_B: {
  Branch (2566:9): [True: 0, False: 0]
  Branch (2566:9): [True: 0, False: 0]
  Branch (2566:9): [True: 0, False: 0]
2567
0
            if (constructed.size() < 2) return {};
  Branch (2567:17): [True: 0, False: 0]
  Branch (2567:17): [True: 0, False: 0]
  Branch (2567:17): [True: 0, False: 0]
2568
0
            BuildBack(ctx.MsContext(), Fragment::OR_B, constructed, /*reverse=*/true);
2569
0
            break;
2570
0
        }
2571
0
        case DecodeContext::OR_C: {
  Branch (2571:9): [True: 0, False: 0]
  Branch (2571:9): [True: 0, False: 0]
  Branch (2571:9): [True: 0, False: 0]
2572
0
            if (constructed.size() < 2) return {};
  Branch (2572:17): [True: 0, False: 0]
  Branch (2572:17): [True: 0, False: 0]
  Branch (2572:17): [True: 0, False: 0]
2573
0
            BuildBack(ctx.MsContext(), Fragment::OR_C, constructed, /*reverse=*/true);
2574
0
            break;
2575
0
        }
2576
0
        case DecodeContext::OR_D: {
  Branch (2576:9): [True: 0, False: 0]
  Branch (2576:9): [True: 0, False: 0]
  Branch (2576:9): [True: 0, False: 0]
2577
0
            if (constructed.size() < 2) return {};
  Branch (2577:17): [True: 0, False: 0]
  Branch (2577:17): [True: 0, False: 0]
  Branch (2577:17): [True: 0, False: 0]
2578
0
            BuildBack(ctx.MsContext(), Fragment::OR_D, constructed, /*reverse=*/true);
2579
0
            break;
2580
0
        }
2581
0
        case DecodeContext::ANDOR: {
  Branch (2581:9): [True: 0, False: 0]
  Branch (2581:9): [True: 0, False: 0]
  Branch (2581:9): [True: 0, False: 0]
2582
0
            if (constructed.size() < 3) return {};
  Branch (2582:17): [True: 0, False: 0]
  Branch (2582:17): [True: 0, False: 0]
  Branch (2582:17): [True: 0, False: 0]
2583
0
            Node left{std::move(constructed.back())};
2584
0
            constructed.pop_back();
2585
0
            Node right{std::move(constructed.back())};
2586
0
            constructed.pop_back();
2587
0
            Node mid{std::move(constructed.back())};
2588
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::ANDOR, Vector(std::move(left), std::move(mid), std::move(right))};
2589
0
            break;
2590
0
        }
2591
0
        case DecodeContext::THRESH_W: {
  Branch (2591:9): [True: 0, False: 0]
  Branch (2591:9): [True: 0, False: 0]
  Branch (2591:9): [True: 0, False: 0]
2592
0
            if (in >= last) return {};
  Branch (2592:17): [True: 0, False: 0]
  Branch (2592:17): [True: 0, False: 0]
  Branch (2592:17): [True: 0, False: 0]
2593
0
            if (in[0].first == OP_ADD) {
  Branch (2593:17): [True: 0, False: 0]
  Branch (2593:17): [True: 0, False: 0]
  Branch (2593:17): [True: 0, False: 0]
2594
0
                ++in;
2595
0
                to_parse.emplace_back(DecodeContext::THRESH_W, n+1, k);
2596
0
                to_parse.emplace_back(DecodeContext::W_EXPR, -1, -1);
2597
0
            } else {
2598
0
                to_parse.emplace_back(DecodeContext::THRESH_E, n+1, k);
2599
                // All children of thresh have type modifier d, so cannot be and_v
2600
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2601
0
            }
2602
0
            break;
2603
0
        }
2604
0
        case DecodeContext::THRESH_E: {
  Branch (2604:9): [True: 0, False: 0]
  Branch (2604:9): [True: 0, False: 0]
  Branch (2604:9): [True: 0, False: 0]
2605
0
            if (k < 1 || k > n || constructed.size() < static_cast<size_t>(n)) return {};
  Branch (2605:17): [True: 0, False: 0]
  Branch (2605:26): [True: 0, False: 0]
  Branch (2605:35): [True: 0, False: 0]
  Branch (2605:17): [True: 0, False: 0]
  Branch (2605:26): [True: 0, False: 0]
  Branch (2605:35): [True: 0, False: 0]
  Branch (2605:17): [True: 0, False: 0]
  Branch (2605:26): [True: 0, False: 0]
  Branch (2605:35): [True: 0, False: 0]
2606
0
            std::vector<Node<Key>> subs;
2607
0
            for (int i = 0; i < n; ++i) {
  Branch (2607:29): [True: 0, False: 0]
  Branch (2607:29): [True: 0, False: 0]
  Branch (2607:29): [True: 0, False: 0]
2608
0
                Node sub{std::move(constructed.back())};
2609
0
                constructed.pop_back();
2610
0
                subs.push_back(std::move(sub));
2611
0
            }
2612
0
            constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::THRESH, std::move(subs), k);
2613
0
            break;
2614
0
        }
2615
0
        case DecodeContext::ENDIF: {
  Branch (2615:9): [True: 0, False: 0]
  Branch (2615:9): [True: 0, False: 0]
  Branch (2615:9): [True: 0, False: 0]
2616
0
            if (in >= last) return {};
  Branch (2616:17): [True: 0, False: 0]
  Branch (2616:17): [True: 0, False: 0]
  Branch (2616:17): [True: 0, False: 0]
2617
2618
            // could be andor or or_i
2619
0
            if (in[0].first == OP_ELSE) {
  Branch (2619:17): [True: 0, False: 0]
  Branch (2619:17): [True: 0, False: 0]
  Branch (2619:17): [True: 0, False: 0]
2620
0
                ++in;
2621
0
                to_parse.emplace_back(DecodeContext::ENDIF_ELSE, -1, -1);
2622
0
                to_parse.emplace_back(DecodeContext::BKV_EXPR, -1, -1);
2623
0
            }
2624
            // could be j: or d: wrapper
2625
0
            else if (in[0].first == OP_IF) {
  Branch (2625:22): [True: 0, False: 0]
  Branch (2625:22): [True: 0, False: 0]
  Branch (2625:22): [True: 0, False: 0]
2626
0
                if (last - in >= 2 && in[1].first == OP_DUP) {
  Branch (2626:21): [True: 0, False: 0]
  Branch (2626:39): [True: 0, False: 0]
  Branch (2626:21): [True: 0, False: 0]
  Branch (2626:39): [True: 0, False: 0]
  Branch (2626:21): [True: 0, False: 0]
  Branch (2626:39): [True: 0, False: 0]
2627
0
                    in += 2;
2628
0
                    to_parse.emplace_back(DecodeContext::DUP_IF, -1, -1);
2629
0
                } else if (last - in >= 3 && in[1].first == OP_0NOTEQUAL && in[2].first == OP_SIZE) {
  Branch (2629:28): [True: 0, False: 0]
  Branch (2629:46): [True: 0, False: 0]
  Branch (2629:77): [True: 0, False: 0]
  Branch (2629:28): [True: 0, False: 0]
  Branch (2629:46): [True: 0, False: 0]
  Branch (2629:77): [True: 0, False: 0]
  Branch (2629:28): [True: 0, False: 0]
  Branch (2629:46): [True: 0, False: 0]
  Branch (2629:77): [True: 0, False: 0]
2630
0
                    in += 3;
2631
0
                    to_parse.emplace_back(DecodeContext::NON_ZERO, -1, -1);
2632
0
                }
2633
0
                else {
2634
0
                    return {};
2635
0
                }
2636
            // could be or_c or or_d
2637
0
            } else if (in[0].first == OP_NOTIF) {
  Branch (2637:24): [True: 0, False: 0]
  Branch (2637:24): [True: 0, False: 0]
  Branch (2637:24): [True: 0, False: 0]
2638
0
                ++in;
2639
0
                to_parse.emplace_back(DecodeContext::ENDIF_NOTIF, -1, -1);
2640
0
            }
2641
0
            else {
2642
0
                return {};
2643
0
            }
2644
0
            break;
2645
0
        }
2646
0
        case DecodeContext::ENDIF_NOTIF: {
  Branch (2646:9): [True: 0, False: 0]
  Branch (2646:9): [True: 0, False: 0]
  Branch (2646:9): [True: 0, False: 0]
2647
0
            if (in >= last) return {};
  Branch (2647:17): [True: 0, False: 0]
  Branch (2647:17): [True: 0, False: 0]
  Branch (2647:17): [True: 0, False: 0]
2648
0
            if (in[0].first == OP_IFDUP) {
  Branch (2648:17): [True: 0, False: 0]
  Branch (2648:17): [True: 0, False: 0]
  Branch (2648:17): [True: 0, False: 0]
2649
0
                ++in;
2650
0
                to_parse.emplace_back(DecodeContext::OR_D, -1, -1);
2651
0
            } else {
2652
0
                to_parse.emplace_back(DecodeContext::OR_C, -1, -1);
2653
0
            }
2654
            // or_c and or_d both require X to have type modifier d so, can't contain and_v
2655
0
            to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2656
0
            break;
2657
0
        }
2658
0
        case DecodeContext::ENDIF_ELSE: {
  Branch (2658:9): [True: 0, False: 0]
  Branch (2658:9): [True: 0, False: 0]
  Branch (2658:9): [True: 0, False: 0]
2659
0
            if (in >= last) return {};
  Branch (2659:17): [True: 0, False: 0]
  Branch (2659:17): [True: 0, False: 0]
  Branch (2659:17): [True: 0, False: 0]
2660
0
            if (in[0].first == OP_IF) {
  Branch (2660:17): [True: 0, False: 0]
  Branch (2660:17): [True: 0, False: 0]
  Branch (2660:17): [True: 0, False: 0]
2661
0
                ++in;
2662
0
                BuildBack(ctx.MsContext(), Fragment::OR_I, constructed, /*reverse=*/true);
2663
0
            } else if (in[0].first == OP_NOTIF) {
  Branch (2663:24): [True: 0, False: 0]
  Branch (2663:24): [True: 0, False: 0]
  Branch (2663:24): [True: 0, False: 0]
2664
0
                ++in;
2665
0
                to_parse.emplace_back(DecodeContext::ANDOR, -1, -1);
2666
                // andor requires X to have type modifier d, so it can't be and_v
2667
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2668
0
            } else {
2669
0
                return {};
2670
0
            }
2671
0
            break;
2672
0
        }
2673
0
        }
2674
0
    }
2675
0
    if (constructed.size() != 1) return {};
  Branch (2675:9): [True: 0, False: 0]
  Branch (2675:9): [True: 0, False: 0]
  Branch (2675:9): [True: 0, False: 0]
2676
0
    Node tl_node{std::move(constructed.front())};
2677
0
    tl_node.DuplicateKeyCheck(ctx);
2678
    // Note that due to how ComputeType works (only assign the type to the node if the
2679
    // subs' types are valid) this would fail if any node of tree is badly typed.
2680
0
    if (!tl_node.IsValidTopLevel()) return {};
  Branch (2680:9): [True: 0, False: 0]
  Branch (2680:9): [True: 0, False: 0]
  Branch (2680:9): [True: 0, False: 0]
2681
0
    return tl_node;
2682
0
}
Unexecuted instantiation: descriptor.cpp:std::optional<miniscript::Node<unsigned int> > miniscript::internal::DecodeScript<unsigned int, (anonymous namespace)::KeyParser, __gnu_cxx::__normal_iterator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >*, std::vector<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >, std::allocator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > > > > > >(__gnu_cxx::__normal_iterator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >*, std::vector<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >, std::allocator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > > > > >&, __gnu_cxx::__normal_iterator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >*, std::vector<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >, std::allocator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > > > > >, (anonymous namespace)::KeyParser const&)
Unexecuted instantiation: std::optional<miniscript::Node<XOnlyPubKey> > miniscript::internal::DecodeScript<XOnlyPubKey, TapSatisfier, __gnu_cxx::__normal_iterator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >*, std::vector<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >, std::allocator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > > > > > >(__gnu_cxx::__normal_iterator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >*, std::vector<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >, std::allocator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > > > > >&, __gnu_cxx::__normal_iterator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >*, std::vector<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >, std::allocator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > > > > >, TapSatisfier const&)
Unexecuted instantiation: std::optional<miniscript::Node<CPubKey> > miniscript::internal::DecodeScript<CPubKey, WshSatisfier, __gnu_cxx::__normal_iterator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >*, std::vector<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >, std::allocator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > > > > > >(__gnu_cxx::__normal_iterator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >*, std::vector<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >, std::allocator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > > > > >&, __gnu_cxx::__normal_iterator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >*, std::vector<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > >, std::allocator<std::pair<opcodetype, std::vector<unsigned char, std::allocator<unsigned char> > > > > >, WshSatisfier const&)
2683
2684
} // namespace internal
2685
2686
template <typename Ctx>
2687
inline std::optional<Node<typename Ctx::Key>> FromString(const std::string& str, const Ctx& ctx)
2688
0
{
2689
0
    return internal::Parse<typename Ctx::Key>(str, ctx);
2690
0
}
2691
2692
template <typename Ctx>
2693
inline std::optional<Node<typename Ctx::Key>> FromScript(const CScript& script, const Ctx& ctx)
2694
0
{
2695
0
    using namespace internal;
2696
    // A too large Script is necessarily invalid, don't bother parsing it.
2697
0
    if (script.size() > MaxScriptSize(ctx.MsContext())) return {};
  Branch (2697:9): [True: 0, False: 0]
  Branch (2697:9): [True: 0, False: 0]
  Branch (2697:9): [True: 0, False: 0]
2698
0
    auto decomposed = DecomposeScript(script);
2699
0
    if (!decomposed) return {};
  Branch (2699:9): [True: 0, False: 0]
  Branch (2699:9): [True: 0, False: 0]
  Branch (2699:9): [True: 0, False: 0]
2700
0
    auto it = decomposed->begin();
2701
0
    auto ret = DecodeScript<typename Ctx::Key>(it, decomposed->end(), ctx);
2702
0
    if (!ret) return {};
  Branch (2702:9): [True: 0, False: 0]
  Branch (2702:9): [True: 0, False: 0]
  Branch (2702:9): [True: 0, False: 0]
2703
0
    if (it != decomposed->end()) return {};
  Branch (2703:9): [True: 0, False: 0]
  Branch (2703:9): [True: 0, False: 0]
  Branch (2703:9): [True: 0, False: 0]
2704
0
    return ret;
2705
0
}
Unexecuted instantiation: descriptor.cpp:std::optional<miniscript::Node<(anonymous namespace)::KeyParser::Key> > miniscript::FromScript<(anonymous namespace)::KeyParser>(CScript const&, (anonymous namespace)::KeyParser const&)
Unexecuted instantiation: std::optional<miniscript::Node<TapSatisfier::Key> > miniscript::FromScript<TapSatisfier>(CScript const&, TapSatisfier const&)
Unexecuted instantiation: std::optional<miniscript::Node<WshSatisfier::Key> > miniscript::FromScript<WshSatisfier>(CScript const&, WshSatisfier const&)
2706
2707
} // namespace miniscript
2708
2709
#endif // BITCOIN_SCRIPT_MINISCRIPT_H