Coverage Report

Created: 2026-06-01 18:35

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 <algorithm>
9
#include <compare>
10
#include <concepts>
11
#include <cstdint>
12
#include <cstdlib>
13
#include <functional>
14
#include <iterator>
15
#include <memory>
16
#include <optional>
17
#include <set>
18
#include <stdexcept>
19
#include <tuple>
20
#include <utility>
21
#include <vector>
22
23
#include <consensus/consensus.h>
24
#include <policy/policy.h>
25
#include <script/interpreter.h>
26
#include <script/parsing.h>
27
#include <script/script.h>
28
#include <serialize.h>
29
#include <span.h>
30
#include <util/check.h>
31
#include <util/strencodings.h>
32
#include <util/string.h>
33
#include <util/vector.h>
34
35
namespace miniscript {
36
37
/** This type encapsulates the miniscript type system properties.
38
 *
39
 * Every miniscript expression is one of 4 basic types, and additionally has
40
 * a number of boolean type properties.
41
 *
42
 * The basic types are:
43
 * - "B" Base:
44
 *   - Takes its inputs from the top of the stack.
45
 *   - When satisfied, pushes a nonzero value of up to 4 bytes onto the stack.
46
 *   - When dissatisfied, pushes a 0 onto the stack.
47
 *   - This is used for most expressions, and required for the top level one.
48
 *   - For example: older(n) = <n> OP_CHECKSEQUENCEVERIFY.
49
 * - "V" Verify:
50
 *   - Takes its inputs from the top of the stack.
51
 *   - When satisfied, pushes nothing.
52
 *   - Cannot be dissatisfied.
53
 *   - This can be obtained by adding an OP_VERIFY to a B, modifying the last opcode
54
 *     of a B to its -VERIFY version (only for OP_CHECKSIG, OP_CHECKSIGVERIFY,
55
 *     OP_NUMEQUAL and OP_EQUAL), or by combining a V fragment under some conditions.
56
 *   - For example vc:pk_k(key) = <key> OP_CHECKSIGVERIFY
57
 * - "K" Key:
58
 *   - Takes its inputs from the top of the stack.
59
 *   - Becomes a B when followed by OP_CHECKSIG.
60
 *   - Always pushes a public key onto the stack, for which a signature is to be
61
 *     provided to satisfy the expression.
62
 *   - For example pk_h(key) = OP_DUP OP_HASH160 <Hash160(key)> OP_EQUALVERIFY
63
 * - "W" Wrapped:
64
 *   - Takes its input from one below the top of the stack.
65
 *   - When satisfied, pushes a nonzero value (like B) on top of the stack, or one below.
66
 *   - When dissatisfied, pushes 0 op top of the stack or one below.
67
 *   - Is always "OP_SWAP [B]" or "OP_TOALTSTACK [B] OP_FROMALTSTACK".
68
 *   - For example sc:pk_k(key) = OP_SWAP <key> OP_CHECKSIG
69
 *
70
 * There are type properties that help reasoning about correctness:
71
 * - "z" Zero-arg:
72
 *   - Is known to always consume exactly 0 stack elements.
73
 *   - For example after(n) = <n> OP_CHECKLOCKTIMEVERIFY
74
 * - "o" One-arg:
75
 *   - Is known to always consume exactly 1 stack element.
76
 *   - Conflicts with property 'z'
77
 *   - For example sha256(hash) = OP_SIZE 32 OP_EQUALVERIFY OP_SHA256 <hash> OP_EQUAL
78
 * - "n" Nonzero:
79
 *   - For every way this expression can be satisfied, a satisfaction exists that never needs
80
 *     a zero top stack element.
81
 *   - Conflicts with property 'z' and with type 'W'.
82
 * - "d" Dissatisfiable:
83
 *   - There is an easy way to construct a dissatisfaction for this expression.
84
 *   - Conflicts with type 'V'.
85
 * - "u" Unit:
86
 *   - In case of satisfaction, an exact 1 is put on the stack (rather than just nonzero).
87
 *   - Conflicts with type 'V'.
88
 *
89
 * Additional type properties help reasoning about nonmalleability:
90
 * - "e" Expression:
91
 *   - This implies property 'd', but the dissatisfaction is nonmalleable.
92
 *   - This generally requires 'e' for all subexpressions which are invoked for that
93
 *     dissatisfaction, and property 'f' for the unexecuted subexpressions in that case.
94
 *   - Conflicts with type 'V'.
95
 * - "f" Forced:
96
 *   - Dissatisfactions (if any) for this expression always involve at least one signature.
97
 *   - Is always true for type 'V'.
98
 * - "s" Safe:
99
 *   - Satisfactions for this expression always involve at least one signature.
100
 * - "m" Nonmalleable:
101
 *   - For every way this expression can be satisfied (which may be none),
102
 *     a nonmalleable satisfaction exists.
103
 *   - This generally requires 'm' for all subexpressions, and 'e' for all subexpressions
104
 *     which are dissatisfied when satisfying the parent.
105
 *
106
 * One type property is an implementation detail:
107
 * - "x" Expensive verify:
108
 *   - Expressions with this property have a script whose last opcode is not EQUAL, CHECKSIG, or CHECKMULTISIG.
109
 *   - Not having this property means that it can be converted to a V at no cost (by switching to the
110
 *     -VERIFY version of the last opcode).
111
 *
112
 * Five more type properties for representing timelock information. Spend paths
113
 * in miniscripts containing conflicting timelocks and heightlocks cannot be spent together.
114
 * This helps users detect if miniscript does not match the semantic behaviour the
115
 * user expects.
116
 * - "g" Whether the branch contains a relative time timelock
117
 * - "h" Whether the branch contains a relative height timelock
118
 * - "i" Whether the branch contains an absolute time timelock
119
 * - "j" Whether the branch contains an absolute height timelock
120
 * - "k"
121
 *   - Whether all satisfactions of this expression don't contain a mix of heightlock and timelock
122
 *     of the same type.
123
 *   - If the miniscript does not have the "k" property, the miniscript template will not match
124
 *     the user expectation of the corresponding spending policy.
125
 * For each of these properties the subset rule holds: an expression with properties X, Y, and Z, is also
126
 * valid in places where an X, a Y, a Z, an XY, ... is expected.
127
*/
128
class Type {
129
    //! Internal bitmap of properties (see ""_mst operator for details).
130
    uint32_t m_flags;
131
132
    //! Internal constructor used by the ""_mst operator.
133
0
    explicit constexpr Type(uint32_t flags) : m_flags(flags) {}
134
135
public:
136
    //! The only way to publicly construct a Type is using this literal operator.
137
    friend consteval Type operator""_mst(const char* c, size_t l);
138
139
    //! Compute the type with the union of properties.
140
0
    constexpr Type operator|(Type x) const { return Type(m_flags | x.m_flags); }
141
142
    //! Compute the type with the intersection of properties.
143
0
    constexpr Type operator&(Type x) const { return Type(m_flags & x.m_flags); }
144
145
    //! Check whether the left hand's properties are superset of the right's (= left is a subtype of right).
146
0
    constexpr bool operator<<(Type x) const { return (x.m_flags & ~m_flags) == 0; }
147
148
    //! Comparison operator to enable use in sets/maps (total ordering incompatible with <<).
149
0
    constexpr bool operator<(Type x) const { return m_flags < x.m_flags; }
150
151
    //! Equality operator.
152
0
    constexpr bool operator==(Type x) const { return m_flags == x.m_flags; }
153
154
    //! The empty type if x is false, itself otherwise.
155
0
    constexpr Type If(bool x) const { return Type(x ? m_flags : 0); }
  Branch (155:51): [True: 0, False: 0]
156
};
157
158
//! Literal operator to construct Type objects.
159
inline consteval Type operator""_mst(const char* c, size_t l)
160
{
161
    Type typ{0};
162
163
    for (const char *p = c; p < c + l; p++) {
164
        typ = typ | Type(
165
            *p == 'B' ? 1 << 0 : // Base type
166
            *p == 'V' ? 1 << 1 : // Verify type
167
            *p == 'K' ? 1 << 2 : // Key type
168
            *p == 'W' ? 1 << 3 : // Wrapped type
169
            *p == 'z' ? 1 << 4 : // Zero-arg property
170
            *p == 'o' ? 1 << 5 : // One-arg property
171
            *p == 'n' ? 1 << 6 : // Nonzero arg property
172
            *p == 'd' ? 1 << 7 : // Dissatisfiable property
173
            *p == 'u' ? 1 << 8 : // Unit property
174
            *p == 'e' ? 1 << 9 : // Expression property
175
            *p == 'f' ? 1 << 10 : // Forced property
176
            *p == 's' ? 1 << 11 : // Safe property
177
            *p == 'm' ? 1 << 12 : // Nonmalleable property
178
            *p == 'x' ? 1 << 13 : // Expensive verify
179
            *p == 'g' ? 1 << 14 : // older: contains relative time timelock   (csv_time)
180
            *p == 'h' ? 1 << 15 : // older: contains relative height timelock (csv_height)
181
            *p == 'i' ? 1 << 16 : // after: contains time timelock   (cltv_time)
182
            *p == 'j' ? 1 << 17 : // after: contains height timelock   (cltv_height)
183
            *p == 'k' ? 1 << 18 : // does not contain a combination of height and time locks
184
            (throw std::logic_error("Unknown character in _mst literal"), 0)
185
        );
186
    }
187
188
    return typ;
189
}
190
191
using Opcode = std::pair<opcodetype, std::vector<unsigned char>>;
192
193
template<typename Key> class Node;
194
195
//! Unordered traversal of a miniscript node tree.
196
template <typename Key, std::invocable<const Node<Key>&> Fn>
197
void ForEachNode(const Node<Key>& root, Fn&& fn)
198
0
{
199
0
    std::vector<std::reference_wrapper<const Node<Key>>> stack{root};
200
0
    while (!stack.empty()) {
  Branch (200:12): [True: 0, False: 0]
201
0
        const Node<Key>& node = stack.back();
202
0
        std::invoke(fn, node);
203
0
        stack.pop_back();
204
0
        for (const auto& sub : node.Subs()) {
  Branch (204:30): [True: 0, False: 0]
205
0
            stack.emplace_back(sub);
206
0
        }
207
0
    }
208
0
}
209
210
//! The different node types in miniscript.
211
enum class Fragment {
212
    JUST_0,    //!< OP_0
213
    JUST_1,    //!< OP_1
214
    PK_K,      //!< [key]
215
    PK_H,      //!< OP_DUP OP_HASH160 [keyhash] OP_EQUALVERIFY
216
    OLDER,     //!< [n] OP_CHECKSEQUENCEVERIFY
217
    AFTER,     //!< [n] OP_CHECKLOCKTIMEVERIFY
218
    SHA256,    //!< OP_SIZE 32 OP_EQUALVERIFY OP_SHA256 [hash] OP_EQUAL
219
    HASH256,   //!< OP_SIZE 32 OP_EQUALVERIFY OP_HASH256 [hash] OP_EQUAL
220
    RIPEMD160, //!< OP_SIZE 32 OP_EQUALVERIFY OP_RIPEMD160 [hash] OP_EQUAL
221
    HASH160,   //!< OP_SIZE 32 OP_EQUALVERIFY OP_HASH160 [hash] OP_EQUAL
222
    WRAP_A,    //!< OP_TOALTSTACK [X] OP_FROMALTSTACK
223
    WRAP_S,    //!< OP_SWAP [X]
224
    WRAP_C,    //!< [X] OP_CHECKSIG
225
    WRAP_D,    //!< OP_DUP OP_IF [X] OP_ENDIF
226
    WRAP_V,    //!< [X] OP_VERIFY (or -VERIFY version of last opcode in X)
227
    WRAP_J,    //!< OP_SIZE OP_0NOTEQUAL OP_IF [X] OP_ENDIF
228
    WRAP_N,    //!< [X] OP_0NOTEQUAL
229
    AND_V,     //!< [X] [Y]
230
    AND_B,     //!< [X] [Y] OP_BOOLAND
231
    OR_B,      //!< [X] [Y] OP_BOOLOR
232
    OR_C,      //!< [X] OP_NOTIF [Y] OP_ENDIF
233
    OR_D,      //!< [X] OP_IFDUP OP_NOTIF [Y] OP_ENDIF
234
    OR_I,      //!< OP_IF [X] OP_ELSE [Y] OP_ENDIF
235
    ANDOR,     //!< [X] OP_NOTIF [Z] OP_ELSE [Y] OP_ENDIF
236
    THRESH,    //!< [X1] ([Xn] OP_ADD)* [k] OP_EQUAL
237
    MULTI,     //!< [k] [key_n]* [n] OP_CHECKMULTISIG (only available within P2WSH context)
238
    MULTI_A,   //!< [key_0] OP_CHECKSIG ([key_n] OP_CHECKSIGADD)* [k] OP_NUMEQUAL (only within Tapscript ctx)
239
    // AND_N(X,Y) is represented as ANDOR(X,Y,0)
240
    // WRAP_T(X) is represented as AND_V(X,1)
241
    // WRAP_L(X) is represented as OR_I(0,X)
242
    // WRAP_U(X) is represented as OR_I(X,0)
243
};
244
245
enum class Availability {
246
    NO,
247
    YES,
248
    MAYBE,
249
};
250
251
enum class MiniscriptContext {
252
    P2WSH,
253
    TAPSCRIPT,
254
};
255
256
/** Whether the context Tapscript, ensuring the only other possibility is P2WSH. */
257
constexpr bool IsTapscript(MiniscriptContext ms_ctx)
258
0
{
259
0
    switch (ms_ctx) {
  Branch (259:13): [True: 0, False: 0]
260
0
        case MiniscriptContext::P2WSH: return false;
  Branch (260:9): [True: 0, False: 0]
261
0
        case MiniscriptContext::TAPSCRIPT: return true;
  Branch (261:9): [True: 0, False: 0]
262
0
    }
263
0
    assert(false);
  Branch (263:5): [Folded - Ignored]
264
0
}
265
266
namespace internal {
267
268
//! The maximum size of a witness item for a Miniscript under Tapscript context. (A BIP340 signature with a sighash type byte.)
269
static constexpr uint32_t MAX_TAPMINISCRIPT_STACK_ELEM_SIZE{65};
270
271
//! version + nLockTime
272
constexpr uint32_t TX_OVERHEAD{4 + 4};
273
//! prevout + nSequence + scriptSig
274
constexpr uint32_t TXIN_BYTES_NO_WITNESS{36 + 4 + 1};
275
//! nValue + script len + OP_0 + pushdata 32.
276
constexpr uint32_t P2WSH_TXOUT_BYTES{8 + 1 + 1 + 33};
277
//! Data other than the witness in a transaction. Overhead + vin count + one vin + vout count + one vout + segwit marker
278
constexpr uint32_t TX_BODY_LEEWAY_WEIGHT{(TX_OVERHEAD + GetSizeOfCompactSize(1) + TXIN_BYTES_NO_WITNESS + GetSizeOfCompactSize(1) + P2WSH_TXOUT_BYTES) * WITNESS_SCALE_FACTOR + 2};
279
//! Maximum possible stack size to spend a Taproot output (excluding the script itself).
280
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};
281
/** The maximum size of a script depending on the context. */
282
constexpr uint32_t MaxScriptSize(MiniscriptContext ms_ctx)
283
0
{
284
0
    if (IsTapscript(ms_ctx)) {
  Branch (284:9): [True: 0, False: 0]
285
        // Leaf scripts under Tapscript are not explicitly limited in size. They are only implicitly
286
        // bounded by the maximum standard size of a spending transaction. Let the maximum script
287
        // size conservatively be small enough such that even a maximum sized witness and a reasonably
288
        // sized spending transaction can spend an output paying to this script without running into
289
        // the maximum standard tx size limit.
290
0
        constexpr auto max_size{MAX_STANDARD_TX_WEIGHT - TX_BODY_LEEWAY_WEIGHT - MAX_TAPSCRIPT_SAT_SIZE};
291
0
        return max_size - GetSizeOfCompactSize(max_size);
292
0
    }
293
0
    return MAX_STANDARD_P2WSH_SCRIPT_SIZE;
294
0
}
295
296
//! Helper function for Node::CalcType.
297
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);
298
299
//! Helper function for Node::CalcScriptLen.
300
size_t ComputeScriptLen(Fragment fragment, Type sub0typ, size_t subsize, uint32_t k, size_t n_subs, size_t n_keys, MiniscriptContext ms_ctx);
301
302
//! A helper sanitizer/checker for the output of CalcType.
303
Type SanitizeType(Type x);
304
305
//! An object representing a sequence of witness stack elements.
306
struct InputStack {
307
    /** Whether this stack is valid for its intended purpose (satisfaction or dissatisfaction of a Node).
308
     *  The MAYBE value is used for size estimation, when keys/preimages may actually be unavailable,
309
     *  but may be available at signing time. This makes the InputStack structure and signing logic,
310
     *  filled with dummy signatures/preimages usable for witness size estimation.
311
     */
312
    Availability available = Availability::YES;
313
    //! Whether this stack contains a digital signature.
314
    bool has_sig = false;
315
    //! Whether this stack is malleable (can be turned into an equally valid other stack by a third party).
316
    bool malleable = false;
317
    //! Whether this stack is non-canonical (using a construction known to be unnecessary for satisfaction).
318
    //! Note that this flag does not affect the satisfaction algorithm; it is only used for sanity checking.
319
    bool non_canon = false;
320
    //! Serialized witness size.
321
    size_t size = 0;
322
    //! Data elements.
323
    std::vector<std::vector<unsigned char>> stack;
324
    //! Construct an empty stack (valid).
325
0
    InputStack() = default;
326
    //! Construct a valid single-element stack (with an element up to 75 bytes).
327
0
    InputStack(std::vector<unsigned char> in) : size(in.size() + 1), stack(Vector(std::move(in))) {}
328
    //! Change availability
329
    InputStack& SetAvailable(Availability avail);
330
    //! Mark this input stack as having a signature.
331
    InputStack& SetWithSig();
332
    //! Mark this input stack as non-canonical (known to not be necessary in non-malleable satisfactions).
333
    InputStack& SetNonCanon();
334
    //! Mark this input stack as malleable.
335
    InputStack& SetMalleable(bool x = true);
336
    //! Concatenate two input stacks.
337
    friend InputStack operator+(InputStack a, InputStack b);
338
    //! Choose between two potential input stacks.
339
    friend InputStack operator|(InputStack a, InputStack b);
340
};
341
342
/** A stack consisting of a single zero-length element (interpreted as 0 by the script interpreter in numeric context). */
343
static const auto ZERO = InputStack(std::vector<unsigned char>());
344
/** A stack consisting of a single malleable 32-byte 0x0000...0000 element (for dissatisfying hash challenges). */
345
static const auto ZERO32 = InputStack(std::vector<unsigned char>(32, 0)).SetMalleable();
346
/** A stack consisting of a single 0x01 element (interpreted as 1 by the script interpreted in numeric context). */
347
static const auto ONE = InputStack(Vector((unsigned char)1));
348
/** The empty stack. */
349
static const auto EMPTY = InputStack();
350
/** A stack representing the lack of any (dis)satisfactions. */
351
static const auto INVALID = InputStack().SetAvailable(Availability::NO);
352
353
//! A pair of a satisfaction and a dissatisfaction InputStack.
354
struct InputResult {
355
    InputStack nsat, sat;
356
357
    template<typename A, typename B>
358
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&&)
359
};
360
361
//! Class whose objects represent the maximum of a list of integers.
362
template <typename I>
363
class MaxInt
364
{
365
    bool valid;
366
    I value;
367
368
public:
369
0
    MaxInt() : valid(false), value(0) {}
370
0
    MaxInt(I val) : valid(true), value(val) {}
371
372
0
    bool Valid() const { return valid; }
373
0
    I Value() const { return value; }
374
375
0
    friend MaxInt<I> operator+(const MaxInt<I>& a, const MaxInt<I>& b) {
376
0
        if (!a.valid || !b.valid) return {};
  Branch (376:13): [True: 0, False: 0]
  Branch (376:25): [True: 0, False: 0]
377
0
        return a.value + b.value;
378
0
    }
379
380
0
    friend MaxInt<I> operator|(const MaxInt<I>& a, const MaxInt<I>& b) {
381
0
        if (!a.valid) return b;
  Branch (381:13): [True: 0, False: 0]
382
0
        if (!b.valid) return a;
  Branch (382:13): [True: 0, False: 0]
383
0
        return std::max(a.value, b.value);
384
0
    }
385
};
386
387
struct Ops {
388
    //! Non-push opcodes.
389
    uint32_t count;
390
    //! Number of keys in possibly executed OP_CHECKMULTISIG(VERIFY)s to satisfy.
391
    MaxInt<uint32_t> sat;
392
    //! Number of keys in possibly executed OP_CHECKMULTISIG(VERIFY)s to dissatisfy.
393
    MaxInt<uint32_t> dsat;
394
395
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) {};
396
};
397
398
/** A data structure to help the calculation of stack size limits.
399
 *
400
 * Conceptually, every SatInfo object corresponds to a (possibly empty) set of script execution
401
 * traces (sequences of opcodes).
402
 * - SatInfo{} corresponds to the empty set.
403
 * - SatInfo{n, e} corresponds to a single trace whose net effect is removing n elements from the
404
 *   stack (may be negative for a net increase), and reaches a maximum of e stack elements more
405
 *   than it ends with.
406
 * - operator| is the union operation: (a | b) corresponds to the union of the traces in a and the
407
 *   traces in b.
408
 * - operator+ is the concatenation operator: (a + b) corresponds to the set of traces formed by
409
 *   concatenating any trace in a with any trace in b.
410
 *
411
 * Its fields are:
412
 * - valid is true if the set is non-empty.
413
 * - netdiff (if valid) is the largest difference between stack size at the beginning and at the
414
 *   end of the script across all traces in the set.
415
 * - exec (if valid) is the largest difference between stack size anywhere during execution and at
416
 *   the end of the script, across all traces in the set (note that this is not necessarily due
417
 *   to the same trace as the one that resulted in the value for netdiff).
418
 *
419
 * This allows us to build up stack size limits for any script efficiently, by starting from the
420
 * individual opcodes miniscripts correspond to, using concatenation to construct scripts, and
421
 * using the union operation to choose between execution branches. Since any top-level script
422
 * satisfaction ends with a single stack element, we know that for a full script:
423
 * - netdiff+1 is the maximal initial stack size (relevant for P2WSH stack limits).
424
 * - exec+1 is the maximal stack size reached during execution (relevant for P2TR stack limits).
425
 *
426
 * Mathematically, SatInfo forms a semiring:
427
 * - operator| is the semiring addition operator, with identity SatInfo{}, and which is commutative
428
 *   and associative.
429
 * - operator+ is the semiring multiplication operator, with identity SatInfo{0}, and which is
430
 *   associative.
431
 * - operator+ is distributive over operator|, so (a + (b | c)) = (a+b | a+c). This means we do not
432
 *   need to actually materialize all possible full execution traces over the whole script (which
433
 *   may be exponential in the length of the script); instead we can use the union operation at the
434
 *   individual subexpression level, and concatenate the result with subexpressions before and
435
 *   after it.
436
 * - It is not a commutative semiring, because a+b can differ from b+a. For example, "OP_1 OP_DROP"
437
 *   has exec=1, while "OP_DROP OP_1" has exec=0.
438
 */
439
class SatInfo
440
{
441
    //! Whether a canonical satisfaction/dissatisfaction is possible at all.
442
    bool valid;
443
    //! How much higher the stack size at start of execution can be compared to at the end.
444
    int32_t netdiff;
445
    //! How much higher the stack size can be during execution compared to at the end.
446
    int32_t exec;
447
448
public:
449
    /** Empty script set. */
450
0
    constexpr SatInfo() noexcept : valid(false), netdiff(0), exec(0) {}
451
452
    /** Script set with a single script in it, with specified netdiff and exec. */
453
    constexpr SatInfo(int32_t in_netdiff, int32_t in_exec) noexcept :
454
0
        valid{true}, netdiff{in_netdiff}, exec{in_exec} {}
455
456
0
    bool Valid() const { return valid; }
457
0
    int32_t NetDiff() const { return netdiff; }
458
0
    int32_t Exec() const { return exec; }
459
460
    /** Script set union. */
461
    constexpr friend SatInfo operator|(const SatInfo& a, const SatInfo& b) noexcept
462
0
    {
463
        // Union with an empty set is itself.
464
0
        if (!a.valid) return b;
  Branch (464:13): [True: 0, False: 0]
465
0
        if (!b.valid) return a;
  Branch (465:13): [True: 0, False: 0]
466
        // Otherwise the netdiff and exec of the union is the maximum of the individual values.
467
0
        return {std::max(a.netdiff, b.netdiff), std::max(a.exec, b.exec)};
468
0
    }
469
470
    /** Script set concatenation. */
471
    constexpr friend SatInfo operator+(const SatInfo& a, const SatInfo& b) noexcept
472
0
    {
473
        // Concatenation with an empty set yields an empty set.
474
0
        if (!a.valid || !b.valid) return {};
  Branch (474:13): [True: 0, False: 0]
  Branch (474:25): [True: 0, False: 0]
475
        // Otherwise, the maximum stack size difference for the combined scripts is the sum of the
476
        // netdiffs, and the maximum stack size difference anywhere is either b.exec (if the
477
        // maximum occurred in b) or b.netdiff+a.exec (if the maximum occurred in a).
478
0
        return {a.netdiff + b.netdiff, std::max(b.exec, b.netdiff + a.exec)};
479
0
    }
480
481
    /** The empty script. */
482
0
    static constexpr SatInfo Empty() noexcept { return {0, 0}; }
483
    /** A script consisting of a single push opcode. */
484
0
    static constexpr SatInfo Push() noexcept { return {-1, 0}; }
485
    /** A script consisting of a single hash opcode. */
486
0
    static constexpr SatInfo Hash() noexcept { return {0, 0}; }
487
    /** A script consisting of just a repurposed nop (OP_CHECKLOCKTIMEVERIFY, OP_CHECKSEQUENCEVERIFY). */
488
0
    static constexpr SatInfo Nop() noexcept { return {0, 0}; }
489
    /** A script consisting of just OP_IF or OP_NOTIF. Note that OP_ELSE and OP_ENDIF have no stack effect. */
490
0
    static constexpr SatInfo If() noexcept { return {1, 1}; }
491
    /** A script consisting of just a binary operator (OP_BOOLAND, OP_BOOLOR, OP_ADD). */
492
0
    static constexpr SatInfo BinaryOp() noexcept { return {1, 1}; }
493
494
    // Scripts for specific individual opcodes.
495
0
    static constexpr SatInfo OP_DUP() noexcept { return {-1, 0}; }
496
0
    static constexpr SatInfo OP_IFDUP(bool nonzero) noexcept { return {nonzero ? -1 : 0, 0}; }
  Branch (496:72): [True: 0, False: 0]
497
0
    static constexpr SatInfo OP_EQUALVERIFY() noexcept { return {2, 2}; }
498
0
    static constexpr SatInfo OP_EQUAL() noexcept { return {1, 1}; }
499
0
    static constexpr SatInfo OP_SIZE() noexcept { return {-1, 0}; }
500
0
    static constexpr SatInfo OP_CHECKSIG() noexcept { return {1, 1}; }
501
0
    static constexpr SatInfo OP_0NOTEQUAL() noexcept { return {0, 0}; }
502
0
    static constexpr SatInfo OP_VERIFY() noexcept { return {1, 1}; }
503
};
504
505
class StackSize
506
{
507
    SatInfo sat, dsat;
508
509
public:
510
0
    constexpr StackSize(SatInfo in_sat, SatInfo in_dsat) noexcept : sat(in_sat), dsat(in_dsat) {};
511
0
    constexpr StackSize(SatInfo in_both) noexcept : sat(in_both), dsat(in_both) {};
512
513
0
    const SatInfo& Sat() const { return sat; }
514
0
    const SatInfo& Dsat() const { return dsat; }
515
};
516
517
struct WitnessSize {
518
    //! Maximum witness size to satisfy;
519
    MaxInt<uint32_t> sat;
520
    //! Maximum witness size to dissatisfy;
521
    MaxInt<uint32_t> dsat;
522
523
0
    WitnessSize(MaxInt<uint32_t> in_sat, MaxInt<uint32_t> in_dsat) : sat(in_sat), dsat(in_dsat) {};
524
};
525
526
struct NoDupCheck {};
527
528
} // namespace internal
529
530
//! A node in a miniscript expression.
531
template <typename Key>
532
class Node
533
{
534
    //! What node type this node is.
535
    enum Fragment fragment;
536
    //! The k parameter (time for OLDER/AFTER, threshold for THRESH(_M))
537
    uint32_t k = 0;
538
    //! The keys used by this expression (only for PK_K/PK_H/MULTI)
539
    std::vector<Key> keys;
540
    //! The data bytes in this expression (only for HASH160/HASH256/SHA256/RIPEMD160).
541
    std::vector<unsigned char> data;
542
    //! Subexpressions (for WRAP_*/AND_*/OR_*/ANDOR/THRESH)
543
    std::vector<Node> subs;
544
    //! The Script context for this node. Either P2WSH or Tapscript.
545
    MiniscriptContext m_script_ctx;
546
547
public:
548
    // Permit 1 level deep recursion since we own instances of our own type.
549
    // NOLINTBEGIN(misc-no-recursion)
550
    ~Node()
551
0
    {
552
        // Destroy the subexpressions iteratively after moving out their
553
        // subexpressions to avoid a stack-overflow due to recursive calls to
554
        // the subs' destructors.
555
        // We move vectors in order to only update array-pointers inside them
556
        // rather than moving individual Node instances which would involve
557
        // moving/copying each Node field.
558
0
        std::vector<std::vector<Node>> queue;
559
0
        queue.push_back(std::move(subs));
560
0
        do {
561
0
            auto flattening{std::move(queue.back())};
562
0
            queue.pop_back();
563
0
            for (Node& n : flattening) {
  Branch (563:26): [True: 0, False: 0]
  Branch (563:26): [True: 0, False: 0]
  Branch (563:26): [True: 0, False: 0]
564
0
                if (!n.subs.empty()) queue.push_back(std::move(n.subs));
  Branch (564:21): [True: 0, False: 0]
  Branch (564:21): [True: 0, False: 0]
  Branch (564:21): [True: 0, False: 0]
565
0
            }
566
0
        } while (!queue.empty());
  Branch (566:18): [True: 0, False: 0]
  Branch (566:18): [True: 0, False: 0]
  Branch (566:18): [True: 0, False: 0]
567
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::~Node()
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::~Node()
Unexecuted instantiation: miniscript::Node<CPubKey>::~Node()
568
    // NOLINTEND(misc-no-recursion)
569
570
    Node<Key> Clone() const
571
0
    {
572
        // Use TreeEval() to avoid a stack-overflow due to recursion
573
0
        auto upfn = [](const Node& node, std::span<Node> children) {
574
0
            std::vector<Node> new_subs;
575
0
            for (auto& child : children) {
  Branch (575:30): [True: 0, False: 0]
576
                // It's fine to move from children as they are new nodes having
577
                // been produced by calling this function one level down.
578
0
                new_subs.push_back(std::move(child));
579
0
            }
580
0
            return Node{internal::NoDupCheck{}, node.m_script_ctx, node.fragment, std::move(new_subs), node.keys, node.data, node.k};
581
0
        };
582
0
        return TreeEval<Node>(upfn);
583
0
    }
584
585
0
    enum Fragment Fragment() const { return fragment; }
586
0
    uint32_t K() const { return k; }
587
    const std::vector<Key>& Keys() const { return keys; }
588
    const std::vector<unsigned char>& Data() const { return data; }
589
0
    const std::vector<Node>& Subs() const { return subs; }
590
591
private:
592
    //! Cached ops counts.
593
    internal::Ops ops;
594
    //! Cached stack size bounds.
595
    internal::StackSize ss;
596
    //! Cached witness size bounds.
597
    internal::WitnessSize ws;
598
    //! Cached expression type (computed by CalcType and fed through SanitizeType).
599
    Type typ;
600
    //! Cached script length (computed by CalcScriptLen).
601
    size_t scriptlen;
602
    //! Whether a public key appears more than once in this node. This value is initialized
603
    //! by all constructors except the NoDupCheck ones. The NoDupCheck ones skip the
604
    //! computation, requiring it to be done manually by invoking DuplicateKeyCheck().
605
    //! DuplicateKeyCheck(), or a non-NoDupCheck constructor, will compute has_duplicate_keys
606
    //! for all subnodes as well.
607
    mutable std::optional<bool> has_duplicate_keys;
608
609
    // Constructor which takes all of the data that a Node could possibly contain.
610
    // This is kept private as no valid fragment has all of these arguments.
611
    // Only used by Clone()
612
    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)
613
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()) {}
614
615
    //! Compute the length of the script for this miniscript (including children).
616
    size_t CalcScriptLen() const
617
0
    {
618
0
        size_t subsize = 0;
619
0
        for (const auto& sub : subs) {
  Branch (619:30): [True: 0, False: 0]
  Branch (619:30): [True: 0, False: 0]
  Branch (619:30): [True: 0, False: 0]
620
0
            subsize += sub.ScriptSize();
621
0
        }
622
0
        Type sub0type = subs.size() > 0 ? subs[0].GetType() : ""_mst;
  Branch (622:25): [True: 0, False: 0]
  Branch (622:25): [True: 0, False: 0]
  Branch (622:25): [True: 0, False: 0]
623
0
        return internal::ComputeScriptLen(fragment, sub0type, subsize, k, subs.size(), keys.size(), m_script_ctx);
624
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::CalcScriptLen() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::CalcScriptLen() const
Unexecuted instantiation: miniscript::Node<CPubKey>::CalcScriptLen() const
625
626
    /* Apply a recursive algorithm to a Miniscript tree, without actual recursive calls.
627
     *
628
     * The algorithm is defined by two functions: downfn and upfn. Conceptually, the
629
     * result can be thought of as first using downfn to compute a "state" for each node,
630
     * from the root down to the leaves. Then upfn is used to compute a "result" for each
631
     * node, from the leaves back up to the root, which is then returned. In the actual
632
     * implementation, both functions are invoked in an interleaved fashion, performing a
633
     * depth-first traversal of the tree.
634
     *
635
     * In more detail, it is invoked as node.TreeEvalMaybe<Result>(root, downfn, upfn):
636
     * - root is the state of the root node, of type State.
637
     * - downfn is a callable (State&, const Node&, size_t) -> State, which given a
638
     *   node, its state, and an index of one of its children, computes the state of that
639
     *   child. It can modify the state. Children of a given node will have downfn()
640
     *   called in order.
641
     * - upfn is a callable (State&&, const Node&, std::span<Result>) -> std::optional<Result>,
642
     *   which given a node, its state, and a span of the results of its children,
643
     *   computes the result of the node. If std::nullopt is returned by upfn,
644
     *   TreeEvalMaybe() immediately returns std::nullopt.
645
     * The return value of TreeEvalMaybe is the result of the root node.
646
     *
647
     * Result type cannot be bool due to the std::vector<bool> specialization.
648
     */
649
    template<typename Result, typename State, typename DownFn, typename UpFn>
650
    std::optional<Result> TreeEvalMaybe(State root_state, DownFn downfn, UpFn upfn) const
651
0
    {
652
        /** Entries of the explicit stack tracked in this algorithm. */
653
0
        struct StackElem
654
0
        {
655
0
            const Node& node; //!< The node being evaluated.
656
0
            size_t expanded; //!< How many children of this node have been expanded.
657
0
            State state; //!< The state for that node.
658
659
0
            StackElem(const Node& node_, size_t exp_, State&& state_) :
660
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&&)
661
0
        };
662
        /* Stack of tree nodes being explored. */
663
0
        std::vector<StackElem> stack;
664
        /* Results of subtrees so far. Their order and mapping to tree nodes
665
         * is implicitly defined by stack. */
666
0
        std::vector<Result> results;
667
0
        stack.emplace_back(*this, 0, std::move(root_state));
668
669
        /* Here is a demonstration of the algorithm, for an example tree A(B,C(D,E),F).
670
         * State variables are omitted for simplicity.
671
         *
672
         * First: stack=[(A,0)] results=[]
673
         *        stack=[(A,1),(B,0)] results=[]
674
         *        stack=[(A,1)] results=[B]
675
         *        stack=[(A,2),(C,0)] results=[B]
676
         *        stack=[(A,2),(C,1),(D,0)] results=[B]
677
         *        stack=[(A,2),(C,1)] results=[B,D]
678
         *        stack=[(A,2),(C,2),(E,0)] results=[B,D]
679
         *        stack=[(A,2),(C,2)] results=[B,D,E]
680
         *        stack=[(A,2)] results=[B,C]
681
         *        stack=[(A,3),(F,0)] results=[B,C]
682
         *        stack=[(A,3)] results=[B,C,F]
683
         * Final: stack=[] results=[A]
684
         */
685
0
        while (stack.size()) {
  Branch (685:16): [True: 0, False: 0]
  Branch (685:16): [True: 0, False: 0]
  Branch (685:16): [True: 0, False: 0]
  Branch (685:16): [True: 0, False: 0]
  Branch (685:16): [True: 0, False: 0]
  Branch (685:16): [True: 0, False: 0]
  Branch (685:16): [True: 0, False: 0]
  Branch (685:16): [True: 0, False: 0]
  Branch (685:16): [True: 0, False: 0]
  Branch (685:16): [True: 0, False: 0]
686
0
            const Node& node = stack.back().node;
687
0
            if (stack.back().expanded < node.subs.size()) {
  Branch (687:17): [True: 0, False: 0]
  Branch (687:17): [True: 0, False: 0]
  Branch (687:17): [True: 0, False: 0]
  Branch (687:17): [True: 0, False: 0]
  Branch (687:17): [True: 0, False: 0]
  Branch (687:17): [True: 0, False: 0]
  Branch (687:17): [True: 0, False: 0]
  Branch (687:17): [True: 0, False: 0]
  Branch (687:17): [True: 0, False: 0]
  Branch (687:17): [True: 0, False: 0]
688
                /* We encounter a tree node with at least one unexpanded child.
689
                 * Expand it. By the time we hit this node again, the result of
690
                 * that child (and all earlier children) will be at the end of `results`. */
691
0
                size_t child_index = stack.back().expanded++;
692
0
                State child_state = downfn(stack.back().state, node, child_index);
693
0
                stack.emplace_back(node.subs[child_index], 0, std::move(child_state));
694
0
                continue;
695
0
            }
696
            // Invoke upfn with the last node.subs.size() elements of results as input.
697
0
            assert(results.size() >= node.subs.size());
  Branch (697:13): [True: 0, False: 0]
  Branch (697:13): [True: 0, False: 0]
  Branch (697:13): [True: 0, False: 0]
  Branch (697:13): [True: 0, False: 0]
  Branch (697:13): [True: 0, False: 0]
  Branch (697:13): [True: 0, False: 0]
  Branch (697:13): [True: 0, False: 0]
  Branch (697:13): [True: 0, False: 0]
  Branch (697:13): [True: 0, False: 0]
  Branch (697:13): [True: 0, False: 0]
698
0
            std::optional<Result> result{upfn(std::move(stack.back().state), node,
699
0
                std::span<Result>{results}.last(node.subs.size()))};
700
            // If evaluation returns std::nullopt, abort immediately.
701
0
            if (!result) return {};
  Branch (701:17): [True: 0, False: 0]
  Branch (701:17): [True: 0, False: 0]
  Branch (701:17): [True: 0, False: 0]
  Branch (701:17): [True: 0, False: 0]
  Branch (701:17): [True: 0, False: 0]
  Branch (701:17): [True: 0, False: 0]
  Branch (701:17): [True: 0, False: 0]
  Branch (701:17): [True: 0, False: 0]
  Branch (701:17): [True: 0, False: 0]
  Branch (701:17): [True: 0, False: 0]
702
            // Replace the last node.subs.size() elements of results with the new result.
703
0
            results.erase(results.end() - node.subs.size(), results.end());
704
0
            results.push_back(std::move(*result));
705
0
            stack.pop_back();
706
0
        }
707
        // The final remaining results element is the root result, return it.
708
0
        assert(results.size() >= 1);
  Branch (708:9): [True: 0, False: 0]
  Branch (708:9): [True: 0, False: 0]
  Branch (708:9): [True: 0, False: 0]
  Branch (708:9): [True: 0, False: 0]
  Branch (708:9): [True: 0, False: 0]
  Branch (708:9): [True: 0, False: 0]
  Branch (708:9): [True: 0, False: 0]
  Branch (708:9): [True: 0, False: 0]
  Branch (708:9): [True: 0, False: 0]
  Branch (708:9): [True: 0, False: 0]
709
0
        CHECK_NONFATAL(results.size() == 1);
710
0
        return std::move(results[0]);
711
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
712
713
    /** Like TreeEvalMaybe, but without downfn or State type.
714
     * upfn takes (const Node&, std::span<Result>) and returns std::optional<Result>. */
715
    template<typename Result, typename UpFn>
716
    std::optional<Result> TreeEvalMaybe(UpFn upfn) const
717
    {
718
        struct DummyState {};
719
        return TreeEvalMaybe<Result>(DummyState{},
720
            [](DummyState, const Node&, size_t) { return DummyState{}; },
721
            [&upfn](DummyState, const Node& node, std::span<Result> subs) {
722
                return upfn(node, subs);
723
            }
724
        );
725
    }
726
727
    /** Like TreeEvalMaybe, but always produces a result. upfn must return Result. */
728
    template<typename Result, typename State, typename DownFn, typename UpFn>
729
    Result TreeEval(State root_state, DownFn&& downfn, UpFn upfn) const
730
0
    {
731
        // Invoke TreeEvalMaybe with upfn wrapped to return std::optional<Result>, and then
732
        // unconditionally dereference the result (it cannot be std::nullopt).
733
0
        return std::move(*TreeEvalMaybe<Result>(std::move(root_state),
734
0
            std::forward<DownFn>(downfn),
735
0
            [&upfn](State&& state, const Node& node, std::span<Result> subs) {
736
0
                Result res{upfn(std::move(state), node, subs)};
737
0
                return std::optional<Result>(std::move(res));
738
0
            }
739
0
        ));
740
0
    }
741
742
    /** Like TreeEval, but without downfn or State type.
743
     *  upfn takes (const Node&, std::span<Result>) and returns Result. */
744
    template<typename Result, typename UpFn>
745
    Result TreeEval(UpFn upfn) const
746
0
    {
747
0
        struct DummyState {};
748
0
        return std::move(*TreeEvalMaybe<Result>(DummyState{},
749
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
750
0
            [&upfn](DummyState, const Node& node, std::span<Result> subs) {
751
0
                Result res{upfn(node, subs)};
752
0
                return std::optional<Result>(std::move(res));
753
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
754
0
        ));
755
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
756
757
    /** Compare two miniscript subtrees, using a non-recursive algorithm. */
758
    friend int Compare(const Node<Key>& node1, const Node<Key>& node2)
759
    {
760
        std::vector<std::pair<const Node<Key>&, const Node<Key>&>> queue;
761
        queue.emplace_back(node1, node2);
762
        while (!queue.empty()) {
763
            const auto& [a, b] = queue.back();
764
            queue.pop_back();
765
            if (std::tie(a.fragment, a.k, a.keys, a.data) < std::tie(b.fragment, b.k, b.keys, b.data)) return -1;
766
            if (std::tie(b.fragment, b.k, b.keys, b.data) < std::tie(a.fragment, a.k, a.keys, a.data)) return 1;
767
            if (a.subs.size() < b.subs.size()) return -1;
768
            if (b.subs.size() < a.subs.size()) return 1;
769
            size_t n = a.subs.size();
770
            for (size_t i = 0; i < n; ++i) {
771
                queue.emplace_back(a.subs[n - 1 - i], b.subs[n - 1 - i]);
772
            }
773
        }
774
        return 0;
775
    }
776
777
    //! Compute the type for this miniscript.
778
0
    Type CalcType() const {
779
0
        using namespace internal;
780
781
        // THRESH has a variable number of subexpressions
782
0
        std::vector<Type> sub_types;
783
0
        if (fragment == Fragment::THRESH) {
  Branch (783:13): [True: 0, False: 0]
  Branch (783:13): [True: 0, False: 0]
  Branch (783:13): [True: 0, False: 0]
784
0
            for (const auto& sub : subs) sub_types.push_back(sub.GetType());
  Branch (784:34): [True: 0, False: 0]
  Branch (784:34): [True: 0, False: 0]
  Branch (784:34): [True: 0, False: 0]
785
0
        }
786
        // All other nodes than THRESH can be computed just from the types of the 0-3 subexpressions.
787
0
        Type x = subs.size() > 0 ? subs[0].GetType() : ""_mst;
  Branch (787:18): [True: 0, False: 0]
  Branch (787:18): [True: 0, False: 0]
  Branch (787:18): [True: 0, False: 0]
788
0
        Type y = subs.size() > 1 ? subs[1].GetType() : ""_mst;
  Branch (788:18): [True: 0, False: 0]
  Branch (788:18): [True: 0, False: 0]
  Branch (788:18): [True: 0, False: 0]
789
0
        Type z = subs.size() > 2 ? subs[2].GetType() : ""_mst;
  Branch (789:18): [True: 0, False: 0]
  Branch (789:18): [True: 0, False: 0]
  Branch (789:18): [True: 0, False: 0]
790
791
0
        return SanitizeType(ComputeType(fragment, x, y, z, sub_types, k, data.size(), subs.size(), keys.size(), m_script_ctx));
792
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::CalcType() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::CalcType() const
Unexecuted instantiation: miniscript::Node<CPubKey>::CalcType() const
793
794
public:
795
    template<typename Ctx>
796
    CScript ToScript(const Ctx& ctx) const
797
0
    {
798
        // To construct the CScript for a Miniscript object, we use the TreeEval algorithm.
799
        // The State is a boolean: whether or not the node's script expansion is followed
800
        // by an OP_VERIFY (which may need to be combined with the last script opcode).
801
0
        auto downfn = [](bool verify, const Node& node, size_t index) {
802
            // For WRAP_V, the subexpression is certainly followed by OP_VERIFY.
803
0
            if (node.fragment == Fragment::WRAP_V) return true;
  Branch (803:17): [True: 0, False: 0]
804
            // The subexpression of WRAP_S, and the last subexpression of AND_V
805
            // inherit the followed-by-OP_VERIFY property from the parent.
806
0
            if (node.fragment == Fragment::WRAP_S ||
  Branch (806:17): [True: 0, False: 0]
807
0
                (node.fragment == Fragment::AND_V && index == 1)) return verify;
  Branch (807:18): [True: 0, False: 0]
  Branch (807:54): [True: 0, False: 0]
808
0
            return false;
809
0
        };
810
        // The upward function computes for a node, given its followed-by-OP_VERIFY status
811
        // and the CScripts of its child nodes, the CScript of the node.
812
0
        const bool is_tapscript{IsTapscript(m_script_ctx)};
813
0
        auto upfn = [&ctx, is_tapscript](bool verify, const Node& node, std::span<CScript> subs) -> CScript {
814
0
            switch (node.fragment) {
  Branch (814:21): [True: 0, False: 0]
815
0
                case Fragment::PK_K: return BuildScript(ctx.ToPKBytes(node.keys[0]));
  Branch (815:17): [True: 0, False: 0]
816
0
                case Fragment::PK_H: return BuildScript(OP_DUP, OP_HASH160, ctx.ToPKHBytes(node.keys[0]), OP_EQUALVERIFY);
  Branch (816:17): [True: 0, False: 0]
817
0
                case Fragment::OLDER: return BuildScript(node.k, OP_CHECKSEQUENCEVERIFY);
  Branch (817:17): [True: 0, False: 0]
818
0
                case Fragment::AFTER: return BuildScript(node.k, OP_CHECKLOCKTIMEVERIFY);
  Branch (818:17): [True: 0, False: 0]
819
0
                case Fragment::SHA256: return BuildScript(OP_SIZE, 32, OP_EQUALVERIFY, OP_SHA256, node.data, verify ? OP_EQUALVERIFY : OP_EQUAL);
  Branch (819:17): [True: 0, False: 0]
  Branch (819:110): [True: 0, False: 0]
820
0
                case Fragment::RIPEMD160: return BuildScript(OP_SIZE, 32, OP_EQUALVERIFY, OP_RIPEMD160, node.data, verify ? OP_EQUALVERIFY : OP_EQUAL);
  Branch (820:17): [True: 0, False: 0]
  Branch (820:116): [True: 0, False: 0]
821
0
                case Fragment::HASH256: return BuildScript(OP_SIZE, 32, OP_EQUALVERIFY, OP_HASH256, node.data, verify ? OP_EQUALVERIFY : OP_EQUAL);
  Branch (821:17): [True: 0, False: 0]
  Branch (821:112): [True: 0, False: 0]
822
0
                case Fragment::HASH160: return BuildScript(OP_SIZE, 32, OP_EQUALVERIFY, OP_HASH160, node.data, verify ? OP_EQUALVERIFY : OP_EQUAL);
  Branch (822:17): [True: 0, False: 0]
  Branch (822:112): [True: 0, False: 0]
823
0
                case Fragment::WRAP_A: return BuildScript(OP_TOALTSTACK, subs[0], OP_FROMALTSTACK);
  Branch (823:17): [True: 0, False: 0]
824
0
                case Fragment::WRAP_S: return BuildScript(OP_SWAP, subs[0]);
  Branch (824:17): [True: 0, False: 0]
825
0
                case Fragment::WRAP_C: return BuildScript(std::move(subs[0]), verify ? OP_CHECKSIGVERIFY : OP_CHECKSIG);
  Branch (825:17): [True: 0, False: 0]
  Branch (825:79): [True: 0, False: 0]
826
0
                case Fragment::WRAP_D: return BuildScript(OP_DUP, OP_IF, subs[0], OP_ENDIF);
  Branch (826:17): [True: 0, False: 0]
827
0
                case Fragment::WRAP_V: {
  Branch (827:17): [True: 0, False: 0]
828
0
                    if (node.subs[0].GetType() << "x"_mst) {
  Branch (828:25): [True: 0, False: 0]
829
0
                        return BuildScript(std::move(subs[0]), OP_VERIFY);
830
0
                    } else {
831
0
                        return std::move(subs[0]);
832
0
                    }
833
0
                }
834
0
                case Fragment::WRAP_J: return BuildScript(OP_SIZE, OP_0NOTEQUAL, OP_IF, subs[0], OP_ENDIF);
  Branch (834:17): [True: 0, False: 0]
835
0
                case Fragment::WRAP_N: return BuildScript(std::move(subs[0]), OP_0NOTEQUAL);
  Branch (835:17): [True: 0, False: 0]
836
0
                case Fragment::JUST_1: return BuildScript(OP_1);
  Branch (836:17): [True: 0, False: 0]
837
0
                case Fragment::JUST_0: return BuildScript(OP_0);
  Branch (837:17): [True: 0, False: 0]
838
0
                case Fragment::AND_V: return BuildScript(std::move(subs[0]), subs[1]);
  Branch (838:17): [True: 0, False: 0]
839
0
                case Fragment::AND_B: return BuildScript(std::move(subs[0]), subs[1], OP_BOOLAND);
  Branch (839:17): [True: 0, False: 0]
840
0
                case Fragment::OR_B: return BuildScript(std::move(subs[0]), subs[1], OP_BOOLOR);
  Branch (840:17): [True: 0, False: 0]
841
0
                case Fragment::OR_D: return BuildScript(std::move(subs[0]), OP_IFDUP, OP_NOTIF, subs[1], OP_ENDIF);
  Branch (841:17): [True: 0, False: 0]
842
0
                case Fragment::OR_C: return BuildScript(std::move(subs[0]), OP_NOTIF, subs[1], OP_ENDIF);
  Branch (842:17): [True: 0, False: 0]
843
0
                case Fragment::OR_I: return BuildScript(OP_IF, subs[0], OP_ELSE, subs[1], OP_ENDIF);
  Branch (843:17): [True: 0, False: 0]
844
0
                case Fragment::ANDOR: return BuildScript(std::move(subs[0]), OP_NOTIF, subs[2], OP_ELSE, subs[1], OP_ENDIF);
  Branch (844:17): [True: 0, False: 0]
845
0
                case Fragment::MULTI: {
  Branch (845:17): [True: 0, False: 0]
846
0
                    CHECK_NONFATAL(!is_tapscript);
847
0
                    CScript script = BuildScript(node.k);
848
0
                    for (const auto& key : node.keys) {
  Branch (848:42): [True: 0, False: 0]
849
0
                        script = BuildScript(std::move(script), ctx.ToPKBytes(key));
850
0
                    }
851
0
                    return BuildScript(std::move(script), node.keys.size(), verify ? OP_CHECKMULTISIGVERIFY : OP_CHECKMULTISIG);
  Branch (851:77): [True: 0, False: 0]
852
0
                }
853
0
                case Fragment::MULTI_A: {
  Branch (853:17): [True: 0, False: 0]
854
0
                    CHECK_NONFATAL(is_tapscript);
855
0
                    CScript script = BuildScript(ctx.ToPKBytes(*node.keys.begin()), OP_CHECKSIG);
856
0
                    for (auto it = node.keys.begin() + 1; it != node.keys.end(); ++it) {
  Branch (856:59): [True: 0, False: 0]
857
0
                        script = BuildScript(std::move(script), ctx.ToPKBytes(*it), OP_CHECKSIGADD);
858
0
                    }
859
0
                    return BuildScript(std::move(script), node.k, verify ? OP_NUMEQUALVERIFY : OP_NUMEQUAL);
  Branch (859:67): [True: 0, False: 0]
860
0
                }
861
0
                case Fragment::THRESH: {
  Branch (861:17): [True: 0, False: 0]
862
0
                    CScript script = std::move(subs[0]);
863
0
                    for (size_t i = 1; i < subs.size(); ++i) {
  Branch (863:40): [True: 0, False: 0]
864
0
                        script = BuildScript(std::move(script), subs[i], OP_ADD);
865
0
                    }
866
0
                    return BuildScript(std::move(script), node.k, verify ? OP_EQUALVERIFY : OP_EQUAL);
  Branch (866:67): [True: 0, False: 0]
867
0
                }
868
0
            }
869
0
            assert(false);
  Branch (869:13): [Folded - Ignored]
870
0
        };
871
0
        return TreeEval<CScript>(false, downfn, upfn);
872
0
    }
873
874
    template<typename CTx>
875
0
    std::optional<std::string> ToString(const CTx& ctx) const {
876
0
        bool dummy{false};
877
0
        return ToString(ctx, dummy);
878
0
    }
879
880
    template<typename CTx>
881
0
    std::optional<std::string> ToString(const CTx& ctx, bool& has_priv_key) const {
882
        // To construct the std::string representation for a Miniscript object, we use
883
        // the TreeEvalMaybe algorithm. The State is a boolean: whether the parent node is a
884
        // wrapper. If so, non-wrapper expressions must be prefixed with a ":".
885
0
        auto downfn = [](bool, const Node& node, size_t) {
886
0
            return (node.fragment == Fragment::WRAP_A || node.fragment == Fragment::WRAP_S ||
  Branch (886:21): [True: 0, False: 0]
  Branch (886:58): [True: 0, False: 0]
  Branch (886:21): [True: 0, False: 0]
  Branch (886:58): [True: 0, False: 0]
887
0
                    node.fragment == Fragment::WRAP_D || node.fragment == Fragment::WRAP_V ||
  Branch (887:21): [True: 0, False: 0]
  Branch (887:58): [True: 0, False: 0]
  Branch (887:21): [True: 0, False: 0]
  Branch (887:58): [True: 0, False: 0]
888
0
                    node.fragment == Fragment::WRAP_J || node.fragment == Fragment::WRAP_N ||
  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_C ||
  Branch (889:21): [True: 0, False: 0]
  Branch (889:21): [True: 0, False: 0]
890
0
                    (node.fragment == Fragment::AND_V && node.subs[1].fragment == Fragment::JUST_1) ||
  Branch (890:22): [True: 0, False: 0]
  Branch (890:58): [True: 0, False: 0]
  Branch (890:22): [True: 0, False: 0]
  Branch (890:58): [True: 0, False: 0]
891
0
                    (node.fragment == Fragment::OR_I && node.subs[0].fragment == Fragment::JUST_0) ||
  Branch (891:22): [True: 0, False: 0]
  Branch (891:57): [True: 0, False: 0]
  Branch (891:22): [True: 0, False: 0]
  Branch (891:57): [True: 0, False: 0]
892
0
                    (node.fragment == Fragment::OR_I && node.subs[1].fragment == Fragment::JUST_0));
  Branch (892:22): [True: 0, False: 0]
  Branch (892:57): [True: 0, False: 0]
  Branch (892:22): [True: 0, False: 0]
  Branch (892:57): [True: 0, False: 0]
893
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
894
0
        auto toString = [&ctx, &has_priv_key](Key key) -> std::optional<std::string> {
895
0
            bool fragment_has_priv_key{false};
896
0
            auto key_str{ctx.ToString(key, fragment_has_priv_key)};
897
0
            if (key_str) has_priv_key = has_priv_key || fragment_has_priv_key;
  Branch (897:17): [True: 0, False: 0]
  Branch (897:41): [True: 0, False: 0]
  Branch (897:57): [True: 0, False: 0]
  Branch (897:17): [True: 0, False: 0]
  Branch (897:41): [True: 0, False: 0]
  Branch (897:57): [True: 0, False: 0]
898
0
            return key_str;
899
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
900
        // The upward function computes for a node, given whether its parent is a wrapper,
901
        // and the string representations of its child nodes, the string representation of the node.
902
0
        const bool is_tapscript{IsTapscript(m_script_ctx)};
903
0
        auto upfn = [is_tapscript, &toString](bool wrapped, const Node& node, std::span<std::string> subs) -> std::optional<std::string> {
904
0
            std::string ret = wrapped ? ":" : "";
  Branch (904:31): [True: 0, False: 0]
  Branch (904:31): [True: 0, False: 0]
905
906
0
            switch (node.fragment) {
907
0
                case Fragment::WRAP_A: return "a" + std::move(subs[0]);
  Branch (907:17): [True: 0, False: 0]
  Branch (907:17): [True: 0, False: 0]
908
0
                case Fragment::WRAP_S: return "s" + std::move(subs[0]);
  Branch (908:17): [True: 0, False: 0]
  Branch (908:17): [True: 0, False: 0]
909
0
                case Fragment::WRAP_C:
  Branch (909:17): [True: 0, False: 0]
  Branch (909:17): [True: 0, False: 0]
910
0
                    if (node.subs[0].fragment == Fragment::PK_K) {
  Branch (910:25): [True: 0, False: 0]
  Branch (910:25): [True: 0, False: 0]
911
                        // pk(K) is syntactic sugar for c:pk_k(K)
912
0
                        auto key_str = toString(node.subs[0].keys[0]);
913
0
                        if (!key_str) return {};
  Branch (913:29): [True: 0, False: 0]
  Branch (913:29): [True: 0, False: 0]
914
0
                        return std::move(ret) + "pk(" + std::move(*key_str) + ")";
915
0
                    }
916
0
                    if (node.subs[0].fragment == Fragment::PK_H) {
  Branch (916:25): [True: 0, False: 0]
  Branch (916:25): [True: 0, False: 0]
917
                        // pkh(K) is syntactic sugar for c:pk_h(K)
918
0
                        auto key_str = toString(node.subs[0].keys[0]);
919
0
                        if (!key_str) return {};
  Branch (919:29): [True: 0, False: 0]
  Branch (919:29): [True: 0, False: 0]
920
0
                        return std::move(ret) + "pkh(" + std::move(*key_str) + ")";
921
0
                    }
922
0
                    return "c" + std::move(subs[0]);
923
0
                case Fragment::WRAP_D: return "d" + std::move(subs[0]);
  Branch (923:17): [True: 0, False: 0]
  Branch (923:17): [True: 0, False: 0]
924
0
                case Fragment::WRAP_V: return "v" + std::move(subs[0]);
  Branch (924:17): [True: 0, False: 0]
  Branch (924:17): [True: 0, False: 0]
925
0
                case Fragment::WRAP_J: return "j" + std::move(subs[0]);
  Branch (925:17): [True: 0, False: 0]
  Branch (925:17): [True: 0, False: 0]
926
0
                case Fragment::WRAP_N: return "n" + std::move(subs[0]);
  Branch (926:17): [True: 0, False: 0]
  Branch (926:17): [True: 0, False: 0]
927
0
                case Fragment::AND_V:
  Branch (927:17): [True: 0, False: 0]
  Branch (927:17): [True: 0, False: 0]
928
                    // t:X is syntactic sugar for and_v(X,1).
929
0
                    if (node.subs[1].fragment == Fragment::JUST_1) return "t" + std::move(subs[0]);
  Branch (929:25): [True: 0, False: 0]
  Branch (929:25): [True: 0, False: 0]
930
0
                    break;
931
0
                case Fragment::OR_I:
  Branch (931:17): [True: 0, False: 0]
  Branch (931:17): [True: 0, False: 0]
932
0
                    if (node.subs[0].fragment == Fragment::JUST_0) return "l" + std::move(subs[1]);
  Branch (932:25): [True: 0, False: 0]
  Branch (932:25): [True: 0, False: 0]
933
0
                    if (node.subs[1].fragment == Fragment::JUST_0) return "u" + std::move(subs[0]);
  Branch (933:25): [True: 0, False: 0]
  Branch (933:25): [True: 0, False: 0]
934
0
                    break;
935
0
                default: break;
  Branch (935:17): [True: 0, False: 0]
  Branch (935:17): [True: 0, False: 0]
936
0
            }
937
0
            switch (node.fragment) {
938
0
                case Fragment::PK_K: {
  Branch (938:17): [True: 0, False: 0]
  Branch (938:17): [True: 0, False: 0]
939
0
                    auto key_str = toString(node.keys[0]);
940
0
                    if (!key_str) return {};
  Branch (940:25): [True: 0, False: 0]
  Branch (940:25): [True: 0, False: 0]
941
0
                    return std::move(ret) + "pk_k(" + std::move(*key_str) + ")";
942
0
                }
943
0
                case Fragment::PK_H: {
  Branch (943:17): [True: 0, False: 0]
  Branch (943:17): [True: 0, False: 0]
944
0
                    auto key_str = toString(node.keys[0]);
945
0
                    if (!key_str) return {};
  Branch (945:25): [True: 0, False: 0]
  Branch (945:25): [True: 0, False: 0]
946
0
                    return std::move(ret) + "pk_h(" + std::move(*key_str) + ")";
947
0
                }
948
0
                case Fragment::AFTER: return std::move(ret) + "after(" + util::ToString(node.k) + ")";
  Branch (948:17): [True: 0, False: 0]
  Branch (948:17): [True: 0, False: 0]
949
0
                case Fragment::OLDER: return std::move(ret) + "older(" + util::ToString(node.k) + ")";
  Branch (949:17): [True: 0, False: 0]
  Branch (949:17): [True: 0, False: 0]
950
0
                case Fragment::HASH256: return std::move(ret) + "hash256(" + HexStr(node.data) + ")";
  Branch (950:17): [True: 0, False: 0]
  Branch (950:17): [True: 0, False: 0]
951
0
                case Fragment::HASH160: return std::move(ret) + "hash160(" + HexStr(node.data) + ")";
  Branch (951:17): [True: 0, False: 0]
  Branch (951:17): [True: 0, False: 0]
952
0
                case Fragment::SHA256: return std::move(ret) + "sha256(" + HexStr(node.data) + ")";
  Branch (952:17): [True: 0, False: 0]
  Branch (952:17): [True: 0, False: 0]
953
0
                case Fragment::RIPEMD160: return std::move(ret) + "ripemd160(" + HexStr(node.data) + ")";
  Branch (953:17): [True: 0, False: 0]
  Branch (953:17): [True: 0, False: 0]
954
0
                case Fragment::JUST_1: return std::move(ret) + "1";
  Branch (954:17): [True: 0, False: 0]
  Branch (954:17): [True: 0, False: 0]
955
0
                case Fragment::JUST_0: return std::move(ret) + "0";
  Branch (955:17): [True: 0, False: 0]
  Branch (955:17): [True: 0, False: 0]
956
0
                case Fragment::AND_V: return std::move(ret) + "and_v(" + std::move(subs[0]) + "," + std::move(subs[1]) + ")";
  Branch (956:17): [True: 0, False: 0]
  Branch (956:17): [True: 0, False: 0]
957
0
                case Fragment::AND_B: return std::move(ret) + "and_b(" + std::move(subs[0]) + "," + std::move(subs[1]) + ")";
  Branch (957:17): [True: 0, False: 0]
  Branch (957:17): [True: 0, False: 0]
958
0
                case Fragment::OR_B: return std::move(ret) + "or_b(" + 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::OR_D: return std::move(ret) + "or_d(" + 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_C: return std::move(ret) + "or_c(" + 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_I: return std::move(ret) + "or_i(" + 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::ANDOR:
  Branch (962:17): [True: 0, False: 0]
  Branch (962:17): [True: 0, False: 0]
963
                    // and_n(X,Y) is syntactic sugar for andor(X,Y,0).
964
0
                    if (node.subs[2].fragment == Fragment::JUST_0) return std::move(ret) + "and_n(" + std::move(subs[0]) + "," + std::move(subs[1]) + ")";
  Branch (964:25): [True: 0, False: 0]
  Branch (964:25): [True: 0, False: 0]
965
0
                    return std::move(ret) + "andor(" + std::move(subs[0]) + "," + std::move(subs[1]) + "," + std::move(subs[2]) + ")";
966
0
                case Fragment::MULTI: {
  Branch (966:17): [True: 0, False: 0]
  Branch (966:17): [True: 0, False: 0]
967
0
                    CHECK_NONFATAL(!is_tapscript);
968
0
                    auto str = std::move(ret) + "multi(" + util::ToString(node.k);
969
0
                    for (const auto& key : node.keys) {
  Branch (969:42): [True: 0, False: 0]
  Branch (969:42): [True: 0, False: 0]
970
0
                        auto key_str = toString(key);
971
0
                        if (!key_str) return {};
  Branch (971:29): [True: 0, False: 0]
  Branch (971:29): [True: 0, False: 0]
972
0
                        str += "," + std::move(*key_str);
973
0
                    }
974
0
                    return std::move(str) + ")";
975
0
                }
976
0
                case Fragment::MULTI_A: {
  Branch (976:17): [True: 0, False: 0]
  Branch (976:17): [True: 0, False: 0]
977
0
                    CHECK_NONFATAL(is_tapscript);
978
0
                    auto str = std::move(ret) + "multi_a(" + util::ToString(node.k);
979
0
                    for (const auto& key : node.keys) {
  Branch (979:42): [True: 0, False: 0]
  Branch (979:42): [True: 0, False: 0]
980
0
                        auto key_str = toString(key);
981
0
                        if (!key_str) return {};
  Branch (981:29): [True: 0, False: 0]
  Branch (981:29): [True: 0, False: 0]
982
0
                        str += "," + std::move(*key_str);
983
0
                    }
984
0
                    return std::move(str) + ")";
985
0
                }
986
0
                case Fragment::THRESH: {
  Branch (986:17): [True: 0, False: 0]
  Branch (986:17): [True: 0, False: 0]
987
0
                    auto str = std::move(ret) + "thresh(" + util::ToString(node.k);
988
0
                    for (auto& sub : subs) {
  Branch (988:36): [True: 0, False: 0]
  Branch (988:36): [True: 0, False: 0]
989
0
                        str += "," + std::move(sub);
990
0
                    }
991
0
                    return std::move(str) + ")";
992
0
                }
993
0
                default: break;
  Branch (993:17): [True: 0, False: 0]
  Branch (993:17): [True: 0, False: 0]
994
0
            }
995
0
            assert(false);
  Branch (995:13): [Folded - Ignored]
  Branch (995:13): [Folded - Ignored]
996
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
997
998
0
        return TreeEvalMaybe<std::string>(false, downfn, upfn);
999
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
1000
1001
private:
1002
0
    internal::Ops CalcOps() const {
1003
0
        switch (fragment) {
  Branch (1003:17): [True: 0, False: 0]
  Branch (1003:17): [True: 0, False: 0]
  Branch (1003:17): [True: 0, False: 0]
1004
0
            case Fragment::JUST_1: return {0, 0, {}};
  Branch (1004:13): [True: 0, False: 0]
  Branch (1004:13): [True: 0, False: 0]
  Branch (1004:13): [True: 0, False: 0]
1005
0
            case Fragment::JUST_0: return {0, {}, 0};
  Branch (1005:13): [True: 0, False: 0]
  Branch (1005:13): [True: 0, False: 0]
  Branch (1005:13): [True: 0, False: 0]
1006
0
            case Fragment::PK_K: return {0, 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::PK_H: return {3, 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::OLDER:
  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::AFTER: return {1, 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::SHA256:
  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::RIPEMD160:
  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::HASH256:
  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::HASH160: return {4, 0, {}};
  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::AND_V: return {subs[0].ops.count + subs[1].ops.count, subs[0].ops.sat + subs[1].ops.sat, {}};
  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::AND_B: {
  Branch (1015:13): [True: 0, False: 0]
  Branch (1015:13): [True: 0, False: 0]
  Branch (1015:13): [True: 0, False: 0]
1016
0
                const auto count{1 + subs[0].ops.count + subs[1].ops.count};
1017
0
                const auto sat{subs[0].ops.sat + subs[1].ops.sat};
1018
0
                const auto dsat{subs[0].ops.dsat + subs[1].ops.dsat};
1019
0
                return {count, sat, dsat};
1020
0
            }
1021
0
            case Fragment::OR_B: {
  Branch (1021:13): [True: 0, False: 0]
  Branch (1021:13): [True: 0, False: 0]
  Branch (1021:13): [True: 0, False: 0]
1022
0
                const auto count{1 + subs[0].ops.count + subs[1].ops.count};
1023
0
                const auto sat{(subs[0].ops.sat + subs[1].ops.dsat) | (subs[1].ops.sat + subs[0].ops.dsat)};
1024
0
                const auto dsat{subs[0].ops.dsat + subs[1].ops.dsat};
1025
0
                return {count, sat, dsat};
1026
0
            }
1027
0
            case Fragment::OR_D: {
  Branch (1027:13): [True: 0, False: 0]
  Branch (1027:13): [True: 0, False: 0]
  Branch (1027:13): [True: 0, False: 0]
1028
0
                const auto count{3 + subs[0].ops.count + subs[1].ops.count};
1029
0
                const auto sat{subs[0].ops.sat | (subs[1].ops.sat + subs[0].ops.dsat)};
1030
0
                const auto dsat{subs[0].ops.dsat + subs[1].ops.dsat};
1031
0
                return {count, sat, dsat};
1032
0
            }
1033
0
            case Fragment::OR_C: {
  Branch (1033:13): [True: 0, False: 0]
  Branch (1033:13): [True: 0, False: 0]
  Branch (1033:13): [True: 0, False: 0]
1034
0
                const auto count{2 + subs[0].ops.count + subs[1].ops.count};
1035
0
                const auto sat{subs[0].ops.sat | (subs[1].ops.sat + subs[0].ops.dsat)};
1036
0
                return {count, sat, {}};
1037
0
            }
1038
0
            case Fragment::OR_I: {
  Branch (1038:13): [True: 0, False: 0]
  Branch (1038:13): [True: 0, False: 0]
  Branch (1038:13): [True: 0, False: 0]
1039
0
                const auto count{3 + subs[0].ops.count + subs[1].ops.count};
1040
0
                const auto sat{subs[0].ops.sat | subs[1].ops.sat};
1041
0
                const auto dsat{subs[0].ops.dsat | subs[1].ops.dsat};
1042
0
                return {count, sat, dsat};
1043
0
            }
1044
0
            case Fragment::ANDOR: {
  Branch (1044:13): [True: 0, False: 0]
  Branch (1044:13): [True: 0, False: 0]
  Branch (1044:13): [True: 0, False: 0]
1045
0
                const auto count{3 + subs[0].ops.count + subs[1].ops.count + subs[2].ops.count};
1046
0
                const auto sat{(subs[1].ops.sat + subs[0].ops.sat) | (subs[0].ops.dsat + subs[2].ops.sat)};
1047
0
                const auto dsat{subs[0].ops.dsat + subs[2].ops.dsat};
1048
0
                return {count, sat, dsat};
1049
0
            }
1050
0
            case Fragment::MULTI: return {1, (uint32_t)keys.size(), (uint32_t)keys.size()};
  Branch (1050:13): [True: 0, False: 0]
  Branch (1050:13): [True: 0, False: 0]
  Branch (1050:13): [True: 0, False: 0]
1051
0
            case Fragment::MULTI_A: return {(uint32_t)keys.size() + 1, 0, 0};
  Branch (1051:13): [True: 0, False: 0]
  Branch (1051:13): [True: 0, False: 0]
  Branch (1051:13): [True: 0, False: 0]
1052
0
            case Fragment::WRAP_S:
  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::WRAP_C:
  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_N: return {1 + subs[0].ops.count, subs[0].ops.sat, subs[0].ops.dsat};
  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_A: return {2 + subs[0].ops.count, subs[0].ops.sat, subs[0].ops.dsat};
  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_D: return {3 + subs[0].ops.count, subs[0].ops.sat, 0};
  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_J: return {4 + subs[0].ops.count, subs[0].ops.sat, 0};
  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_V: return {subs[0].ops.count + (subs[0].GetType() << "x"_mst), subs[0].ops.sat, {}};
  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::THRESH: {
  Branch (1059:13): [True: 0, False: 0]
  Branch (1059:13): [True: 0, False: 0]
  Branch (1059:13): [True: 0, False: 0]
1060
0
                uint32_t count = 0;
1061
0
                auto sats = Vector(internal::MaxInt<uint32_t>(0));
1062
0
                for (const auto& sub : subs) {
  Branch (1062:38): [True: 0, False: 0]
  Branch (1062:38): [True: 0, False: 0]
  Branch (1062:38): [True: 0, False: 0]
1063
0
                    count += sub.ops.count + 1;
1064
0
                    auto next_sats = Vector(sats[0] + sub.ops.dsat);
1065
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 (1065:40): [True: 0, False: 0]
  Branch (1065:40): [True: 0, False: 0]
  Branch (1065:40): [True: 0, False: 0]
1066
0
                    next_sats.push_back(sats[sats.size() - 1] + sub.ops.sat);
1067
0
                    sats = std::move(next_sats);
1068
0
                }
1069
0
                assert(k < sats.size());
  Branch (1069:17): [True: 0, False: 0]
  Branch (1069:17): [True: 0, False: 0]
  Branch (1069:17): [True: 0, False: 0]
1070
0
                return {count, sats[k], sats[0]};
1071
0
            }
1072
0
        }
1073
0
        assert(false);
  Branch (1073:9): [Folded - Ignored]
  Branch (1073:9): [Folded - Ignored]
  Branch (1073:9): [Folded - Ignored]
1074
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::CalcOps() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::CalcOps() const
Unexecuted instantiation: miniscript::Node<CPubKey>::CalcOps() const
1075
1076
0
    internal::StackSize CalcStackSize() const {
1077
0
        using namespace internal;
1078
0
        switch (fragment) {
  Branch (1078:17): [True: 0, False: 0]
  Branch (1078:17): [True: 0, False: 0]
  Branch (1078:17): [True: 0, False: 0]
1079
0
            case Fragment::JUST_0: return {{}, SatInfo::Push()};
  Branch (1079:13): [True: 0, False: 0]
  Branch (1079:13): [True: 0, False: 0]
  Branch (1079:13): [True: 0, False: 0]
1080
0
            case Fragment::JUST_1: return {SatInfo::Push(), {}};
  Branch (1080:13): [True: 0, False: 0]
  Branch (1080:13): [True: 0, False: 0]
  Branch (1080:13): [True: 0, False: 0]
1081
0
            case Fragment::OLDER:
  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::AFTER: return {SatInfo::Push() + SatInfo::Nop(), {}};
  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::PK_K: return {SatInfo::Push()};
  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::PK_H: return {SatInfo::OP_DUP() + SatInfo::Hash() + SatInfo::Push() + SatInfo::OP_EQUALVERIFY()};
  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::SHA256:
  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::RIPEMD160:
  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::HASH256:
  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::HASH160: return {
  Branch (1088:13): [True: 0, False: 0]
  Branch (1088:13): [True: 0, False: 0]
  Branch (1088:13): [True: 0, False: 0]
1089
0
                SatInfo::OP_SIZE() + SatInfo::Push() + SatInfo::OP_EQUALVERIFY() + SatInfo::Hash() + SatInfo::Push() + SatInfo::OP_EQUAL(),
1090
0
                {}
1091
0
            };
1092
0
            case Fragment::ANDOR: {
  Branch (1092:13): [True: 0, False: 0]
  Branch (1092:13): [True: 0, False: 0]
  Branch (1092:13): [True: 0, False: 0]
1093
0
                const auto& x{subs[0].ss};
1094
0
                const auto& y{subs[1].ss};
1095
0
                const auto& z{subs[2].ss};
1096
0
                return {
1097
0
                    (x.Sat() + SatInfo::If() + y.Sat()) | (x.Dsat() + SatInfo::If() + z.Sat()),
1098
0
                    x.Dsat() + SatInfo::If() + z.Dsat()
1099
0
                };
1100
0
            }
1101
0
            case Fragment::AND_V: {
  Branch (1101:13): [True: 0, False: 0]
  Branch (1101:13): [True: 0, False: 0]
  Branch (1101:13): [True: 0, False: 0]
1102
0
                const auto& x{subs[0].ss};
1103
0
                const auto& y{subs[1].ss};
1104
0
                return {x.Sat() + y.Sat(), {}};
1105
0
            }
1106
0
            case Fragment::AND_B: {
  Branch (1106:13): [True: 0, False: 0]
  Branch (1106:13): [True: 0, False: 0]
  Branch (1106:13): [True: 0, False: 0]
1107
0
                const auto& x{subs[0].ss};
1108
0
                const auto& y{subs[1].ss};
1109
0
                return {x.Sat() + y.Sat() + SatInfo::BinaryOp(), x.Dsat() + y.Dsat() + SatInfo::BinaryOp()};
1110
0
            }
1111
0
            case Fragment::OR_B: {
  Branch (1111:13): [True: 0, False: 0]
  Branch (1111:13): [True: 0, False: 0]
  Branch (1111:13): [True: 0, False: 0]
1112
0
                const auto& x{subs[0].ss};
1113
0
                const auto& y{subs[1].ss};
1114
0
                return {
1115
0
                    ((x.Sat() + y.Dsat()) | (x.Dsat() + y.Sat())) + SatInfo::BinaryOp(),
1116
0
                    x.Dsat() + y.Dsat() + SatInfo::BinaryOp()
1117
0
                };
1118
0
            }
1119
0
            case Fragment::OR_C: {
  Branch (1119:13): [True: 0, False: 0]
  Branch (1119:13): [True: 0, False: 0]
  Branch (1119:13): [True: 0, False: 0]
1120
0
                const auto& x{subs[0].ss};
1121
0
                const auto& y{subs[1].ss};
1122
0
                return {(x.Sat() + SatInfo::If()) | (x.Dsat() + SatInfo::If() + y.Sat()), {}};
1123
0
            }
1124
0
            case Fragment::OR_D: {
  Branch (1124:13): [True: 0, False: 0]
  Branch (1124:13): [True: 0, False: 0]
  Branch (1124:13): [True: 0, False: 0]
1125
0
                const auto& x{subs[0].ss};
1126
0
                const auto& y{subs[1].ss};
1127
0
                return {
1128
0
                    (x.Sat() + SatInfo::OP_IFDUP(true) + SatInfo::If()) | (x.Dsat() + SatInfo::OP_IFDUP(false) + SatInfo::If() + y.Sat()),
1129
0
                    x.Dsat() + SatInfo::OP_IFDUP(false) + SatInfo::If() + y.Dsat()
1130
0
                };
1131
0
            }
1132
0
            case Fragment::OR_I: {
  Branch (1132:13): [True: 0, False: 0]
  Branch (1132:13): [True: 0, False: 0]
  Branch (1132:13): [True: 0, False: 0]
1133
0
                const auto& x{subs[0].ss};
1134
0
                const auto& y{subs[1].ss};
1135
0
                return {SatInfo::If() + (x.Sat() | y.Sat()), SatInfo::If() + (x.Dsat() | y.Dsat())};
1136
0
            }
1137
            // multi(k, key1, key2, ..., key_n) starts off with k+1 stack elements (a 0, plus k
1138
            // signatures), then reaches n+k+3 stack elements after pushing the n keys, plus k and
1139
            // n itself, and ends with 1 stack element (success or failure). Thus, it net removes
1140
            // k elements (from k+1 to 1), while reaching k+n+2 more than it ends with.
1141
0
            case Fragment::MULTI: return {SatInfo(k, k + keys.size() + 2)};
  Branch (1141:13): [True: 0, False: 0]
  Branch (1141:13): [True: 0, False: 0]
  Branch (1141:13): [True: 0, False: 0]
1142
            // multi_a(k, key1, key2, ..., key_n) starts off with n stack elements (the
1143
            // signatures), reaches 1 more (after the first key push), and ends with 1. Thus it net
1144
            // removes n-1 elements (from n to 1) while reaching n more than it ends with.
1145
0
            case Fragment::MULTI_A: return {SatInfo(keys.size() - 1, keys.size())};
  Branch (1145:13): [True: 0, False: 0]
  Branch (1145:13): [True: 0, False: 0]
  Branch (1145:13): [True: 0, False: 0]
1146
0
            case Fragment::WRAP_A:
  Branch (1146:13): [True: 0, False: 0]
  Branch (1146:13): [True: 0, False: 0]
  Branch (1146:13): [True: 0, False: 0]
1147
0
            case Fragment::WRAP_N:
  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_S: return subs[0].ss;
  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_C: return {
  Branch (1149:13): [True: 0, False: 0]
  Branch (1149:13): [True: 0, False: 0]
  Branch (1149:13): [True: 0, False: 0]
1150
0
                subs[0].ss.Sat() + SatInfo::OP_CHECKSIG(),
1151
0
                subs[0].ss.Dsat() + SatInfo::OP_CHECKSIG()
1152
0
            };
1153
0
            case Fragment::WRAP_D: return {
  Branch (1153:13): [True: 0, False: 0]
  Branch (1153:13): [True: 0, False: 0]
  Branch (1153:13): [True: 0, False: 0]
1154
0
                SatInfo::OP_DUP() + SatInfo::If() + subs[0].ss.Sat(),
1155
0
                SatInfo::OP_DUP() + SatInfo::If()
1156
0
            };
1157
0
            case Fragment::WRAP_V: return {subs[0].ss.Sat() + SatInfo::OP_VERIFY(), {}};
  Branch (1157:13): [True: 0, False: 0]
  Branch (1157:13): [True: 0, False: 0]
  Branch (1157:13): [True: 0, False: 0]
1158
0
            case Fragment::WRAP_J: return {
  Branch (1158:13): [True: 0, False: 0]
  Branch (1158:13): [True: 0, False: 0]
  Branch (1158:13): [True: 0, False: 0]
1159
0
                SatInfo::OP_SIZE() + SatInfo::OP_0NOTEQUAL() + SatInfo::If() + subs[0].ss.Sat(),
1160
0
                SatInfo::OP_SIZE() + SatInfo::OP_0NOTEQUAL() + SatInfo::If()
1161
0
            };
1162
0
            case Fragment::THRESH: {
  Branch (1162:13): [True: 0, False: 0]
  Branch (1162:13): [True: 0, False: 0]
  Branch (1162:13): [True: 0, False: 0]
1163
                // sats[j] is the SatInfo corresponding to all traces reaching j satisfactions.
1164
0
                auto sats = Vector(SatInfo::Empty());
1165
0
                for (size_t i = 0; i < subs.size(); ++i) {
  Branch (1165:36): [True: 0, False: 0]
  Branch (1165:36): [True: 0, False: 0]
  Branch (1165:36): [True: 0, False: 0]
1166
                    // Loop over the subexpressions, processing them one by one. After adding
1167
                    // element i we need to add OP_ADD (if i>0).
1168
0
                    auto add = i ? SatInfo::BinaryOp() : SatInfo::Empty();
  Branch (1168:32): [True: 0, False: 0]
  Branch (1168:32): [True: 0, False: 0]
  Branch (1168:32): [True: 0, False: 0]
1169
                    // Construct a variable that will become the next sats, starting with index 0.
1170
0
                    auto next_sats = Vector(sats[0] + subs[i].ss.Dsat() + add);
1171
                    // Then loop to construct next_sats[1..i].
1172
0
                    for (size_t j = 1; j < sats.size(); ++j) {
  Branch (1172:40): [True: 0, False: 0]
  Branch (1172:40): [True: 0, False: 0]
  Branch (1172:40): [True: 0, False: 0]
1173
0
                        next_sats.push_back(((sats[j] + subs[i].ss.Dsat()) | (sats[j - 1] + subs[i].ss.Sat())) + add);
1174
0
                    }
1175
                    // Finally construct next_sats[i+1].
1176
0
                    next_sats.push_back(sats[sats.size() - 1] + subs[i].ss.Sat() + add);
1177
                    // Switch over.
1178
0
                    sats = std::move(next_sats);
1179
0
                }
1180
                // To satisfy thresh we need k satisfactions; to dissatisfy we need 0. In both
1181
                // cases a push of k and an OP_EQUAL follow.
1182
0
                return {
1183
0
                    sats[k] + SatInfo::Push() + SatInfo::OP_EQUAL(),
1184
0
                    sats[0] + SatInfo::Push() + SatInfo::OP_EQUAL()
1185
0
                };
1186
0
            }
1187
0
        }
1188
0
        assert(false);
  Branch (1188:9): [Folded - Ignored]
  Branch (1188:9): [Folded - Ignored]
  Branch (1188:9): [Folded - Ignored]
1189
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::CalcStackSize() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::CalcStackSize() const
Unexecuted instantiation: miniscript::Node<CPubKey>::CalcStackSize() const
1190
1191
0
    internal::WitnessSize CalcWitnessSize() const {
1192
0
        const uint32_t sig_size = IsTapscript(m_script_ctx) ? 1 + 65 : 1 + 72;
  Branch (1192:35): [True: 0, False: 0]
  Branch (1192:35): [True: 0, False: 0]
  Branch (1192:35): [True: 0, False: 0]
1193
0
        const uint32_t pubkey_size = IsTapscript(m_script_ctx) ? 1 + 32 : 1 + 33;
  Branch (1193:38): [True: 0, False: 0]
  Branch (1193:38): [True: 0, False: 0]
  Branch (1193:38): [True: 0, False: 0]
1194
0
        switch (fragment) {
  Branch (1194:17): [True: 0, False: 0]
  Branch (1194:17): [True: 0, False: 0]
  Branch (1194:17): [True: 0, False: 0]
1195
0
            case Fragment::JUST_0: return {{}, 0};
  Branch (1195:13): [True: 0, False: 0]
  Branch (1195:13): [True: 0, False: 0]
  Branch (1195:13): [True: 0, False: 0]
1196
0
            case Fragment::JUST_1:
  Branch (1196:13): [True: 0, False: 0]
  Branch (1196:13): [True: 0, False: 0]
  Branch (1196:13): [True: 0, False: 0]
1197
0
            case Fragment::OLDER:
  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::AFTER: return {0, {}};
  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::PK_K: return {sig_size, 1};
  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::PK_H: return {sig_size + pubkey_size, 1 + pubkey_size};
  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::SHA256:
  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::RIPEMD160:
  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::HASH256:
  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::HASH160: return {1 + 32, {}};
  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::ANDOR: {
  Branch (1205:13): [True: 0, False: 0]
  Branch (1205:13): [True: 0, False: 0]
  Branch (1205:13): [True: 0, False: 0]
1206
0
                const auto sat{(subs[0].ws.sat + subs[1].ws.sat) | (subs[0].ws.dsat + subs[2].ws.sat)};
1207
0
                const auto dsat{subs[0].ws.dsat + subs[2].ws.dsat};
1208
0
                return {sat, dsat};
1209
0
            }
1210
0
            case Fragment::AND_V: return {subs[0].ws.sat + subs[1].ws.sat, {}};
  Branch (1210:13): [True: 0, False: 0]
  Branch (1210:13): [True: 0, False: 0]
  Branch (1210:13): [True: 0, False: 0]
1211
0
            case Fragment::AND_B: return {subs[0].ws.sat + subs[1].ws.sat, subs[0].ws.dsat + subs[1].ws.dsat};
  Branch (1211:13): [True: 0, False: 0]
  Branch (1211:13): [True: 0, False: 0]
  Branch (1211:13): [True: 0, False: 0]
1212
0
            case Fragment::OR_B: {
  Branch (1212:13): [True: 0, False: 0]
  Branch (1212:13): [True: 0, False: 0]
  Branch (1212:13): [True: 0, False: 0]
1213
0
                const auto sat{(subs[0].ws.dsat + subs[1].ws.sat) | (subs[0].ws.sat + subs[1].ws.dsat)};
1214
0
                const auto dsat{subs[0].ws.dsat + subs[1].ws.dsat};
1215
0
                return {sat, dsat};
1216
0
            }
1217
0
            case Fragment::OR_C: return {subs[0].ws.sat | (subs[0].ws.dsat + subs[1].ws.sat), {}};
  Branch (1217:13): [True: 0, False: 0]
  Branch (1217:13): [True: 0, False: 0]
  Branch (1217:13): [True: 0, False: 0]
1218
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 (1218:13): [True: 0, False: 0]
  Branch (1218:13): [True: 0, False: 0]
  Branch (1218:13): [True: 0, False: 0]
1219
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 (1219:13): [True: 0, False: 0]
  Branch (1219:13): [True: 0, False: 0]
  Branch (1219:13): [True: 0, False: 0]
1220
0
            case Fragment::MULTI: return {k * sig_size + 1, k + 1};
  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::MULTI_A: return {k * sig_size + static_cast<uint32_t>(keys.size()) - k, static_cast<uint32_t>(keys.size())};
  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::WRAP_A:
  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::WRAP_N:
  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_S:
  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_C: return subs[0].ws;
  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_D: return {1 + 1 + subs[0].ws.sat, 1};
  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_V: return {subs[0].ws.sat, {}};
  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_J: return {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::THRESH: {
  Branch (1229:13): [True: 0, False: 0]
  Branch (1229:13): [True: 0, False: 0]
  Branch (1229:13): [True: 0, False: 0]
1230
0
                auto sats = Vector(internal::MaxInt<uint32_t>(0));
1231
0
                for (const auto& sub : subs) {
  Branch (1231:38): [True: 0, False: 0]
  Branch (1231:38): [True: 0, False: 0]
  Branch (1231:38): [True: 0, False: 0]
1232
0
                    auto next_sats = Vector(sats[0] + sub.ws.dsat);
1233
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 (1233:40): [True: 0, False: 0]
  Branch (1233:40): [True: 0, False: 0]
  Branch (1233:40): [True: 0, False: 0]
1234
0
                    next_sats.push_back(sats[sats.size() - 1] + sub.ws.sat);
1235
0
                    sats = std::move(next_sats);
1236
0
                }
1237
0
                assert(k < sats.size());
  Branch (1237:17): [True: 0, False: 0]
  Branch (1237:17): [True: 0, False: 0]
  Branch (1237:17): [True: 0, False: 0]
1238
0
                return {sats[k], sats[0]};
1239
0
            }
1240
0
        }
1241
0
        assert(false);
  Branch (1241:9): [Folded - Ignored]
  Branch (1241:9): [Folded - Ignored]
  Branch (1241:9): [Folded - Ignored]
1242
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::CalcWitnessSize() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::CalcWitnessSize() const
Unexecuted instantiation: miniscript::Node<CPubKey>::CalcWitnessSize() const
1243
1244
    template<typename Ctx>
1245
0
    internal::InputResult ProduceInput(const Ctx& ctx) const {
1246
0
        using namespace internal;
1247
1248
        // Internal function which is invoked for every tree node, constructing satisfaction/dissatisfactions
1249
        // given those of its subnodes.
1250
0
        auto helper = [&ctx](const Node& node, std::span<InputResult> subres) -> InputResult {
1251
0
            switch (node.fragment) {
  Branch (1251:21): [True: 0, False: 0]
  Branch (1251:21): [True: 0, False: 0]
1252
0
                case Fragment::PK_K: {
  Branch (1252:17): [True: 0, False: 0]
  Branch (1252:17): [True: 0, False: 0]
1253
0
                    std::vector<unsigned char> sig;
1254
0
                    Availability avail = ctx.Sign(node.keys[0], sig);
1255
0
                    return {ZERO, InputStack(std::move(sig)).SetWithSig().SetAvailable(avail)};
1256
0
                }
1257
0
                case Fragment::PK_H: {
  Branch (1257:17): [True: 0, False: 0]
  Branch (1257:17): [True: 0, False: 0]
1258
0
                    std::vector<unsigned char> key = ctx.ToPKBytes(node.keys[0]), sig;
1259
0
                    Availability avail = ctx.Sign(node.keys[0], sig);
1260
0
                    return {ZERO + InputStack(key), (InputStack(std::move(sig)).SetWithSig() + InputStack(key)).SetAvailable(avail)};
1261
0
                }
1262
0
                case Fragment::MULTI_A: {
  Branch (1262:17): [True: 0, False: 0]
  Branch (1262:17): [True: 0, False: 0]
1263
                    // sats[j] represents the best stack containing j valid signatures (out of the first i keys).
1264
                    // In the loop below, these stacks are built up using a dynamic programming approach.
1265
0
                    std::vector<InputStack> sats = Vector(EMPTY);
1266
0
                    for (size_t i = 0; i < node.keys.size(); ++i) {
  Branch (1266:40): [True: 0, False: 0]
  Branch (1266:40): [True: 0, False: 0]
1267
                        // Get the signature for the i'th key in reverse order (the signature for the first key needs to
1268
                        // be at the top of the stack, contrary to CHECKMULTISIG's satisfaction).
1269
0
                        std::vector<unsigned char> sig;
1270
0
                        Availability avail = ctx.Sign(node.keys[node.keys.size() - 1 - i], sig);
1271
                        // Compute signature stack for just this key.
1272
0
                        auto sat = InputStack(std::move(sig)).SetWithSig().SetAvailable(avail);
1273
                        // Compute the next sats vector: next_sats[0] is a copy of sats[0] (no signatures). All further
1274
                        // next_sats[j] are equal to either the existing sats[j] + ZERO, or sats[j-1] plus a signature
1275
                        // for the current (i'th) key. The very last element needs all signatures filled.
1276
0
                        std::vector<InputStack> next_sats;
1277
0
                        next_sats.push_back(sats[0] + ZERO);
1278
0
                        for (size_t j = 1; j < sats.size(); ++j) next_sats.push_back((sats[j] + ZERO) | (std::move(sats[j - 1]) + sat));
  Branch (1278:44): [True: 0, False: 0]
  Branch (1278:44): [True: 0, False: 0]
1279
0
                        next_sats.push_back(std::move(sats[sats.size() - 1]) + std::move(sat));
1280
                        // Switch over.
1281
0
                        sats = std::move(next_sats);
1282
0
                    }
1283
                    // The dissatisfaction consists of as many empty vectors as there are keys, which is the same as
1284
                    // satisfying 0 keys.
1285
0
                    auto& nsat{sats[0]};
1286
0
                    CHECK_NONFATAL(node.k != 0);
1287
0
                    assert(node.k < sats.size());
  Branch (1287:21): [True: 0, False: 0]
  Branch (1287:21): [True: 0, False: 0]
1288
0
                    return {std::move(nsat), std::move(sats[node.k])};
1289
0
                }
1290
0
                case Fragment::MULTI: {
  Branch (1290:17): [True: 0, False: 0]
  Branch (1290:17): [True: 0, False: 0]
1291
                    // sats[j] represents the best stack containing j valid signatures (out of the first i keys).
1292
                    // In the loop below, these stacks are built up using a dynamic programming approach.
1293
                    // sats[0] starts off being {0}, due to the CHECKMULTISIG bug that pops off one element too many.
1294
0
                    std::vector<InputStack> sats = Vector(ZERO);
1295
0
                    for (size_t i = 0; i < node.keys.size(); ++i) {
  Branch (1295:40): [True: 0, False: 0]
  Branch (1295:40): [True: 0, False: 0]
1296
0
                        std::vector<unsigned char> sig;
1297
0
                        Availability avail = ctx.Sign(node.keys[i], sig);
1298
                        // Compute signature stack for just the i'th key.
1299
0
                        auto sat = InputStack(std::move(sig)).SetWithSig().SetAvailable(avail);
1300
                        // Compute the next sats vector: next_sats[0] is a copy of sats[0] (no signatures). All further
1301
                        // next_sats[j] are equal to either the existing sats[j], or sats[j-1] plus a signature for the
1302
                        // current (i'th) key. The very last element needs all signatures filled.
1303
0
                        std::vector<InputStack> next_sats;
1304
0
                        next_sats.push_back(sats[0]);
1305
0
                        for (size_t j = 1; j < sats.size(); ++j) next_sats.push_back(sats[j] | (std::move(sats[j - 1]) + sat));
  Branch (1305:44): [True: 0, False: 0]
  Branch (1305:44): [True: 0, False: 0]
1306
0
                        next_sats.push_back(std::move(sats[sats.size() - 1]) + std::move(sat));
1307
                        // Switch over.
1308
0
                        sats = std::move(next_sats);
1309
0
                    }
1310
                    // The dissatisfaction consists of k+1 stack elements all equal to 0.
1311
0
                    InputStack nsat = ZERO;
1312
0
                    for (size_t i = 0; i < node.k; ++i) nsat = std::move(nsat) + ZERO;
  Branch (1312:40): [True: 0, False: 0]
  Branch (1312:40): [True: 0, False: 0]
1313
0
                    assert(node.k < sats.size());
  Branch (1313:21): [True: 0, False: 0]
  Branch (1313:21): [True: 0, False: 0]
1314
0
                    return {std::move(nsat), std::move(sats[node.k])};
1315
0
                }
1316
0
                case Fragment::THRESH: {
  Branch (1316:17): [True: 0, False: 0]
  Branch (1316:17): [True: 0, False: 0]
1317
                    // sats[k] represents the best stack that satisfies k out of the *last* i subexpressions.
1318
                    // In the loop below, these stacks are built up using a dynamic programming approach.
1319
                    // sats[0] starts off empty.
1320
0
                    std::vector<InputStack> sats = Vector(EMPTY);
1321
0
                    for (size_t i = 0; i < subres.size(); ++i) {
  Branch (1321:40): [True: 0, False: 0]
  Branch (1321:40): [True: 0, False: 0]
1322
                        // Introduce an alias for the i'th last satisfaction/dissatisfaction.
1323
0
                        auto& res = subres[subres.size() - i - 1];
1324
                        // Compute the next sats vector: next_sats[0] is sats[0] plus res.nsat (thus containing all dissatisfactions
1325
                        // so far. next_sats[j] is either sats[j] + res.nsat (reusing j earlier satisfactions) or sats[j-1] + res.sat
1326
                        // (reusing j-1 earlier satisfactions plus a new one). The very last next_sats[j] is all satisfactions.
1327
0
                        std::vector<InputStack> next_sats;
1328
0
                        next_sats.push_back(sats[0] + res.nsat);
1329
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 (1329:44): [True: 0, False: 0]
  Branch (1329:44): [True: 0, False: 0]
1330
0
                        next_sats.push_back(std::move(sats[sats.size() - 1]) + std::move(res.sat));
1331
                        // Switch over.
1332
0
                        sats = std::move(next_sats);
1333
0
                    }
1334
                    // At this point, sats[k].sat is the best satisfaction for the overall thresh() node. The best dissatisfaction
1335
                    // is computed by gathering all sats[i].nsat for i != k.
1336
0
                    InputStack nsat = INVALID;
1337
0
                    for (size_t i = 0; i < sats.size(); ++i) {
  Branch (1337:40): [True: 0, False: 0]
  Branch (1337:40): [True: 0, False: 0]
1338
                        // i==k is the satisfaction; i==0 is the canonical dissatisfaction;
1339
                        // the rest are non-canonical (a no-signature dissatisfaction - the i=0
1340
                        // form - is always available) and malleable (due to overcompleteness).
1341
                        // Marking the solutions malleable here is not strictly necessary, as they
1342
                        // should already never be picked in non-malleable solutions due to the
1343
                        // availability of the i=0 form.
1344
0
                        if (i != 0 && i != node.k) sats[i].SetMalleable().SetNonCanon();
  Branch (1344:29): [True: 0, False: 0]
  Branch (1344:39): [True: 0, False: 0]
  Branch (1344:29): [True: 0, False: 0]
  Branch (1344:39): [True: 0, False: 0]
1345
                        // Include all dissatisfactions (even these non-canonical ones) in nsat.
1346
0
                        if (i != node.k) nsat = std::move(nsat) | std::move(sats[i]);
  Branch (1346:29): [True: 0, False: 0]
  Branch (1346:29): [True: 0, False: 0]
1347
0
                    }
1348
0
                    assert(node.k < sats.size());
  Branch (1348:21): [True: 0, False: 0]
  Branch (1348:21): [True: 0, False: 0]
1349
0
                    return {std::move(nsat), std::move(sats[node.k])};
1350
0
                }
1351
0
                case Fragment::OLDER: {
  Branch (1351:17): [True: 0, False: 0]
  Branch (1351:17): [True: 0, False: 0]
1352
0
                    return {INVALID, ctx.CheckOlder(node.k) ? EMPTY : INVALID};
  Branch (1352:38): [True: 0, False: 0]
  Branch (1352:38): [True: 0, False: 0]
1353
0
                }
1354
0
                case Fragment::AFTER: {
  Branch (1354:17): [True: 0, False: 0]
  Branch (1354:17): [True: 0, False: 0]
1355
0
                    return {INVALID, ctx.CheckAfter(node.k) ? EMPTY : INVALID};
  Branch (1355:38): [True: 0, False: 0]
  Branch (1355:38): [True: 0, False: 0]
1356
0
                }
1357
0
                case Fragment::SHA256: {
  Branch (1357:17): [True: 0, False: 0]
  Branch (1357:17): [True: 0, False: 0]
1358
0
                    std::vector<unsigned char> preimage;
1359
0
                    Availability avail = ctx.SatSHA256(node.data, preimage);
1360
0
                    return {ZERO32, InputStack(std::move(preimage)).SetAvailable(avail)};
1361
0
                }
1362
0
                case Fragment::RIPEMD160: {
  Branch (1362:17): [True: 0, False: 0]
  Branch (1362:17): [True: 0, False: 0]
1363
0
                    std::vector<unsigned char> preimage;
1364
0
                    Availability avail = ctx.SatRIPEMD160(node.data, preimage);
1365
0
                    return {ZERO32, InputStack(std::move(preimage)).SetAvailable(avail)};
1366
0
                }
1367
0
                case Fragment::HASH256: {
  Branch (1367:17): [True: 0, False: 0]
  Branch (1367:17): [True: 0, False: 0]
1368
0
                    std::vector<unsigned char> preimage;
1369
0
                    Availability avail = ctx.SatHASH256(node.data, preimage);
1370
0
                    return {ZERO32, InputStack(std::move(preimage)).SetAvailable(avail)};
1371
0
                }
1372
0
                case Fragment::HASH160: {
  Branch (1372:17): [True: 0, False: 0]
  Branch (1372:17): [True: 0, False: 0]
1373
0
                    std::vector<unsigned char> preimage;
1374
0
                    Availability avail = ctx.SatHASH160(node.data, preimage);
1375
0
                    return {ZERO32, InputStack(std::move(preimage)).SetAvailable(avail)};
1376
0
                }
1377
0
                case Fragment::AND_V: {
  Branch (1377:17): [True: 0, False: 0]
  Branch (1377:17): [True: 0, False: 0]
1378
0
                    auto& x = subres[0], &y = subres[1];
1379
                    // As the dissatisfaction here only consist of a single option, it doesn't
1380
                    // actually need to be listed (it's not required for reasoning about malleability of
1381
                    // other options), and is never required (no valid miniscript relies on the ability
1382
                    // to satisfy the type V left subexpression). It's still listed here for
1383
                    // completeness, as a hypothetical (not currently implemented) satisfier that doesn't
1384
                    // care about malleability might in some cases prefer it still.
1385
0
                    return {(y.nsat + x.sat).SetNonCanon(), y.sat + x.sat};
1386
0
                }
1387
0
                case Fragment::AND_B: {
  Branch (1387:17): [True: 0, False: 0]
  Branch (1387:17): [True: 0, False: 0]
1388
0
                    auto& x = subres[0], &y = subres[1];
1389
                    // Note that it is not strictly necessary to mark the 2nd and 3rd dissatisfaction here
1390
                    // as malleable. While they are definitely malleable, they are also non-canonical due
1391
                    // to the guaranteed existence of a no-signature other dissatisfaction (the 1st)
1392
                    // option. Because of that, the 2nd and 3rd option will never be chosen, even if they
1393
                    // weren't marked as malleable.
1394
0
                    return {(y.nsat + x.nsat) | (y.sat + x.nsat).SetMalleable().SetNonCanon() | (y.nsat + x.sat).SetMalleable().SetNonCanon(), y.sat + x.sat};
1395
0
                }
1396
0
                case Fragment::OR_B: {
  Branch (1396:17): [True: 0, False: 0]
  Branch (1396:17): [True: 0, False: 0]
1397
0
                    auto& x = subres[0], &z = subres[1];
1398
                    // The (sat(Z) sat(X)) solution is overcomplete (attacker can change either into dsat).
1399
0
                    return {z.nsat + x.nsat, (z.nsat + x.sat) | (z.sat + x.nsat) | (z.sat + x.sat).SetMalleable().SetNonCanon()};
1400
0
                }
1401
0
                case Fragment::OR_C: {
  Branch (1401:17): [True: 0, False: 0]
  Branch (1401:17): [True: 0, False: 0]
1402
0
                    auto& x = subres[0], &z = subres[1];
1403
0
                    return {INVALID, std::move(x.sat) | (z.sat + x.nsat)};
1404
0
                }
1405
0
                case Fragment::OR_D: {
  Branch (1405:17): [True: 0, False: 0]
  Branch (1405:17): [True: 0, False: 0]
1406
0
                    auto& x = subres[0], &z = subres[1];
1407
0
                    return {z.nsat + x.nsat, std::move(x.sat) | (z.sat + x.nsat)};
1408
0
                }
1409
0
                case Fragment::OR_I: {
  Branch (1409:17): [True: 0, False: 0]
  Branch (1409:17): [True: 0, False: 0]
1410
0
                    auto& x = subres[0], &z = subres[1];
1411
0
                    return {(x.nsat + ONE) | (z.nsat + ZERO), (x.sat + ONE) | (z.sat + ZERO)};
1412
0
                }
1413
0
                case Fragment::ANDOR: {
  Branch (1413:17): [True: 0, False: 0]
  Branch (1413:17): [True: 0, False: 0]
1414
0
                    auto& x = subres[0], &y = subres[1], &z = subres[2];
1415
0
                    return {(y.nsat + x.sat).SetNonCanon() | (z.nsat + x.nsat), (y.sat + x.sat) | (z.sat + x.nsat)};
1416
0
                }
1417
0
                case Fragment::WRAP_A:
  Branch (1417:17): [True: 0, False: 0]
  Branch (1417:17): [True: 0, False: 0]
1418
0
                case Fragment::WRAP_S:
  Branch (1418:17): [True: 0, False: 0]
  Branch (1418:17): [True: 0, False: 0]
1419
0
                case Fragment::WRAP_C:
  Branch (1419:17): [True: 0, False: 0]
  Branch (1419:17): [True: 0, False: 0]
1420
0
                case Fragment::WRAP_N:
  Branch (1420:17): [True: 0, False: 0]
  Branch (1420:17): [True: 0, False: 0]
1421
0
                    return std::move(subres[0]);
1422
0
                case Fragment::WRAP_D: {
  Branch (1422:17): [True: 0, False: 0]
  Branch (1422:17): [True: 0, False: 0]
1423
0
                    auto &x = subres[0];
1424
0
                    return {ZERO, x.sat + ONE};
1425
0
                }
1426
0
                case Fragment::WRAP_J: {
  Branch (1426:17): [True: 0, False: 0]
  Branch (1426:17): [True: 0, False: 0]
1427
0
                    auto &x = subres[0];
1428
                    // If a dissatisfaction with a nonzero top stack element exists, an alternative dissatisfaction exists.
1429
                    // As the dissatisfaction logic currently doesn't keep track of this nonzeroness property, and thus even
1430
                    // if a dissatisfaction with a top zero element is found, we don't know whether another one with a
1431
                    // nonzero top stack element exists. Make the conservative assumption that whenever the subexpression is weakly
1432
                    // dissatisfiable, this alternative dissatisfaction exists and leads to malleability.
1433
0
                    return {InputStack(ZERO).SetMalleable(x.nsat.available != Availability::NO && !x.nsat.has_sig), std::move(x.sat)};
  Branch (1433:59): [True: 0, False: 0]
  Branch (1433:99): [True: 0, False: 0]
  Branch (1433:59): [True: 0, False: 0]
  Branch (1433:99): [True: 0, False: 0]
1434
0
                }
1435
0
                case Fragment::WRAP_V: {
  Branch (1435:17): [True: 0, False: 0]
  Branch (1435:17): [True: 0, False: 0]
1436
0
                    auto &x = subres[0];
1437
0
                    return {INVALID, std::move(x.sat)};
1438
0
                }
1439
0
                case Fragment::JUST_0: return {EMPTY, INVALID};
  Branch (1439:17): [True: 0, False: 0]
  Branch (1439:17): [True: 0, False: 0]
1440
0
                case Fragment::JUST_1: return {INVALID, EMPTY};
  Branch (1440:17): [True: 0, False: 0]
  Branch (1440:17): [True: 0, False: 0]
1441
0
            }
1442
0
            assert(false);
  Branch (1442:13): [Folded - Ignored]
  Branch (1442:13): [Folded - Ignored]
1443
0
            return {INVALID, INVALID};
1444
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
1445
1446
0
        auto tester = [&helper](const Node& node, std::span<InputResult> subres) -> InputResult {
1447
0
            auto ret = helper(node, subres);
1448
1449
            // Do a consistency check between the satisfaction code and the type checker
1450
            // (the actual satisfaction code in ProduceInputHelper does not use GetType)
1451
1452
            // For 'z' nodes, available satisfactions/dissatisfactions must have stack size 0.
1453
0
            if (node.GetType() << "z"_mst && ret.nsat.available != Availability::NO) CHECK_NONFATAL(ret.nsat.stack.size() == 0);
  Branch (1453:17): [True: 0, False: 0]
  Branch (1453:17): [True: 0, False: 0]
  Branch (1453:46): [True: 0, False: 0]
  Branch (1453:17): [True: 0, False: 0]
  Branch (1453:17): [True: 0, False: 0]
  Branch (1453:46): [True: 0, False: 0]
1454
0
            if (node.GetType() << "z"_mst && ret.sat.available != Availability::NO) CHECK_NONFATAL(ret.sat.stack.size() == 0);
  Branch (1454:17): [True: 0, False: 0]
  Branch (1454:17): [True: 0, False: 0]
  Branch (1454:46): [True: 0, False: 0]
  Branch (1454:17): [True: 0, False: 0]
  Branch (1454:17): [True: 0, False: 0]
  Branch (1454:46): [True: 0, False: 0]
1455
1456
            // For 'o' nodes, available satisfactions/dissatisfactions must have stack size 1.
1457
0
            if (node.GetType() << "o"_mst && ret.nsat.available != Availability::NO) CHECK_NONFATAL(ret.nsat.stack.size() == 1);
  Branch (1457:17): [True: 0, False: 0]
  Branch (1457:17): [True: 0, False: 0]
  Branch (1457:46): [True: 0, False: 0]
  Branch (1457:17): [True: 0, False: 0]
  Branch (1457:17): [True: 0, False: 0]
  Branch (1457:46): [True: 0, False: 0]
1458
0
            if (node.GetType() << "o"_mst && ret.sat.available != Availability::NO) CHECK_NONFATAL(ret.sat.stack.size() == 1);
  Branch (1458:17): [True: 0, False: 0]
  Branch (1458:17): [True: 0, False: 0]
  Branch (1458:46): [True: 0, False: 0]
  Branch (1458:17): [True: 0, False: 0]
  Branch (1458:17): [True: 0, False: 0]
  Branch (1458:46): [True: 0, False: 0]
1459
1460
            // For 'n' nodes, available satisfactions/dissatisfactions must have stack size 1 or larger. For satisfactions,
1461
            // the top element cannot be 0.
1462
0
            if (node.GetType() << "n"_mst && ret.sat.available != Availability::NO) CHECK_NONFATAL(ret.sat.stack.size() >= 1);
  Branch (1462:17): [True: 0, False: 0]
  Branch (1462:17): [True: 0, False: 0]
  Branch (1462:46): [True: 0, False: 0]
  Branch (1462:17): [True: 0, False: 0]
  Branch (1462:17): [True: 0, False: 0]
  Branch (1462:46): [True: 0, False: 0]
1463
0
            if (node.GetType() << "n"_mst && ret.nsat.available != Availability::NO) CHECK_NONFATAL(ret.nsat.stack.size() >= 1);
  Branch (1463:17): [True: 0, False: 0]
  Branch (1463:17): [True: 0, False: 0]
  Branch (1463:46): [True: 0, False: 0]
  Branch (1463:17): [True: 0, False: 0]
  Branch (1463:17): [True: 0, False: 0]
  Branch (1463:46): [True: 0, False: 0]
1464
0
            if (node.GetType() << "n"_mst && ret.sat.available != Availability::NO) CHECK_NONFATAL(!ret.sat.stack.back().empty());
  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
1466
            // For 'd' nodes, a dissatisfaction must exist, and they must not need a signature. If it is non-malleable,
1467
            // it must be canonical.
1468
0
            if (node.GetType() << "d"_mst) CHECK_NONFATAL(ret.nsat.available != Availability::NO);
  Branch (1468:17): [True: 0, False: 0]
  Branch (1468:17): [True: 0, False: 0]
1469
0
            if (node.GetType() << "d"_mst) CHECK_NONFATAL(!ret.nsat.has_sig);
  Branch (1469:17): [True: 0, False: 0]
  Branch (1469:17): [True: 0, False: 0]
1470
0
            if (node.GetType() << "d"_mst && !ret.nsat.malleable) CHECK_NONFATAL(!ret.nsat.non_canon);
  Branch (1470:17): [True: 0, False: 0]
  Branch (1470:17): [True: 0, False: 0]
  Branch (1470:46): [True: 0, False: 0]
  Branch (1470:17): [True: 0, False: 0]
  Branch (1470:17): [True: 0, False: 0]
  Branch (1470:46): [True: 0, False: 0]
1471
1472
            // For 'f'/'s' nodes, dissatisfactions/satisfactions must have a signature.
1473
0
            if (node.GetType() << "f"_mst && ret.nsat.available != Availability::NO) CHECK_NONFATAL(ret.nsat.has_sig);
  Branch (1473:17): [True: 0, False: 0]
  Branch (1473:17): [True: 0, False: 0]
  Branch (1473:46): [True: 0, False: 0]
  Branch (1473:17): [True: 0, False: 0]
  Branch (1473:17): [True: 0, False: 0]
  Branch (1473:46): [True: 0, False: 0]
1474
0
            if (node.GetType() << "s"_mst && ret.sat.available != Availability::NO) CHECK_NONFATAL(ret.sat.has_sig);
  Branch (1474:17): [True: 0, False: 0]
  Branch (1474:17): [True: 0, False: 0]
  Branch (1474:46): [True: 0, False: 0]
  Branch (1474:17): [True: 0, False: 0]
  Branch (1474:17): [True: 0, False: 0]
  Branch (1474:46): [True: 0, False: 0]
1475
1476
            // For non-malleable 'e' nodes, a non-malleable dissatisfaction must exist.
1477
0
            if (node.GetType() << "me"_mst) CHECK_NONFATAL(ret.nsat.available != Availability::NO);
  Branch (1477:17): [True: 0, False: 0]
  Branch (1477:17): [True: 0, False: 0]
1478
0
            if (node.GetType() << "me"_mst) CHECK_NONFATAL(!ret.nsat.malleable);
  Branch (1478:17): [True: 0, False: 0]
  Branch (1478:17): [True: 0, False: 0]
1479
1480
            // For 'm' nodes, if a satisfaction exists, it must be non-malleable.
1481
0
            if (node.GetType() << "m"_mst && ret.sat.available != Availability::NO) CHECK_NONFATAL(!ret.sat.malleable);
  Branch (1481:17): [True: 0, False: 0]
  Branch (1481:17): [True: 0, False: 0]
  Branch (1481:46): [True: 0, False: 0]
  Branch (1481:17): [True: 0, False: 0]
  Branch (1481:17): [True: 0, False: 0]
  Branch (1481:46): [True: 0, False: 0]
1482
1483
            // If a non-malleable satisfaction exists, it must be canonical.
1484
0
            if (ret.sat.available != Availability::NO && !ret.sat.malleable) CHECK_NONFATAL(!ret.sat.non_canon);
  Branch (1484:17): [True: 0, False: 0]
  Branch (1484:58): [True: 0, False: 0]
  Branch (1484:17): [True: 0, False: 0]
  Branch (1484:58): [True: 0, False: 0]
1485
1486
0
            return ret;
1487
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
1488
1489
0
        return TreeEval<InputResult>(tester);
1490
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
1491
1492
public:
1493
    /** Update duplicate key information in this Node.
1494
     *
1495
     * This uses a custom key comparator provided by the context in order to still detect duplicates
1496
     * for more complicated types.
1497
     */
1498
    template<typename Ctx> void DuplicateKeyCheck(const Ctx& ctx) const
1499
0
    {
1500
        // We cannot use a lambda here, as lambdas are non assignable, and the set operations
1501
        // below require moving the comparators around.
1502
0
        struct Comp {
1503
0
            const Ctx* ctx_ptr;
1504
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&)
1505
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
1506
0
        };
1507
1508
        // state in the recursive computation:
1509
        // - std::nullopt means "this node has duplicates"
1510
        // - an std::set means "this node has no duplicate keys, and they are: ...".
1511
0
        using keyset = std::set<Key, Comp>;
1512
0
        using state = std::optional<keyset>;
1513
1514
0
        auto upfn = [&ctx](const Node& node, std::span<state> subs) -> state {
1515
            // If this node is already known to have duplicates, nothing left to do.
1516
0
            if (node.has_duplicate_keys.has_value() && *node.has_duplicate_keys) return {};
  Branch (1516:17): [True: 0, False: 0]
  Branch (1516:56): [True: 0, False: 0]
  Branch (1516:17): [True: 0, False: 0]
  Branch (1516:56): [True: 0, False: 0]
  Branch (1516:17): [True: 0, False: 0]
  Branch (1516:56): [True: 0, False: 0]
1517
1518
            // Check if one of the children is already known to have duplicates.
1519
0
            for (auto& sub : subs) {
  Branch (1519:28): [True: 0, False: 0]
  Branch (1519:28): [True: 0, False: 0]
  Branch (1519:28): [True: 0, False: 0]
1520
0
                if (!sub.has_value()) {
  Branch (1520:21): [True: 0, False: 0]
  Branch (1520:21): [True: 0, False: 0]
  Branch (1520:21): [True: 0, False: 0]
1521
0
                    node.has_duplicate_keys = true;
1522
0
                    return {};
1523
0
                }
1524
0
            }
1525
1526
            // Start building the set of keys involved in this node and children.
1527
            // Start by keys in this node directly.
1528
0
            size_t keys_count = node.keys.size();
1529
0
            keyset key_set{node.keys.begin(), node.keys.end(), Comp(ctx)};
1530
0
            if (key_set.size() != keys_count) {
  Branch (1530:17): [True: 0, False: 0]
  Branch (1530:17): [True: 0, False: 0]
  Branch (1530:17): [True: 0, False: 0]
1531
                // It already has duplicates; bail out.
1532
0
                node.has_duplicate_keys = true;
1533
0
                return {};
1534
0
            }
1535
1536
            // Merge the keys from the children into this set.
1537
0
            for (auto& sub : subs) {
  Branch (1537:28): [True: 0, False: 0]
  Branch (1537:28): [True: 0, False: 0]
  Branch (1537:28): [True: 0, False: 0]
1538
0
                keys_count += sub->size();
1539
                // Small optimization: std::set::merge is linear in the size of the second arg but
1540
                // logarithmic in the size of the first.
1541
0
                if (key_set.size() < sub->size()) std::swap(key_set, *sub);
  Branch (1541:21): [True: 0, False: 0]
  Branch (1541:21): [True: 0, False: 0]
  Branch (1541:21): [True: 0, False: 0]
1542
0
                key_set.merge(*sub);
1543
0
                if (key_set.size() != keys_count) {
  Branch (1543:21): [True: 0, False: 0]
  Branch (1543:21): [True: 0, False: 0]
  Branch (1543:21): [True: 0, False: 0]
1544
0
                    node.has_duplicate_keys = true;
1545
0
                    return {};
1546
0
                }
1547
0
            }
1548
1549
0
            node.has_duplicate_keys = false;
1550
0
            return key_set;
1551
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
1552
1553
0
        TreeEval<state>(upfn);
1554
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
1555
1556
    //! Return the size of the script for this expression (faster than ToScript().size()).
1557
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
1558
1559
    //! Return the maximum number of ops needed to satisfy this script non-malleably.
1560
0
    std::optional<uint32_t> GetOps() const {
1561
0
        if (!ops.sat.Valid()) return {};
  Branch (1561:13): [True: 0, False: 0]
1562
0
        return ops.count + ops.sat.Value();
1563
0
    }
1564
1565
    //! Return the number of ops in the script (not counting the dynamic ones that depend on execution).
1566
    uint32_t GetStaticOps() const { return ops.count; }
1567
1568
    //! Check the ops limit of this script against the consensus limit.
1569
0
    bool CheckOpsLimit() const {
1570
0
        if (IsTapscript(m_script_ctx)) return true;
  Branch (1570:13): [True: 0, False: 0]
1571
0
        if (const auto ops = GetOps()) return *ops <= MAX_OPS_PER_SCRIPT;
  Branch (1571:24): [True: 0, False: 0]
1572
0
        return true;
1573
0
    }
1574
1575
    /** Whether this node is of type B, K or W. (That is, anything but V.) */
1576
0
    bool IsBKW() const {
1577
0
        return !((GetType() & "BKW"_mst) == ""_mst);
1578
0
    }
1579
1580
    /** Return the maximum number of stack elements needed to satisfy this script non-malleably. */
1581
0
    std::optional<uint32_t> GetStackSize() const {
1582
0
        if (!ss.Sat().Valid()) return {};
  Branch (1582:13): [True: 0, False: 0]
1583
0
        return ss.Sat().NetDiff() + static_cast<int32_t>(IsBKW());
1584
0
    }
1585
1586
    //! Return the maximum size of the stack during execution of this script.
1587
0
    std::optional<uint32_t> GetExecStackSize() const {
1588
0
        if (!ss.Sat().Valid()) return {};
  Branch (1588:13): [True: 0, False: 0]
1589
0
        return ss.Sat().Exec() + static_cast<int32_t>(IsBKW());
1590
0
    }
1591
1592
    //! Check the maximum stack size for this script against the policy limit.
1593
0
    bool CheckStackSize() const {
1594
        // Since in Tapscript there is no standardness limit on the script and witness sizes, we may run
1595
        // into the maximum stack size while executing the script. Make sure it doesn't happen.
1596
0
        if (IsTapscript(m_script_ctx)) {
  Branch (1596:13): [True: 0, False: 0]
1597
0
            if (const auto exec_ss = GetExecStackSize()) return exec_ss <= MAX_STACK_SIZE;
  Branch (1597:28): [True: 0, False: 0]
1598
0
            return true;
1599
0
        }
1600
0
        if (const auto ss = GetStackSize()) return *ss <= MAX_STANDARD_P2WSH_STACK_ITEMS;
  Branch (1600:24): [True: 0, False: 0]
1601
0
        return true;
1602
0
    }
1603
1604
    //! Whether no satisfaction exists for this node.
1605
0
    bool IsNotSatisfiable() const { return !GetStackSize(); }
1606
1607
    /** Return the maximum size in bytes of a witness to satisfy this script non-malleably. Note this does
1608
     * not include the witness script push. */
1609
0
    std::optional<uint32_t> GetWitnessSize() const {
1610
0
        if (!ws.sat.Valid()) return {};
  Branch (1610:13): [True: 0, False: 0]
1611
0
        return ws.sat.Value();
1612
0
    }
1613
1614
    //! Return the expression type.
1615
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
1616
1617
    //! Return the script context for this node.
1618
0
    MiniscriptContext GetMsCtx() const { return m_script_ctx; }
1619
1620
    //! Find an insane subnode which has no insane children. Nullptr if there is none.
1621
0
    const Node* FindInsaneSub() const {
1622
0
        return TreeEval<const Node*>([](const Node& node, std::span<const Node*> subs) -> const Node* {
1623
0
            for (auto& sub: subs) if (sub) return sub;
  Branch (1623:27): [True: 0, False: 0]
  Branch (1623:39): [True: 0, False: 0]
1624
0
            if (!node.IsSaneSubexpression()) return &node;
  Branch (1624:17): [True: 0, False: 0]
1625
0
            return nullptr;
1626
0
        });
1627
0
    }
1628
1629
    //! Determine whether a Miniscript node is satisfiable. fn(node) will be invoked for all
1630
    //! key, time, and hashing nodes, and should return their satisfiability.
1631
    template<typename F>
1632
    bool IsSatisfiable(F fn) const
1633
    {
1634
        // TreeEval() doesn't support bool as NodeType, so use int instead.
1635
        return TreeEval<int>([&fn](const Node& node, std::span<int> subs) -> bool {
1636
            switch (node.fragment) {
1637
                case Fragment::JUST_0:
1638
                    return false;
1639
                case Fragment::JUST_1:
1640
                    return true;
1641
                case Fragment::PK_K:
1642
                case Fragment::PK_H:
1643
                case Fragment::MULTI:
1644
                case Fragment::MULTI_A:
1645
                case Fragment::AFTER:
1646
                case Fragment::OLDER:
1647
                case Fragment::HASH256:
1648
                case Fragment::HASH160:
1649
                case Fragment::SHA256:
1650
                case Fragment::RIPEMD160:
1651
                    return bool{fn(node)};
1652
                case Fragment::ANDOR:
1653
                    return (subs[0] && subs[1]) || subs[2];
1654
                case Fragment::AND_V:
1655
                case Fragment::AND_B:
1656
                    return subs[0] && subs[1];
1657
                case Fragment::OR_B:
1658
                case Fragment::OR_C:
1659
                case Fragment::OR_D:
1660
                case Fragment::OR_I:
1661
                    return subs[0] || subs[1];
1662
                case Fragment::THRESH:
1663
                    return static_cast<uint32_t>(std::count(subs.begin(), subs.end(), true)) >= node.k;
1664
                default: // wrappers
1665
                    assert(subs.size() >= 1);
1666
                    CHECK_NONFATAL(subs.size() == 1);
1667
                    return subs[0];
1668
            }
1669
        });
1670
    }
1671
1672
    //! Check whether this node is valid at all.
1673
0
    bool IsValid() const {
1674
0
        if (GetType() == ""_mst) return false;
  Branch (1674:13): [True: 0, False: 0]
  Branch (1674:13): [True: 0, False: 0]
  Branch (1674:13): [True: 0, False: 0]
1675
0
        return ScriptSize() <= internal::MaxScriptSize(m_script_ctx);
1676
0
    }
Unexecuted instantiation: miniscript::Node<unsigned int>::IsValid() const
Unexecuted instantiation: miniscript::Node<XOnlyPubKey>::IsValid() const
Unexecuted instantiation: miniscript::Node<CPubKey>::IsValid() const
1677
1678
    //! Check whether this node is valid as a script on its own.
1679
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 (1679:43): [True: 0, False: 0]
  Branch (1679:56): [True: 0, False: 0]
  Branch (1679:43): [True: 0, False: 0]
  Branch (1679:56): [True: 0, False: 0]
  Branch (1679:43): [True: 0, False: 0]
  Branch (1679:56): [True: 0, False: 0]
1680
1681
    //! Check whether this script can always be satisfied in a non-malleable way.
1682
0
    bool IsNonMalleable() const { return GetType() << "m"_mst; }
1683
1684
    //! Check whether this script always needs a signature.
1685
0
    bool NeedsSignature() const { return GetType() << "s"_mst; }
1686
1687
    //! Check whether there is no satisfaction path that contains both timelocks and heightlocks
1688
0
    bool CheckTimeLocksMix() const { return GetType() << "k"_mst; }
1689
1690
    //! Check whether there is no duplicate key across this fragment and all its sub-fragments.
1691
0
    bool CheckDuplicateKey() const { return has_duplicate_keys && !*has_duplicate_keys; }
  Branch (1691:45): [True: 0, False: 0]
  Branch (1691:67): [True: 0, False: 0]
1692
1693
    //! Whether successful non-malleable satisfactions are guaranteed to be valid.
1694
0
    bool ValidSatisfactions() const { return IsValid() && CheckOpsLimit() && CheckStackSize(); }
  Branch (1694:46): [True: 0, False: 0]
  Branch (1694:59): [True: 0, False: 0]
  Branch (1694:78): [True: 0, False: 0]
1695
1696
    //! Whether the apparent policy of this node matches its script semantics. Doesn't guarantee it is a safe script on its own.
1697
0
    bool IsSaneSubexpression() const { return ValidSatisfactions() && IsNonMalleable() && CheckTimeLocksMix() && CheckDuplicateKey(); }
  Branch (1697:47): [True: 0, False: 0]
  Branch (1697:71): [True: 0, False: 0]
  Branch (1697:91): [True: 0, False: 0]
  Branch (1697:114): [True: 0, False: 0]
1698
1699
    //! Check whether this node is safe as a script on its own.
1700
0
    bool IsSane() const { return IsValidTopLevel() && IsSaneSubexpression() && NeedsSignature(); }
  Branch (1700:34): [True: 0, False: 0]
  Branch (1700:55): [True: 0, False: 0]
  Branch (1700:80): [True: 0, False: 0]
1701
1702
    //! Produce a witness for this script, if possible and given the information available in the context.
1703
    //! The non-malleable satisfaction is guaranteed to be valid if it exists, and ValidSatisfaction()
1704
    //! is true. If IsSane() holds, this satisfaction is guaranteed to succeed in case the node's
1705
    //! conditions are satisfied (private keys and hash preimages available, locktimes satisfied).
1706
    template<typename Ctx>
1707
0
    Availability Satisfy(const Ctx& ctx, std::vector<std::vector<unsigned char>>& stack, bool nonmalleable = true) const {
1708
0
        auto ret = ProduceInput(ctx);
1709
0
        if (nonmalleable && (ret.sat.malleable || !ret.sat.has_sig)) return Availability::NO;
  Branch (1709:13): [True: 0, False: 0]
  Branch (1709:30): [True: 0, False: 0]
  Branch (1709:51): [True: 0, False: 0]
  Branch (1709:13): [True: 0, False: 0]
  Branch (1709:30): [True: 0, False: 0]
  Branch (1709:51): [True: 0, False: 0]
1710
0
        stack = std::move(ret.sat.stack);
1711
0
        return ret.sat.available;
1712
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
1713
1714
    //! Equality testing.
1715
    bool operator==(const Node<Key>& arg) const { return Compare(*this, arg) == 0; }
1716
1717
    // Constructors with various argument combinations, which bypass the duplicate key check.
1718
    Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, std::vector<Node> sub, std::vector<unsigned char> arg, uint32_t val = 0)
1719
        : 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()) {}
1720
    Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, std::vector<unsigned char> arg, uint32_t val = 0)
1721
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)
1722
    Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, std::vector<Node> sub, std::vector<Key> key, uint32_t val = 0)
1723
        : 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()) {}
1724
    Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, std::vector<Key> key, uint32_t val = 0)
1725
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)
1726
    Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, std::vector<Node> sub, uint32_t val = 0)
1727
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)
1728
    Node(internal::NoDupCheck, MiniscriptContext script_ctx, enum Fragment nt, uint32_t val = 0)
1729
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)
1730
1731
    // Constructors with various argument combinations, which do perform the duplicate key check.
1732
    template <typename Ctx> Node(const Ctx& ctx, enum Fragment nt, std::vector<Node> sub, std::vector<unsigned char> arg, uint32_t val = 0)
1733
        : Node(internal::NoDupCheck{}, ctx.MsContext(), nt, std::move(sub), std::move(arg), val) { DuplicateKeyCheck(ctx); }
1734
    template <typename Ctx> Node(const Ctx& ctx, enum Fragment nt, std::vector<unsigned char> arg, uint32_t val = 0)
1735
        : Node(internal::NoDupCheck{}, ctx.MsContext(), nt, std::move(arg), val) { DuplicateKeyCheck(ctx);}
1736
    template <typename Ctx> Node(const Ctx& ctx, enum Fragment nt, std::vector<Node> sub, std::vector<Key> key, uint32_t val = 0)
1737
        : Node(internal::NoDupCheck{}, ctx.MsContext(), nt, std::move(sub), std::move(key), val) { DuplicateKeyCheck(ctx); }
1738
    template <typename Ctx> Node(const Ctx& ctx, enum Fragment nt, std::vector<Key> key, uint32_t val = 0)
1739
        : Node(internal::NoDupCheck{}, ctx.MsContext(), nt, std::move(key), val) { DuplicateKeyCheck(ctx); }
1740
    template <typename Ctx> Node(const Ctx& ctx, enum Fragment nt, std::vector<Node> sub, uint32_t val = 0)
1741
        : Node(internal::NoDupCheck{}, ctx.MsContext(), nt, std::move(sub), val) { DuplicateKeyCheck(ctx); }
1742
    template <typename Ctx> Node(const Ctx& ctx, enum Fragment nt, uint32_t val = 0)
1743
        : Node(internal::NoDupCheck{}, ctx.MsContext(), nt, val) { DuplicateKeyCheck(ctx); }
1744
1745
    // Delete copy constructor and assignment operator, use Clone() instead
1746
    Node(const Node&) = delete;
1747
    Node& operator=(const Node&) = delete;
1748
1749
    // subs is movable, circumventing recursion, so these are permitted.
1750
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>&&)
1751
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>&&)
1752
};
1753
1754
namespace internal {
1755
1756
enum class ParseContext {
1757
    /** An expression which may be begin with wrappers followed by a colon. */
1758
    WRAPPED_EXPR,
1759
    /** A miniscript expression which does not begin with wrappers. */
1760
    EXPR,
1761
1762
    /** SWAP wraps the top constructed node with s: */
1763
    SWAP,
1764
    /** ALT wraps the top constructed node with a: */
1765
    ALT,
1766
    /** CHECK wraps the top constructed node with c: */
1767
    CHECK,
1768
    /** DUP_IF wraps the top constructed node with d: */
1769
    DUP_IF,
1770
    /** VERIFY wraps the top constructed node with v: */
1771
    VERIFY,
1772
    /** NON_ZERO wraps the top constructed node with j: */
1773
    NON_ZERO,
1774
    /** ZERO_NOTEQUAL wraps the top constructed node with n: */
1775
    ZERO_NOTEQUAL,
1776
    /** WRAP_U will construct an or_i(X,0) node from the top constructed node. */
1777
    WRAP_U,
1778
    /** WRAP_T will construct an and_v(X,1) node from the top constructed node. */
1779
    WRAP_T,
1780
1781
    /** AND_N will construct an andor(X,Y,0) node from the last two constructed nodes. */
1782
    AND_N,
1783
    /** AND_V will construct an and_v node from the last two constructed nodes. */
1784
    AND_V,
1785
    /** AND_B will construct an and_b node from the last two constructed nodes. */
1786
    AND_B,
1787
    /** ANDOR will construct an andor node from the last three constructed nodes. */
1788
    ANDOR,
1789
    /** OR_B will construct an or_b node from the last two constructed nodes. */
1790
    OR_B,
1791
    /** OR_C will construct an or_c node from the last two constructed nodes. */
1792
    OR_C,
1793
    /** OR_D will construct an or_d node from the last two constructed nodes. */
1794
    OR_D,
1795
    /** OR_I will construct an or_i node from the last two constructed nodes. */
1796
    OR_I,
1797
1798
    /** THRESH will read a wrapped expression, and then look for a COMMA. If
1799
     * no comma follows, it will construct a thresh node from the appropriate
1800
     * number of constructed children. Otherwise, it will recurse with another
1801
     * THRESH. */
1802
    THRESH,
1803
1804
    /** COMMA expects the next element to be ',' and fails if not. */
1805
    COMMA,
1806
    /** CLOSE_BRACKET expects the next element to be ')' and fails if not. */
1807
    CLOSE_BRACKET,
1808
};
1809
1810
int FindNextChar(std::span<const char> in, char m);
1811
1812
/** Parse a key expression fully contained within a fragment with the name given by 'func' */
1813
template<typename Key, typename Ctx>
1814
std::optional<Key> ParseKey(const std::string& func, std::span<const char>& in, const Ctx& ctx)
1815
0
{
1816
0
    std::span<const char> expr = script::Expr(in);
1817
0
    if (!script::Func(func, expr)) return {};
  Branch (1817:9): [True: 0, False: 0]
1818
0
    return ctx.FromString(expr);
1819
0
}
1820
1821
/** Parse a hex string fully contained within a fragment with the name given by 'func' */
1822
template<typename Ctx>
1823
std::optional<std::vector<unsigned char>> ParseHexStr(const std::string& func, std::span<const char>& in, const size_t expected_size,
1824
                                                                         const Ctx& ctx)
1825
0
{
1826
0
    std::span<const char> expr = script::Expr(in);
1827
0
    if (!script::Func(func, expr)) return {};
  Branch (1827:9): [True: 0, False: 0]
1828
0
    std::string val = std::string(expr.begin(), expr.end());
1829
0
    if (!IsHex(val)) return {};
  Branch (1829:9): [True: 0, False: 0]
1830
0
    auto hash = ParseHex(val);
1831
0
    if (hash.size() != expected_size) return {};
  Branch (1831:9): [True: 0, False: 0]
1832
0
    return hash;
1833
0
}
1834
1835
/** BuildBack pops the last two elements off `constructed` and wraps them in the specified Fragment */
1836
template<typename Key>
1837
void BuildBack(const MiniscriptContext script_ctx, Fragment nt, std::vector<Node<Key>>& constructed, const bool reverse = false)
1838
0
{
1839
0
    Node<Key> child{std::move(constructed.back())};
1840
0
    constructed.pop_back();
1841
0
    if (reverse) {
  Branch (1841:9): [True: 0, False: 0]
  Branch (1841:9): [True: 0, False: 0]
  Branch (1841:9): [True: 0, False: 0]
1842
0
        constructed.back() = Node<Key>{internal::NoDupCheck{}, script_ctx, nt, Vector(std::move(child), std::move(constructed.back()))};
1843
0
    } else {
1844
0
        constructed.back() = Node<Key>{internal::NoDupCheck{}, script_ctx, nt, Vector(std::move(constructed.back()), std::move(child))};
1845
0
    }
1846
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)
1847
1848
/**
1849
 * Parse a miniscript from its textual descriptor form.
1850
 * This does not check whether the script is valid, let alone sane. The caller is expected to use
1851
 * the `IsValidTopLevel()` and `IsSaneTopLevel()` to check for these properties on the node.
1852
 */
1853
template <typename Key, typename Ctx>
1854
inline std::optional<Node<Key>> Parse(std::span<const char> in, const Ctx& ctx)
1855
0
{
1856
0
    using namespace script;
1857
1858
    // Account for the minimum script size for all parsed fragments so far. It "borrows" 1
1859
    // script byte from all leaf nodes, counting it instead whenever a space for a recursive
1860
    // expression is added (through andor, and_*, or_*, thresh). This guarantees that all fragments
1861
    // increment the script_size by at least one, except for:
1862
    // - "0", "1": these leafs are only a single byte, so their subtracted-from increment is 0.
1863
    //   This is not an issue however, as "space" for them has to be created by combinators,
1864
    //   which do increment script_size.
1865
    // - "v:": the v wrapper adds nothing as in some cases it results in no opcode being added
1866
    //   (instead transforming another opcode into its VERIFY form). However, the v: wrapper has
1867
    //   to be interleaved with other fragments to be valid, so this is not a concern.
1868
0
    size_t script_size{1};
1869
0
    size_t max_size{internal::MaxScriptSize(ctx.MsContext())};
1870
1871
    // The two integers are used to hold state for thresh()
1872
0
    std::vector<std::tuple<ParseContext, int64_t, int64_t>> to_parse;
1873
0
    std::vector<Node<Key>> constructed;
1874
1875
0
    to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
1876
1877
    // Parses a multi() or multi_a() from its string representation. Returns false on parsing error.
1878
0
    const auto parse_multi_exp = [&](std::span<const char>& in, const bool is_multi_a) -> bool {
1879
0
        const auto max_keys{is_multi_a ? MAX_PUBKEYS_PER_MULTI_A : MAX_PUBKEYS_PER_MULTISIG};
  Branch (1879:29): [True: 0, False: 0]
1880
0
        const auto required_ctx{is_multi_a ? MiniscriptContext::TAPSCRIPT : MiniscriptContext::P2WSH};
  Branch (1880:33): [True: 0, False: 0]
1881
0
        if (ctx.MsContext() != required_ctx) return false;
  Branch (1881:13): [True: 0, False: 0]
1882
        // Get threshold
1883
0
        int next_comma = FindNextChar(in, ',');
1884
0
        if (next_comma < 1) return false;
  Branch (1884:13): [True: 0, False: 0]
1885
0
        const auto k_to_integral{ToIntegral<int64_t>(std::string_view(in.data(), next_comma))};
1886
0
        if (!k_to_integral.has_value()) return false;
  Branch (1886:13): [True: 0, False: 0]
1887
0
        const int64_t k{k_to_integral.value()};
1888
0
        in = in.subspan(next_comma + 1);
1889
        // Get keys. It is compatible for both compressed and x-only keys.
1890
0
        std::vector<Key> keys;
1891
0
        while (next_comma != -1) {
  Branch (1891:16): [True: 0, False: 0]
1892
0
            next_comma = FindNextChar(in, ',');
1893
0
            int key_length = (next_comma == -1) ? FindNextChar(in, ')') : next_comma;
  Branch (1893:30): [True: 0, False: 0]
1894
0
            if (key_length < 1) return false;
  Branch (1894:17): [True: 0, False: 0]
1895
0
            std::span<const char> sp{in.begin(), in.begin() + key_length};
1896
0
            auto key = ctx.FromString(sp);
1897
0
            if (!key) return false;
  Branch (1897:17): [True: 0, False: 0]
1898
0
            keys.push_back(std::move(*key));
1899
0
            in = in.subspan(key_length + 1);
1900
0
        }
1901
0
        if (keys.size() < 1 || keys.size() > max_keys) return false;
  Branch (1901:13): [True: 0, False: 0]
  Branch (1901:32): [True: 0, False: 0]
1902
0
        if (k < 1 || k > (int64_t)keys.size()) return false;
  Branch (1902:13): [True: 0, False: 0]
  Branch (1902:22): [True: 0, False: 0]
1903
0
        if (is_multi_a) {
  Branch (1903:13): [True: 0, False: 0]
1904
            // (push + xonly-key + CHECKSIG[ADD]) * n + k + OP_NUMEQUAL(VERIFY), minus one.
1905
0
            script_size += (1 + 32 + 1) * keys.size() + BuildScript(k).size();
1906
0
            constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::MULTI_A, std::move(keys), k);
1907
0
        } else {
1908
0
            script_size += 2 + (keys.size() > 16) + (k > 16) + 34 * keys.size();
1909
0
            constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::MULTI, std::move(keys), k);
1910
0
        }
1911
0
        return true;
1912
0
    };
1913
1914
0
    while (!to_parse.empty()) {
  Branch (1914:12): [True: 0, False: 0]
1915
0
        if (script_size > max_size) return {};
  Branch (1915:13): [True: 0, False: 0]
1916
1917
        // Get the current context we are decoding within
1918
0
        auto [cur_context, n, k] = to_parse.back();
1919
0
        to_parse.pop_back();
1920
1921
0
        switch (cur_context) {
  Branch (1921:17): [True: 0, False: 0]
1922
0
        case ParseContext::WRAPPED_EXPR: {
  Branch (1922:9): [True: 0, False: 0]
1923
0
            std::optional<size_t> colon_index{};
1924
0
            for (size_t i = 1; i < in.size(); ++i) {
  Branch (1924:32): [True: 0, False: 0]
1925
0
                if (in[i] == ':') {
  Branch (1925:21): [True: 0, False: 0]
1926
0
                    colon_index = i;
1927
0
                    break;
1928
0
                }
1929
0
                if (in[i] < 'a' || in[i] > 'z') break;
  Branch (1929:21): [True: 0, False: 0]
  Branch (1929:36): [True: 0, False: 0]
1930
0
            }
1931
            // If there is no colon, this loop won't execute
1932
0
            bool last_was_v{false};
1933
0
            for (size_t j = 0; colon_index && j < *colon_index; ++j) {
  Branch (1933:32): [True: 0, False: 0]
  Branch (1933:47): [True: 0, False: 0]
1934
0
                if (script_size > max_size) return {};
  Branch (1934:21): [True: 0, False: 0]
1935
0
                if (in[j] == 'a') {
  Branch (1935:21): [True: 0, False: 0]
1936
0
                    script_size += 2;
1937
0
                    to_parse.emplace_back(ParseContext::ALT, -1, -1);
1938
0
                } else if (in[j] == 's') {
  Branch (1938:28): [True: 0, False: 0]
1939
0
                    script_size += 1;
1940
0
                    to_parse.emplace_back(ParseContext::SWAP, -1, -1);
1941
0
                } else if (in[j] == 'c') {
  Branch (1941:28): [True: 0, False: 0]
1942
0
                    script_size += 1;
1943
0
                    to_parse.emplace_back(ParseContext::CHECK, -1, -1);
1944
0
                } else if (in[j] == 'd') {
  Branch (1944:28): [True: 0, False: 0]
1945
0
                    script_size += 3;
1946
0
                    to_parse.emplace_back(ParseContext::DUP_IF, -1, -1);
1947
0
                } else if (in[j] == 'j') {
  Branch (1947:28): [True: 0, False: 0]
1948
0
                    script_size += 4;
1949
0
                    to_parse.emplace_back(ParseContext::NON_ZERO, -1, -1);
1950
0
                } else if (in[j] == 'n') {
  Branch (1950:28): [True: 0, False: 0]
1951
0
                    script_size += 1;
1952
0
                    to_parse.emplace_back(ParseContext::ZERO_NOTEQUAL, -1, -1);
1953
0
                } else if (in[j] == 'v') {
  Branch (1953:28): [True: 0, False: 0]
1954
                    // do not permit "...vv...:"; it's not valid, and also doesn't trigger early
1955
                    // failure as script_size isn't incremented.
1956
0
                    if (last_was_v) return {};
  Branch (1956:25): [True: 0, False: 0]
1957
0
                    to_parse.emplace_back(ParseContext::VERIFY, -1, -1);
1958
0
                } else if (in[j] == 'u') {
  Branch (1958:28): [True: 0, False: 0]
1959
0
                    script_size += 4;
1960
0
                    to_parse.emplace_back(ParseContext::WRAP_U, -1, -1);
1961
0
                } else if (in[j] == 't') {
  Branch (1961:28): [True: 0, False: 0]
1962
0
                    script_size += 1;
1963
0
                    to_parse.emplace_back(ParseContext::WRAP_T, -1, -1);
1964
0
                } else if (in[j] == 'l') {
  Branch (1964:28): [True: 0, False: 0]
1965
                    // The l: wrapper is equivalent to or_i(0,X)
1966
0
                    script_size += 4;
1967
0
                    constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::JUST_0);
1968
0
                    to_parse.emplace_back(ParseContext::OR_I, -1, -1);
1969
0
                } else {
1970
0
                    return {};
1971
0
                }
1972
0
                last_was_v = (in[j] == 'v');
1973
0
            }
1974
0
            to_parse.emplace_back(ParseContext::EXPR, -1, -1);
1975
0
            if (colon_index) in = in.subspan(*colon_index + 1);
  Branch (1975:17): [True: 0, False: 0]
1976
0
            break;
1977
0
        }
1978
0
        case ParseContext::EXPR: {
  Branch (1978:9): [True: 0, False: 0]
1979
0
            if (Const("0", in)) {
  Branch (1979:17): [True: 0, False: 0]
1980
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::JUST_0);
1981
0
            } else if (Const("1", in)) {
  Branch (1981:24): [True: 0, False: 0]
1982
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::JUST_1);
1983
0
            } else if (Const("pk(", in, /*skip=*/false)) {
  Branch (1983:24): [True: 0, False: 0]
1984
0
                std::optional<Key> key = ParseKey<Key, Ctx>("pk", in, ctx);
1985
0
                if (!key) return {};
  Branch (1985:21): [True: 0, False: 0]
1986
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)))));
1987
0
                script_size += IsTapscript(ctx.MsContext()) ? 33 : 34;
  Branch (1987:32): [True: 0, False: 0]
1988
0
            } else if (Const("pkh(", in, /*skip=*/false)) {
  Branch (1988:24): [True: 0, False: 0]
1989
0
                std::optional<Key> key = ParseKey<Key, Ctx>("pkh", in, ctx);
1990
0
                if (!key) return {};
  Branch (1990:21): [True: 0, False: 0]
1991
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)))));
1992
0
                script_size += 24;
1993
0
            } else if (Const("pk_k(", in, /*skip=*/false)) {
  Branch (1993:24): [True: 0, False: 0]
1994
0
                std::optional<Key> key = ParseKey<Key, Ctx>("pk_k", in, ctx);
1995
0
                if (!key) return {};
  Branch (1995:21): [True: 0, False: 0]
1996
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::PK_K, Vector(std::move(*key)));
1997
0
                script_size += IsTapscript(ctx.MsContext()) ? 32 : 33;
  Branch (1997:32): [True: 0, False: 0]
1998
0
            } else if (Const("pk_h(", in, /*skip=*/false)) {
  Branch (1998:24): [True: 0, False: 0]
1999
0
                std::optional<Key> key = ParseKey<Key, Ctx>("pk_h", in, ctx);
2000
0
                if (!key) return {};
  Branch (2000:21): [True: 0, False: 0]
2001
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::PK_H, Vector(std::move(*key)));
2002
0
                script_size += 23;
2003
0
            } else if (Const("sha256(", in, /*skip=*/false)) {
  Branch (2003:24): [True: 0, False: 0]
2004
0
                std::optional<std::vector<unsigned char>> hash = ParseHexStr("sha256", in, 32, ctx);
2005
0
                if (!hash) return {};
  Branch (2005:21): [True: 0, False: 0]
2006
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::SHA256, std::move(*hash));
2007
0
                script_size += 38;
2008
0
            } else if (Const("ripemd160(", in, /*skip=*/false)) {
  Branch (2008:24): [True: 0, False: 0]
2009
0
                std::optional<std::vector<unsigned char>> hash = ParseHexStr("ripemd160", in, 20, ctx);
2010
0
                if (!hash) return {};
  Branch (2010:21): [True: 0, False: 0]
2011
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::RIPEMD160, std::move(*hash));
2012
0
                script_size += 26;
2013
0
            } else if (Const("hash256(", in, /*skip=*/false)) {
  Branch (2013:24): [True: 0, False: 0]
2014
0
                std::optional<std::vector<unsigned char>> hash = ParseHexStr("hash256", in, 32, ctx);
2015
0
                if (!hash) return {};
  Branch (2015:21): [True: 0, False: 0]
2016
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::HASH256, std::move(*hash));
2017
0
                script_size += 38;
2018
0
            } else if (Const("hash160(", in, /*skip=*/false)) {
  Branch (2018:24): [True: 0, False: 0]
2019
0
                std::optional<std::vector<unsigned char>> hash = ParseHexStr("hash160", in, 20, ctx);
2020
0
                if (!hash) return {};
  Branch (2020:21): [True: 0, False: 0]
2021
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::HASH160, std::move(*hash));
2022
0
                script_size += 26;
2023
0
            } else if (Const("after(", in, /*skip=*/false)) {
  Branch (2023:24): [True: 0, False: 0]
2024
0
                auto expr = Expr(in);
2025
0
                if (!Func("after", expr)) return {};
  Branch (2025:21): [True: 0, False: 0]
2026
0
                const auto num{ToIntegral<int64_t>(std::string_view(expr.begin(), expr.end()))};
2027
0
                if (!num.has_value() || *num < 1 || *num >= 0x80000000L) return {};
  Branch (2027:21): [True: 0, False: 0]
  Branch (2027:41): [True: 0, False: 0]
  Branch (2027:53): [True: 0, False: 0]
2028
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::AFTER, *num);
2029
0
                script_size += 1 + (*num > 16) + (*num > 0x7f) + (*num > 0x7fff) + (*num > 0x7fffff);
2030
0
            } else if (Const("older(", in, /*skip=*/false)) {
  Branch (2030:24): [True: 0, False: 0]
2031
0
                auto expr = Expr(in);
2032
0
                if (!Func("older", expr)) return {};
  Branch (2032:21): [True: 0, False: 0]
2033
0
                const auto num{ToIntegral<int64_t>(std::string_view(expr.begin(), expr.end()))};
2034
0
                if (!num.has_value() || *num < 1 || *num >= 0x80000000L) return {};
  Branch (2034:21): [True: 0, False: 0]
  Branch (2034:41): [True: 0, False: 0]
  Branch (2034:53): [True: 0, False: 0]
2035
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::OLDER, *num);
2036
0
                script_size += 1 + (*num > 16) + (*num > 0x7f) + (*num > 0x7fff) + (*num > 0x7fffff);
2037
0
            } else if (Const("multi(", in)) {
  Branch (2037:24): [True: 0, False: 0]
2038
0
                if (!parse_multi_exp(in, /* is_multi_a = */false)) return {};
  Branch (2038:21): [True: 0, False: 0]
2039
0
            } else if (Const("multi_a(", in)) {
  Branch (2039:24): [True: 0, False: 0]
2040
0
                if (!parse_multi_exp(in, /* is_multi_a = */true)) return {};
  Branch (2040:21): [True: 0, False: 0]
2041
0
            } else if (Const("thresh(", in)) {
  Branch (2041:24): [True: 0, False: 0]
2042
0
                int next_comma = FindNextChar(in, ',');
2043
0
                if (next_comma < 1) return {};
  Branch (2043:21): [True: 0, False: 0]
2044
0
                const auto k{ToIntegral<int64_t>(std::string_view(in.data(), next_comma))};
2045
0
                if (!k.has_value() || *k < 1) return {};
  Branch (2045:21): [True: 0, False: 0]
  Branch (2045:39): [True: 0, False: 0]
2046
0
                in = in.subspan(next_comma + 1);
2047
                // n = 1 here because we read the first WRAPPED_EXPR before reaching THRESH
2048
0
                to_parse.emplace_back(ParseContext::THRESH, 1, *k);
2049
0
                to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
2050
0
                script_size += 2 + (*k > 16) + (*k > 0x7f) + (*k > 0x7fff) + (*k > 0x7fffff);
2051
0
            } else if (Const("andor(", in)) {
  Branch (2051:24): [True: 0, False: 0]
2052
0
                to_parse.emplace_back(ParseContext::ANDOR, -1, -1);
2053
0
                to_parse.emplace_back(ParseContext::CLOSE_BRACKET, -1, -1);
2054
0
                to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
2055
0
                to_parse.emplace_back(ParseContext::COMMA, -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
                script_size += 5;
2060
0
            } else {
2061
0
                if (Const("and_n(", in)) {
  Branch (2061:21): [True: 0, False: 0]
2062
0
                    to_parse.emplace_back(ParseContext::AND_N, -1, -1);
2063
0
                    script_size += 5;
2064
0
                } else if (Const("and_b(", in)) {
  Branch (2064:28): [True: 0, False: 0]
2065
0
                    to_parse.emplace_back(ParseContext::AND_B, -1, -1);
2066
0
                    script_size += 2;
2067
0
                } else if (Const("and_v(", in)) {
  Branch (2067:28): [True: 0, False: 0]
2068
0
                    to_parse.emplace_back(ParseContext::AND_V, -1, -1);
2069
0
                    script_size += 1;
2070
0
                } else if (Const("or_b(", in)) {
  Branch (2070:28): [True: 0, False: 0]
2071
0
                    to_parse.emplace_back(ParseContext::OR_B, -1, -1);
2072
0
                    script_size += 2;
2073
0
                } else if (Const("or_c(", in)) {
  Branch (2073:28): [True: 0, False: 0]
2074
0
                    to_parse.emplace_back(ParseContext::OR_C, -1, -1);
2075
0
                    script_size += 3;
2076
0
                } else if (Const("or_d(", in)) {
  Branch (2076:28): [True: 0, False: 0]
2077
0
                    to_parse.emplace_back(ParseContext::OR_D, -1, -1);
2078
0
                    script_size += 4;
2079
0
                } else if (Const("or_i(", in)) {
  Branch (2079:28): [True: 0, False: 0]
2080
0
                    to_parse.emplace_back(ParseContext::OR_I, -1, -1);
2081
0
                    script_size += 4;
2082
0
                } else {
2083
0
                    return {};
2084
0
                }
2085
0
                to_parse.emplace_back(ParseContext::CLOSE_BRACKET, -1, -1);
2086
0
                to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
2087
0
                to_parse.emplace_back(ParseContext::COMMA, -1, -1);
2088
0
                to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
2089
0
            }
2090
0
            break;
2091
0
        }
2092
0
        case ParseContext::ALT: {
  Branch (2092:9): [True: 0, False: 0]
2093
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_A, Vector(std::move(constructed.back()))};
2094
0
            break;
2095
0
        }
2096
0
        case ParseContext::SWAP: {
  Branch (2096:9): [True: 0, False: 0]
2097
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_S, Vector(std::move(constructed.back()))};
2098
0
            break;
2099
0
        }
2100
0
        case ParseContext::CHECK: {
  Branch (2100:9): [True: 0, False: 0]
2101
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_C, Vector(std::move(constructed.back()))};
2102
0
            break;
2103
0
        }
2104
0
        case ParseContext::DUP_IF: {
  Branch (2104:9): [True: 0, False: 0]
2105
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_D, Vector(std::move(constructed.back()))};
2106
0
            break;
2107
0
        }
2108
0
        case ParseContext::NON_ZERO: {
  Branch (2108:9): [True: 0, False: 0]
2109
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_J, Vector(std::move(constructed.back()))};
2110
0
            break;
2111
0
        }
2112
0
        case ParseContext::ZERO_NOTEQUAL: {
  Branch (2112:9): [True: 0, False: 0]
2113
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_N, Vector(std::move(constructed.back()))};
2114
0
            break;
2115
0
        }
2116
0
        case ParseContext::VERIFY: {
  Branch (2116:9): [True: 0, False: 0]
2117
0
            script_size += (constructed.back().GetType() << "x"_mst);
2118
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_V, Vector(std::move(constructed.back()))};
2119
0
            break;
2120
0
        }
2121
0
        case ParseContext::WRAP_U: {
  Branch (2121:9): [True: 0, False: 0]
2122
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})};
2123
0
            break;
2124
0
        }
2125
0
        case ParseContext::WRAP_T: {
  Branch (2125:9): [True: 0, False: 0]
2126
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})};
2127
0
            break;
2128
0
        }
2129
0
        case ParseContext::AND_B: {
  Branch (2129:9): [True: 0, False: 0]
2130
0
            BuildBack(ctx.MsContext(), Fragment::AND_B, constructed);
2131
0
            break;
2132
0
        }
2133
0
        case ParseContext::AND_N: {
  Branch (2133:9): [True: 0, False: 0]
2134
0
            auto mid = std::move(constructed.back());
2135
0
            constructed.pop_back();
2136
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})};
2137
0
            break;
2138
0
        }
2139
0
        case ParseContext::AND_V: {
  Branch (2139:9): [True: 0, False: 0]
2140
0
            BuildBack(ctx.MsContext(), Fragment::AND_V, constructed);
2141
0
            break;
2142
0
        }
2143
0
        case ParseContext::OR_B: {
  Branch (2143:9): [True: 0, False: 0]
2144
0
            BuildBack(ctx.MsContext(), Fragment::OR_B, constructed);
2145
0
            break;
2146
0
        }
2147
0
        case ParseContext::OR_C: {
  Branch (2147:9): [True: 0, False: 0]
2148
0
            BuildBack(ctx.MsContext(), Fragment::OR_C, constructed);
2149
0
            break;
2150
0
        }
2151
0
        case ParseContext::OR_D: {
  Branch (2151:9): [True: 0, False: 0]
2152
0
            BuildBack(ctx.MsContext(), Fragment::OR_D, constructed);
2153
0
            break;
2154
0
        }
2155
0
        case ParseContext::OR_I: {
  Branch (2155:9): [True: 0, False: 0]
2156
0
            BuildBack(ctx.MsContext(), Fragment::OR_I, constructed);
2157
0
            break;
2158
0
        }
2159
0
        case ParseContext::ANDOR: {
  Branch (2159:9): [True: 0, False: 0]
2160
0
            auto right = std::move(constructed.back());
2161
0
            constructed.pop_back();
2162
0
            auto mid = std::move(constructed.back());
2163
0
            constructed.pop_back();
2164
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::ANDOR, Vector(std::move(constructed.back()), std::move(mid), std::move(right))};
2165
0
            break;
2166
0
        }
2167
0
        case ParseContext::THRESH: {
  Branch (2167:9): [True: 0, False: 0]
2168
0
            if (in.size() < 1) return {};
  Branch (2168:17): [True: 0, False: 0]
2169
0
            if (in[0] == ',') {
  Branch (2169:17): [True: 0, False: 0]
2170
0
                in = in.subspan(1);
2171
0
                to_parse.emplace_back(ParseContext::THRESH, n+1, k);
2172
0
                to_parse.emplace_back(ParseContext::WRAPPED_EXPR, -1, -1);
2173
0
                script_size += 2;
2174
0
            } else if (in[0] == ')') {
  Branch (2174:24): [True: 0, False: 0]
2175
0
                if (k > n) return {};
  Branch (2175:21): [True: 0, False: 0]
2176
0
                in = in.subspan(1);
2177
                // Children are constructed in reverse order, so iterate from end to beginning
2178
0
                std::vector<Node<Key>> subs;
2179
0
                for (int i = 0; i < n; ++i) {
  Branch (2179:33): [True: 0, False: 0]
2180
0
                    subs.push_back(std::move(constructed.back()));
2181
0
                    constructed.pop_back();
2182
0
                }
2183
0
                std::reverse(subs.begin(), subs.end());
2184
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::THRESH, std::move(subs), k);
2185
0
            } else {
2186
0
                return {};
2187
0
            }
2188
0
            break;
2189
0
        }
2190
0
        case ParseContext::COMMA: {
  Branch (2190:9): [True: 0, False: 0]
2191
0
            if (in.size() < 1 || in[0] != ',') return {};
  Branch (2191:17): [True: 0, False: 0]
  Branch (2191:34): [True: 0, False: 0]
2192
0
            in = in.subspan(1);
2193
0
            break;
2194
0
        }
2195
0
        case ParseContext::CLOSE_BRACKET: {
  Branch (2195:9): [True: 0, False: 0]
2196
0
            if (in.size() < 1 || in[0] != ')') return {};
  Branch (2196:17): [True: 0, False: 0]
  Branch (2196:34): [True: 0, False: 0]
2197
0
            in = in.subspan(1);
2198
0
            break;
2199
0
        }
2200
0
        }
2201
0
    }
2202
2203
    // Sanity checks on the produced miniscript
2204
0
    assert(constructed.size() >= 1);
  Branch (2204:5): [True: 0, False: 0]
2205
0
    CHECK_NONFATAL(constructed.size() == 1);
2206
0
    assert(constructed[0].ScriptSize() == script_size);
  Branch (2206:5): [True: 0, False: 0]
2207
0
    if (in.size() > 0) return {};
  Branch (2207:9): [True: 0, False: 0]
2208
0
    Node<Key> tl_node{std::move(constructed.front())};
2209
0
    tl_node.DuplicateKeyCheck(ctx);
2210
0
    return tl_node;
2211
0
}
2212
2213
/** Decode a script into opcode/push pairs.
2214
 *
2215
 * Construct a vector with one element per opcode in the script, in reverse order.
2216
 * Each element is a pair consisting of the opcode, as well as the data pushed by
2217
 * the opcode (including OP_n), if any. OP_CHECKSIGVERIFY, OP_CHECKMULTISIGVERIFY,
2218
 * OP_NUMEQUALVERIFY and OP_EQUALVERIFY are decomposed into OP_CHECKSIG, OP_CHECKMULTISIG,
2219
 * OP_EQUAL and OP_NUMEQUAL respectively, plus OP_VERIFY.
2220
 */
2221
std::optional<std::vector<Opcode>> DecomposeScript(const CScript& script);
2222
2223
/** Determine whether the passed pair (created by DecomposeScript) is pushing a number. */
2224
std::optional<int64_t> ParseScriptNumber(const Opcode& in);
2225
2226
enum class DecodeContext {
2227
    /** A single expression of type B, K, or V. Specifically, this can't be an
2228
     * and_v or an expression of type W (a: and s: wrappers). */
2229
    SINGLE_BKV_EXPR,
2230
    /** Potentially multiple SINGLE_BKV_EXPRs as children of (potentially multiple)
2231
     * and_v expressions. Syntactic sugar for MAYBE_AND_V + SINGLE_BKV_EXPR. */
2232
    BKV_EXPR,
2233
    /** An expression of type W (a: or s: wrappers). */
2234
    W_EXPR,
2235
2236
    /** SWAP expects the next element to be OP_SWAP (inside a W-type expression that
2237
     * didn't end with FROMALTSTACK), and wraps the top of the constructed stack
2238
     * with s: */
2239
    SWAP,
2240
    /** ALT expects the next element to be TOALTSTACK (we must have already read a
2241
     * FROMALTSTACK earlier), and wraps the top of the constructed stack with a: */
2242
    ALT,
2243
    /** CHECK wraps the top constructed node with c: */
2244
    CHECK,
2245
    /** DUP_IF wraps the top constructed node with d: */
2246
    DUP_IF,
2247
    /** VERIFY wraps the top constructed node with v: */
2248
    VERIFY,
2249
    /** NON_ZERO wraps the top constructed node with j: */
2250
    NON_ZERO,
2251
    /** ZERO_NOTEQUAL wraps the top constructed node with n: */
2252
    ZERO_NOTEQUAL,
2253
2254
    /** MAYBE_AND_V will check if the next part of the script could be a valid
2255
     * miniscript sub-expression, and if so it will push AND_V and SINGLE_BKV_EXPR
2256
     * to decode it and construct the and_v node. This is recursive, to deal with
2257
     * multiple and_v nodes inside each other. */
2258
    MAYBE_AND_V,
2259
    /** AND_V will construct an and_v node from the last two constructed nodes. */
2260
    AND_V,
2261
    /** AND_B will construct an and_b node from the last two constructed nodes. */
2262
    AND_B,
2263
    /** ANDOR will construct an andor node from the last three constructed nodes. */
2264
    ANDOR,
2265
    /** OR_B will construct an or_b node from the last two constructed nodes. */
2266
    OR_B,
2267
    /** OR_C will construct an or_c node from the last two constructed nodes. */
2268
    OR_C,
2269
    /** OR_D will construct an or_d node from the last two constructed nodes. */
2270
    OR_D,
2271
2272
    /** In a thresh expression, all sub-expressions other than the first are W-type,
2273
     * and end in OP_ADD. THRESH_W will check for this OP_ADD and either push a W_EXPR
2274
     * or a SINGLE_BKV_EXPR and jump to THRESH_E accordingly. */
2275
    THRESH_W,
2276
    /** THRESH_E constructs a thresh node from the appropriate number of constructed
2277
     * children. */
2278
    THRESH_E,
2279
2280
    /** ENDIF signals that we are inside some sort of OP_IF structure, which could be
2281
     * or_d, or_c, or_i, andor, d:, or j: wrapper, depending on what follows. We read
2282
     * a BKV_EXPR and then deal with the next opcode case-by-case. */
2283
    ENDIF,
2284
    /** If, inside an ENDIF context, we find an OP_NOTIF before finding an OP_ELSE,
2285
     * we could either be in an or_d or an or_c node. We then check for IFDUP to
2286
     * distinguish these cases. */
2287
    ENDIF_NOTIF,
2288
    /** If, inside an ENDIF context, we find an OP_ELSE, then we could be in either an
2289
     * or_i or an andor node. Read the next BKV_EXPR and find either an OP_IF or an
2290
     * OP_NOTIF. */
2291
    ENDIF_ELSE,
2292
};
2293
2294
//! Parse a miniscript from a bitcoin script
2295
template <typename Key, typename Ctx, typename I>
2296
inline std::optional<Node<Key>> DecodeScript(I& in, I last, const Ctx& ctx)
2297
0
{
2298
    // The two integers are used to hold state for thresh()
2299
0
    std::vector<std::tuple<DecodeContext, int64_t, int64_t>> to_parse;
2300
0
    std::vector<Node<Key>> constructed;
2301
2302
    // This is the top level, so we assume the type is B
2303
    // (in particular, disallowing top level W expressions)
2304
0
    to_parse.emplace_back(DecodeContext::BKV_EXPR, -1, -1);
2305
2306
0
    while (!to_parse.empty()) {
  Branch (2306:12): [True: 0, False: 0]
  Branch (2306:12): [True: 0, False: 0]
  Branch (2306:12): [True: 0, False: 0]
2307
        // Exit early if the Miniscript is not going to be valid.
2308
0
        if (!constructed.empty() && !constructed.back().IsValid()) return {};
  Branch (2308:13): [True: 0, False: 0]
  Branch (2308:37): [True: 0, False: 0]
  Branch (2308:13): [True: 0, False: 0]
  Branch (2308:37): [True: 0, False: 0]
  Branch (2308:13): [True: 0, False: 0]
  Branch (2308:37): [True: 0, False: 0]
2309
2310
        // Get the current context we are decoding within
2311
0
        auto [cur_context, n, k] = to_parse.back();
2312
0
        to_parse.pop_back();
2313
2314
0
        switch(cur_context) {
  Branch (2314:16): [True: 0, False: 0]
  Branch (2314:16): [True: 0, False: 0]
  Branch (2314:16): [True: 0, False: 0]
2315
0
        case DecodeContext::SINGLE_BKV_EXPR: {
  Branch (2315:9): [True: 0, False: 0]
  Branch (2315:9): [True: 0, False: 0]
  Branch (2315:9): [True: 0, False: 0]
2316
0
            if (in >= last) return {};
  Branch (2316:17): [True: 0, False: 0]
  Branch (2316:17): [True: 0, False: 0]
  Branch (2316:17): [True: 0, False: 0]
2317
2318
            // Constants
2319
0
            if (in[0].first == OP_1) {
  Branch (2319:17): [True: 0, False: 0]
  Branch (2319:17): [True: 0, False: 0]
  Branch (2319:17): [True: 0, False: 0]
2320
0
                ++in;
2321
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::JUST_1);
2322
0
                break;
2323
0
            }
2324
0
            if (in[0].first == OP_0) {
  Branch (2324:17): [True: 0, False: 0]
  Branch (2324:17): [True: 0, False: 0]
  Branch (2324:17): [True: 0, False: 0]
2325
0
                ++in;
2326
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::JUST_0);
2327
0
                break;
2328
0
            }
2329
            // Public keys
2330
0
            if (in[0].second.size() == 33 || in[0].second.size() == 32) {
  Branch (2330:17): [True: 0, False: 0]
  Branch (2330:46): [True: 0, False: 0]
  Branch (2330:17): [True: 0, False: 0]
  Branch (2330:46): [True: 0, False: 0]
  Branch (2330:17): [True: 0, False: 0]
  Branch (2330:46): [True: 0, False: 0]
2331
0
                auto key = ctx.FromPKBytes(in[0].second.begin(), in[0].second.end());
2332
0
                if (!key) return {};
  Branch (2332:21): [True: 0, False: 0]
  Branch (2332:21): [True: 0, False: 0]
  Branch (2332:21): [True: 0, False: 0]
2333
0
                ++in;
2334
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::PK_K, Vector(std::move(*key)));
2335
0
                break;
2336
0
            }
2337
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 (2337:17): [True: 0, False: 0]
  Branch (2337:35): [True: 0, False: 0]
  Branch (2337:63): [True: 0, False: 0]
  Branch (2337:90): [True: 0, False: 0]
  Branch (2337:119): [True: 0, False: 0]
  Branch (2337:144): [True: 0, False: 0]
  Branch (2337:17): [True: 0, False: 0]
  Branch (2337:35): [True: 0, False: 0]
  Branch (2337:63): [True: 0, False: 0]
  Branch (2337:90): [True: 0, False: 0]
  Branch (2337:119): [True: 0, False: 0]
  Branch (2337:144): [True: 0, False: 0]
  Branch (2337:17): [True: 0, False: 0]
  Branch (2337:35): [True: 0, False: 0]
  Branch (2337:63): [True: 0, False: 0]
  Branch (2337:90): [True: 0, False: 0]
  Branch (2337:119): [True: 0, False: 0]
  Branch (2337:144): [True: 0, False: 0]
2338
0
                auto key = ctx.FromPKHBytes(in[2].second.begin(), in[2].second.end());
2339
0
                if (!key) return {};
  Branch (2339:21): [True: 0, False: 0]
  Branch (2339:21): [True: 0, False: 0]
  Branch (2339:21): [True: 0, False: 0]
2340
0
                in += 5;
2341
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::PK_H, Vector(std::move(*key)));
2342
0
                break;
2343
0
            }
2344
            // Time locks
2345
0
            std::optional<int64_t> num;
2346
0
            if (last - in >= 2 && in[0].first == OP_CHECKSEQUENCEVERIFY && (num = ParseScriptNumber(in[1]))) {
  Branch (2346:17): [True: 0, False: 0]
  Branch (2346:17): [True: 0, False: 0]
  Branch (2346:35): [True: 0, False: 0]
  Branch (2346:76): [True: 0, False: 0]
  Branch (2346:17): [True: 0, False: 0]
  Branch (2346:17): [True: 0, False: 0]
  Branch (2346:35): [True: 0, False: 0]
  Branch (2346:76): [True: 0, False: 0]
  Branch (2346:17): [True: 0, False: 0]
  Branch (2346:17): [True: 0, False: 0]
  Branch (2346:35): [True: 0, False: 0]
  Branch (2346:76): [True: 0, False: 0]
2347
0
                in += 2;
2348
0
                if (*num < 1 || *num > 0x7FFFFFFFL) return {};
  Branch (2348:21): [True: 0, False: 0]
  Branch (2348:33): [True: 0, False: 0]
  Branch (2348:21): [True: 0, False: 0]
  Branch (2348:33): [True: 0, False: 0]
  Branch (2348:21): [True: 0, False: 0]
  Branch (2348:33): [True: 0, False: 0]
2349
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::OLDER, *num);
2350
0
                break;
2351
0
            }
2352
0
            if (last - in >= 2 && in[0].first == OP_CHECKLOCKTIMEVERIFY && (num = ParseScriptNumber(in[1]))) {
  Branch (2352:17): [True: 0, False: 0]
  Branch (2352:17): [True: 0, False: 0]
  Branch (2352:35): [True: 0, False: 0]
  Branch (2352:76): [True: 0, False: 0]
  Branch (2352:17): [True: 0, False: 0]
  Branch (2352:17): [True: 0, False: 0]
  Branch (2352:35): [True: 0, False: 0]
  Branch (2352:76): [True: 0, False: 0]
  Branch (2352:17): [True: 0, False: 0]
  Branch (2352:17): [True: 0, False: 0]
  Branch (2352:35): [True: 0, False: 0]
  Branch (2352:76): [True: 0, False: 0]
2353
0
                in += 2;
2354
0
                if (num < 1 || num > 0x7FFFFFFFL) return {};
  Branch (2354:21): [True: 0, False: 0]
  Branch (2354:21): [True: 0, False: 0]
  Branch (2354:32): [True: 0, False: 0]
  Branch (2354:21): [True: 0, False: 0]
  Branch (2354:21): [True: 0, False: 0]
  Branch (2354:32): [True: 0, False: 0]
  Branch (2354:21): [True: 0, False: 0]
  Branch (2354:21): [True: 0, False: 0]
  Branch (2354:32): [True: 0, False: 0]
2355
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::AFTER, *num);
2356
0
                break;
2357
0
            }
2358
            // Hashes
2359
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 (2359:17): [True: 0, False: 0]
  Branch (2359:17): [True: 0, False: 0]
  Branch (2359:35): [True: 0, False: 0]
  Branch (2359:62): [True: 0, False: 0]
  Branch (2359:90): [True: 0, False: 0]
  Branch (2359:117): [True: 0, False: 0]
  Branch (2359:153): [True: 0, False: 0]
  Branch (2359:166): [True: 0, False: 0]
  Branch (2359:17): [True: 0, False: 0]
  Branch (2359:17): [True: 0, False: 0]
  Branch (2359:35): [True: 0, False: 0]
  Branch (2359:62): [True: 0, False: 0]
  Branch (2359:90): [True: 0, False: 0]
  Branch (2359:117): [True: 0, False: 0]
  Branch (2359:153): [True: 0, False: 0]
  Branch (2359:166): [True: 0, False: 0]
  Branch (2359:17): [True: 0, False: 0]
  Branch (2359:17): [True: 0, False: 0]
  Branch (2359:35): [True: 0, False: 0]
  Branch (2359:62): [True: 0, False: 0]
  Branch (2359:90): [True: 0, False: 0]
  Branch (2359:117): [True: 0, False: 0]
  Branch (2359:153): [True: 0, False: 0]
  Branch (2359:166): [True: 0, False: 0]
2360
0
                if (in[2].first == OP_SHA256 && in[1].second.size() == 32) {
  Branch (2360:21): [True: 0, False: 0]
  Branch (2360:49): [True: 0, False: 0]
  Branch (2360:21): [True: 0, False: 0]
  Branch (2360:49): [True: 0, False: 0]
  Branch (2360:21): [True: 0, False: 0]
  Branch (2360:49): [True: 0, False: 0]
2361
0
                    constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::SHA256, in[1].second);
2362
0
                    in += 7;
2363
0
                    break;
2364
0
                } else if (in[2].first == OP_RIPEMD160 && in[1].second.size() == 20) {
  Branch (2364:28): [True: 0, False: 0]
  Branch (2364:59): [True: 0, False: 0]
  Branch (2364:28): [True: 0, False: 0]
  Branch (2364:59): [True: 0, False: 0]
  Branch (2364:28): [True: 0, False: 0]
  Branch (2364:59): [True: 0, False: 0]
2365
0
                    constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::RIPEMD160, in[1].second);
2366
0
                    in += 7;
2367
0
                    break;
2368
0
                } else if (in[2].first == OP_HASH256 && in[1].second.size() == 32) {
  Branch (2368:28): [True: 0, False: 0]
  Branch (2368:57): [True: 0, False: 0]
  Branch (2368:28): [True: 0, False: 0]
  Branch (2368:57): [True: 0, False: 0]
  Branch (2368:28): [True: 0, False: 0]
  Branch (2368:57): [True: 0, False: 0]
2369
0
                    constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::HASH256, in[1].second);
2370
0
                    in += 7;
2371
0
                    break;
2372
0
                } else if (in[2].first == OP_HASH160 && in[1].second.size() == 20) {
  Branch (2372:28): [True: 0, False: 0]
  Branch (2372:57): [True: 0, False: 0]
  Branch (2372:28): [True: 0, False: 0]
  Branch (2372:57): [True: 0, False: 0]
  Branch (2372:28): [True: 0, False: 0]
  Branch (2372:57): [True: 0, False: 0]
2373
0
                    constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::HASH160, in[1].second);
2374
0
                    in += 7;
2375
0
                    break;
2376
0
                }
2377
0
            }
2378
            // Multi
2379
0
            if (last - in >= 3 && in[0].first == OP_CHECKMULTISIG) {
  Branch (2379:17): [True: 0, False: 0]
  Branch (2379:35): [True: 0, False: 0]
  Branch (2379:17): [True: 0, False: 0]
  Branch (2379:35): [True: 0, False: 0]
  Branch (2379:17): [True: 0, False: 0]
  Branch (2379:35): [True: 0, False: 0]
2380
0
                if (IsTapscript(ctx.MsContext())) return {};
  Branch (2380:21): [True: 0, False: 0]
  Branch (2380:21): [True: 0, False: 0]
  Branch (2380:21): [True: 0, False: 0]
2381
0
                std::vector<Key> keys;
2382
0
                const auto n = ParseScriptNumber(in[1]);
2383
0
                if (!n || last - in < 3 + *n) return {};
  Branch (2383:21): [True: 0, False: 0]
  Branch (2383:27): [True: 0, False: 0]
  Branch (2383:21): [True: 0, False: 0]
  Branch (2383:27): [True: 0, False: 0]
  Branch (2383:21): [True: 0, False: 0]
  Branch (2383:27): [True: 0, False: 0]
2384
0
                if (*n < 1 || *n > 20) return {};
  Branch (2384:21): [True: 0, False: 0]
  Branch (2384:31): [True: 0, False: 0]
  Branch (2384:21): [True: 0, False: 0]
  Branch (2384:31): [True: 0, False: 0]
  Branch (2384:21): [True: 0, False: 0]
  Branch (2384:31): [True: 0, False: 0]
2385
0
                for (int i = 0; i < *n; ++i) {
  Branch (2385:33): [True: 0, False: 0]
  Branch (2385:33): [True: 0, False: 0]
  Branch (2385:33): [True: 0, False: 0]
2386
0
                    if (in[2 + i].second.size() != 33) return {};
  Branch (2386:25): [True: 0, False: 0]
  Branch (2386:25): [True: 0, False: 0]
  Branch (2386:25): [True: 0, False: 0]
2387
0
                    auto key = ctx.FromPKBytes(in[2 + i].second.begin(), in[2 + i].second.end());
2388
0
                    if (!key) return {};
  Branch (2388:25): [True: 0, False: 0]
  Branch (2388:25): [True: 0, False: 0]
  Branch (2388:25): [True: 0, False: 0]
2389
0
                    keys.push_back(std::move(*key));
2390
0
                }
2391
0
                const auto k = ParseScriptNumber(in[2 + *n]);
2392
0
                if (!k || *k < 1 || *k > *n) return {};
  Branch (2392:21): [True: 0, False: 0]
  Branch (2392:27): [True: 0, False: 0]
  Branch (2392:37): [True: 0, False: 0]
  Branch (2392:21): [True: 0, False: 0]
  Branch (2392:27): [True: 0, False: 0]
  Branch (2392:37): [True: 0, False: 0]
  Branch (2392:21): [True: 0, False: 0]
  Branch (2392:27): [True: 0, False: 0]
  Branch (2392:37): [True: 0, False: 0]
2393
0
                in += 3 + *n;
2394
0
                std::reverse(keys.begin(), keys.end());
2395
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::MULTI, std::move(keys), *k);
2396
0
                break;
2397
0
            }
2398
            // Tapscript's equivalent of multi
2399
0
            if (last - in >= 4 && in[0].first == OP_NUMEQUAL) {
  Branch (2399:17): [True: 0, False: 0]
  Branch (2399:35): [True: 0, False: 0]
  Branch (2399:17): [True: 0, False: 0]
  Branch (2399:35): [True: 0, False: 0]
  Branch (2399:17): [True: 0, False: 0]
  Branch (2399:35): [True: 0, False: 0]
2400
0
                if (!IsTapscript(ctx.MsContext())) return {};
  Branch (2400:21): [True: 0, False: 0]
  Branch (2400:21): [True: 0, False: 0]
  Branch (2400:21): [True: 0, False: 0]
2401
                // The necessary threshold of signatures.
2402
0
                const auto k = ParseScriptNumber(in[1]);
2403
0
                if (!k) return {};
  Branch (2403:21): [True: 0, False: 0]
  Branch (2403:21): [True: 0, False: 0]
  Branch (2403:21): [True: 0, False: 0]
2404
0
                if (*k < 1 || *k > MAX_PUBKEYS_PER_MULTI_A) return {};
  Branch (2404:21): [True: 0, False: 0]
  Branch (2404:31): [True: 0, False: 0]
  Branch (2404:21): [True: 0, False: 0]
  Branch (2404:31): [True: 0, False: 0]
  Branch (2404:21): [True: 0, False: 0]
  Branch (2404:31): [True: 0, False: 0]
2405
0
                if (last - in < 2 + *k * 2) return {};
  Branch (2405:21): [True: 0, False: 0]
  Branch (2405:21): [True: 0, False: 0]
  Branch (2405:21): [True: 0, False: 0]
2406
0
                std::vector<Key> keys;
2407
0
                keys.reserve(*k);
2408
                // Walk through the expected (pubkey, CHECKSIG[ADD]) pairs.
2409
0
                for (int pos = 2;; pos += 2) {
2410
0
                    if (last - in < pos + 2) return {};
  Branch (2410:25): [True: 0, False: 0]
  Branch (2410:25): [True: 0, False: 0]
  Branch (2410:25): [True: 0, False: 0]
2411
                    // Make sure it's indeed an x-only pubkey and a CHECKSIG[ADD], then parse the key.
2412
0
                    if (in[pos].first != OP_CHECKSIGADD && in[pos].first != OP_CHECKSIG) return {};
  Branch (2412:25): [True: 0, False: 0]
  Branch (2412:60): [True: 0, False: 0]
  Branch (2412:25): [True: 0, False: 0]
  Branch (2412:60): [True: 0, False: 0]
  Branch (2412:25): [True: 0, False: 0]
  Branch (2412:60): [True: 0, False: 0]
2413
0
                    if (in[pos + 1].second.size() != 32) return {};
  Branch (2413:25): [True: 0, False: 0]
  Branch (2413:25): [True: 0, False: 0]
  Branch (2413:25): [True: 0, False: 0]
2414
0
                    auto key = ctx.FromPKBytes(in[pos + 1].second.begin(), in[pos + 1].second.end());
2415
0
                    if (!key) return {};
  Branch (2415:25): [True: 0, False: 0]
  Branch (2415:25): [True: 0, False: 0]
  Branch (2415:25): [True: 0, False: 0]
2416
0
                    keys.push_back(std::move(*key));
2417
                    // Make sure early we don't parse an arbitrary large expression.
2418
0
                    if (keys.size() > MAX_PUBKEYS_PER_MULTI_A) return {};
  Branch (2418:25): [True: 0, False: 0]
  Branch (2418:25): [True: 0, False: 0]
  Branch (2418:25): [True: 0, False: 0]
2419
                    // OP_CHECKSIG means it was the last one to parse.
2420
0
                    if (in[pos].first == OP_CHECKSIG) break;
  Branch (2420:25): [True: 0, False: 0]
  Branch (2420:25): [True: 0, False: 0]
  Branch (2420:25): [True: 0, False: 0]
2421
0
                }
2422
0
                if (keys.size() < (size_t)*k) return {};
  Branch (2422:21): [True: 0, False: 0]
  Branch (2422:21): [True: 0, False: 0]
  Branch (2422:21): [True: 0, False: 0]
2423
0
                in += 2 + keys.size() * 2;
2424
0
                std::reverse(keys.begin(), keys.end());
2425
0
                constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::MULTI_A, std::move(keys), *k);
2426
0
                break;
2427
0
            }
2428
            /** In the following wrappers, we only need to push SINGLE_BKV_EXPR rather
2429
             * than BKV_EXPR, because and_v commutes with these wrappers. For example,
2430
             * c:and_v(X,Y) produces the same script as and_v(X,c:Y). */
2431
            // c: wrapper
2432
0
            if (in[0].first == OP_CHECKSIG) {
  Branch (2432:17): [True: 0, False: 0]
  Branch (2432:17): [True: 0, False: 0]
  Branch (2432:17): [True: 0, False: 0]
2433
0
                ++in;
2434
0
                to_parse.emplace_back(DecodeContext::CHECK, -1, -1);
2435
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2436
0
                break;
2437
0
            }
2438
            // v: wrapper
2439
0
            if (in[0].first == OP_VERIFY) {
  Branch (2439:17): [True: 0, False: 0]
  Branch (2439:17): [True: 0, False: 0]
  Branch (2439:17): [True: 0, False: 0]
2440
0
                ++in;
2441
0
                to_parse.emplace_back(DecodeContext::VERIFY, -1, -1);
2442
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2443
0
                break;
2444
0
            }
2445
            // n: wrapper
2446
0
            if (in[0].first == OP_0NOTEQUAL) {
  Branch (2446:17): [True: 0, False: 0]
  Branch (2446:17): [True: 0, False: 0]
  Branch (2446:17): [True: 0, False: 0]
2447
0
                ++in;
2448
0
                to_parse.emplace_back(DecodeContext::ZERO_NOTEQUAL, -1, -1);
2449
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2450
0
                break;
2451
0
            }
2452
            // Thresh
2453
0
            if (last - in >= 3 && in[0].first == OP_EQUAL && (num = ParseScriptNumber(in[1]))) {
  Branch (2453:17): [True: 0, False: 0]
  Branch (2453:17): [True: 0, False: 0]
  Branch (2453:35): [True: 0, False: 0]
  Branch (2453:62): [True: 0, False: 0]
  Branch (2453:17): [True: 0, False: 0]
  Branch (2453:17): [True: 0, False: 0]
  Branch (2453:35): [True: 0, False: 0]
  Branch (2453:62): [True: 0, False: 0]
  Branch (2453:17): [True: 0, False: 0]
  Branch (2453:17): [True: 0, False: 0]
  Branch (2453:35): [True: 0, False: 0]
  Branch (2453:62): [True: 0, False: 0]
2454
0
                if (*num < 1) return {};
  Branch (2454:21): [True: 0, False: 0]
  Branch (2454:21): [True: 0, False: 0]
  Branch (2454:21): [True: 0, False: 0]
2455
0
                in += 2;
2456
0
                to_parse.emplace_back(DecodeContext::THRESH_W, 0, *num);
2457
0
                break;
2458
0
            }
2459
            // OP_ENDIF can be WRAP_J, WRAP_D, ANDOR, OR_C, OR_D, or OR_I
2460
0
            if (in[0].first == OP_ENDIF) {
  Branch (2460:17): [True: 0, False: 0]
  Branch (2460:17): [True: 0, False: 0]
  Branch (2460:17): [True: 0, False: 0]
2461
0
                ++in;
2462
0
                to_parse.emplace_back(DecodeContext::ENDIF, -1, -1);
2463
0
                to_parse.emplace_back(DecodeContext::BKV_EXPR, -1, -1);
2464
0
                break;
2465
0
            }
2466
            /** In and_b and or_b nodes, we only look for SINGLE_BKV_EXPR, because
2467
             * or_b(and_v(X,Y),Z) has script [X] [Y] [Z] OP_BOOLOR, the same as
2468
             * and_v(X,or_b(Y,Z)). In this example, the former of these is invalid as
2469
             * miniscript, while the latter is valid. So we leave the and_v "outside"
2470
             * while decoding. */
2471
            // and_b
2472
0
            if (in[0].first == OP_BOOLAND) {
  Branch (2472:17): [True: 0, False: 0]
  Branch (2472:17): [True: 0, False: 0]
  Branch (2472:17): [True: 0, False: 0]
2473
0
                ++in;
2474
0
                to_parse.emplace_back(DecodeContext::AND_B, -1, -1);
2475
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2476
0
                to_parse.emplace_back(DecodeContext::W_EXPR, -1, -1);
2477
0
                break;
2478
0
            }
2479
            // or_b
2480
0
            if (in[0].first == OP_BOOLOR) {
  Branch (2480:17): [True: 0, False: 0]
  Branch (2480:17): [True: 0, False: 0]
  Branch (2480:17): [True: 0, False: 0]
2481
0
                ++in;
2482
0
                to_parse.emplace_back(DecodeContext::OR_B, -1, -1);
2483
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2484
0
                to_parse.emplace_back(DecodeContext::W_EXPR, -1, -1);
2485
0
                break;
2486
0
            }
2487
            // Unrecognised expression
2488
0
            return {};
2489
0
        }
2490
0
        case DecodeContext::BKV_EXPR: {
  Branch (2490:9): [True: 0, False: 0]
  Branch (2490:9): [True: 0, False: 0]
  Branch (2490:9): [True: 0, False: 0]
2491
0
            to_parse.emplace_back(DecodeContext::MAYBE_AND_V, -1, -1);
2492
0
            to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2493
0
            break;
2494
0
        }
2495
0
        case DecodeContext::W_EXPR: {
  Branch (2495:9): [True: 0, False: 0]
  Branch (2495:9): [True: 0, False: 0]
  Branch (2495:9): [True: 0, False: 0]
2496
            // a: wrapper
2497
0
            if (in >= last) return {};
  Branch (2497:17): [True: 0, False: 0]
  Branch (2497:17): [True: 0, False: 0]
  Branch (2497:17): [True: 0, False: 0]
2498
0
            if (in[0].first == OP_FROMALTSTACK) {
  Branch (2498:17): [True: 0, False: 0]
  Branch (2498:17): [True: 0, False: 0]
  Branch (2498:17): [True: 0, False: 0]
2499
0
                ++in;
2500
0
                to_parse.emplace_back(DecodeContext::ALT, -1, -1);
2501
0
            } else {
2502
0
                to_parse.emplace_back(DecodeContext::SWAP, -1, -1);
2503
0
            }
2504
0
            to_parse.emplace_back(DecodeContext::BKV_EXPR, -1, -1);
2505
0
            break;
2506
0
        }
2507
0
        case DecodeContext::MAYBE_AND_V: {
  Branch (2507:9): [True: 0, False: 0]
  Branch (2507:9): [True: 0, False: 0]
  Branch (2507:9): [True: 0, False: 0]
2508
            // If we reach a potential AND_V top-level, check if the next part of the script could be another AND_V child
2509
            // These op-codes cannot end any well-formed miniscript so cannot be used in an and_v node.
2510
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 (2510:17): [True: 0, False: 0]
  Branch (2510:30): [True: 0, False: 0]
  Branch (2510:54): [True: 0, False: 0]
  Branch (2510:80): [True: 0, False: 0]
  Branch (2510:107): [True: 0, False: 0]
  Branch (2510:139): [True: 0, False: 0]
  Branch (2510:17): [True: 0, False: 0]
  Branch (2510:30): [True: 0, False: 0]
  Branch (2510:54): [True: 0, False: 0]
  Branch (2510:80): [True: 0, False: 0]
  Branch (2510:107): [True: 0, False: 0]
  Branch (2510:139): [True: 0, False: 0]
  Branch (2510:17): [True: 0, False: 0]
  Branch (2510:30): [True: 0, False: 0]
  Branch (2510:54): [True: 0, False: 0]
  Branch (2510:80): [True: 0, False: 0]
  Branch (2510:107): [True: 0, False: 0]
  Branch (2510:139): [True: 0, False: 0]
2511
0
                to_parse.emplace_back(DecodeContext::AND_V, -1, -1);
2512
                // BKV_EXPR can contain more AND_V nodes
2513
0
                to_parse.emplace_back(DecodeContext::BKV_EXPR, -1, -1);
2514
0
            }
2515
0
            break;
2516
0
        }
2517
0
        case DecodeContext::SWAP: {
  Branch (2517:9): [True: 0, False: 0]
  Branch (2517:9): [True: 0, False: 0]
  Branch (2517:9): [True: 0, False: 0]
2518
0
            if (in >= last || in[0].first != OP_SWAP || constructed.empty()) return {};
  Branch (2518:17): [True: 0, False: 0]
  Branch (2518:31): [True: 0, False: 0]
  Branch (2518:57): [True: 0, False: 0]
  Branch (2518:17): [True: 0, False: 0]
  Branch (2518:31): [True: 0, False: 0]
  Branch (2518:57): [True: 0, False: 0]
  Branch (2518:17): [True: 0, False: 0]
  Branch (2518:31): [True: 0, False: 0]
  Branch (2518:57): [True: 0, False: 0]
2519
0
            ++in;
2520
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_S, Vector(std::move(constructed.back()))};
2521
0
            break;
2522
0
        }
2523
0
        case DecodeContext::ALT: {
  Branch (2523:9): [True: 0, False: 0]
  Branch (2523:9): [True: 0, False: 0]
  Branch (2523:9): [True: 0, False: 0]
2524
0
            if (in >= last || in[0].first != OP_TOALTSTACK || constructed.empty()) return {};
  Branch (2524:17): [True: 0, False: 0]
  Branch (2524:31): [True: 0, False: 0]
  Branch (2524:63): [True: 0, False: 0]
  Branch (2524:17): [True: 0, False: 0]
  Branch (2524:31): [True: 0, False: 0]
  Branch (2524:63): [True: 0, False: 0]
  Branch (2524:17): [True: 0, False: 0]
  Branch (2524:31): [True: 0, False: 0]
  Branch (2524:63): [True: 0, False: 0]
2525
0
            ++in;
2526
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_A, Vector(std::move(constructed.back()))};
2527
0
            break;
2528
0
        }
2529
0
        case DecodeContext::CHECK: {
  Branch (2529:9): [True: 0, False: 0]
  Branch (2529:9): [True: 0, False: 0]
  Branch (2529:9): [True: 0, False: 0]
2530
0
            if (constructed.empty()) return {};
  Branch (2530:17): [True: 0, False: 0]
  Branch (2530:17): [True: 0, False: 0]
  Branch (2530:17): [True: 0, False: 0]
2531
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_C, Vector(std::move(constructed.back()))};
2532
0
            break;
2533
0
        }
2534
0
        case DecodeContext::DUP_IF: {
  Branch (2534:9): [True: 0, False: 0]
  Branch (2534:9): [True: 0, False: 0]
  Branch (2534:9): [True: 0, False: 0]
2535
0
            if (constructed.empty()) return {};
  Branch (2535:17): [True: 0, False: 0]
  Branch (2535:17): [True: 0, False: 0]
  Branch (2535:17): [True: 0, False: 0]
2536
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_D, Vector(std::move(constructed.back()))};
2537
0
            break;
2538
0
        }
2539
0
        case DecodeContext::VERIFY: {
  Branch (2539:9): [True: 0, False: 0]
  Branch (2539:9): [True: 0, False: 0]
  Branch (2539:9): [True: 0, False: 0]
2540
0
            if (constructed.empty()) return {};
  Branch (2540:17): [True: 0, False: 0]
  Branch (2540:17): [True: 0, False: 0]
  Branch (2540:17): [True: 0, False: 0]
2541
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_V, Vector(std::move(constructed.back()))};
2542
0
            break;
2543
0
        }
2544
0
        case DecodeContext::NON_ZERO: {
  Branch (2544:9): [True: 0, False: 0]
  Branch (2544:9): [True: 0, False: 0]
  Branch (2544:9): [True: 0, False: 0]
2545
0
            if (constructed.empty()) return {};
  Branch (2545:17): [True: 0, False: 0]
  Branch (2545:17): [True: 0, False: 0]
  Branch (2545:17): [True: 0, False: 0]
2546
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_J, Vector(std::move(constructed.back()))};
2547
0
            break;
2548
0
        }
2549
0
        case DecodeContext::ZERO_NOTEQUAL: {
  Branch (2549:9): [True: 0, False: 0]
  Branch (2549:9): [True: 0, False: 0]
  Branch (2549:9): [True: 0, False: 0]
2550
0
            if (constructed.empty()) return {};
  Branch (2550:17): [True: 0, False: 0]
  Branch (2550:17): [True: 0, False: 0]
  Branch (2550:17): [True: 0, False: 0]
2551
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::WRAP_N, Vector(std::move(constructed.back()))};
2552
0
            break;
2553
0
        }
2554
0
        case DecodeContext::AND_V: {
  Branch (2554:9): [True: 0, False: 0]
  Branch (2554:9): [True: 0, False: 0]
  Branch (2554:9): [True: 0, False: 0]
2555
0
            if (constructed.size() < 2) return {};
  Branch (2555:17): [True: 0, False: 0]
  Branch (2555:17): [True: 0, False: 0]
  Branch (2555:17): [True: 0, False: 0]
2556
0
            BuildBack(ctx.MsContext(), Fragment::AND_V, constructed, /*reverse=*/true);
2557
0
            break;
2558
0
        }
2559
0
        case DecodeContext::AND_B: {
  Branch (2559:9): [True: 0, False: 0]
  Branch (2559:9): [True: 0, False: 0]
  Branch (2559:9): [True: 0, False: 0]
2560
0
            if (constructed.size() < 2) return {};
  Branch (2560:17): [True: 0, False: 0]
  Branch (2560:17): [True: 0, False: 0]
  Branch (2560:17): [True: 0, False: 0]
2561
0
            BuildBack(ctx.MsContext(), Fragment::AND_B, constructed, /*reverse=*/true);
2562
0
            break;
2563
0
        }
2564
0
        case DecodeContext::OR_B: {
  Branch (2564:9): [True: 0, False: 0]
  Branch (2564:9): [True: 0, False: 0]
  Branch (2564:9): [True: 0, False: 0]
2565
0
            if (constructed.size() < 2) return {};
  Branch (2565:17): [True: 0, False: 0]
  Branch (2565:17): [True: 0, False: 0]
  Branch (2565:17): [True: 0, False: 0]
2566
0
            BuildBack(ctx.MsContext(), Fragment::OR_B, constructed, /*reverse=*/true);
2567
0
            break;
2568
0
        }
2569
0
        case DecodeContext::OR_C: {
  Branch (2569:9): [True: 0, False: 0]
  Branch (2569:9): [True: 0, False: 0]
  Branch (2569:9): [True: 0, False: 0]
2570
0
            if (constructed.size() < 2) return {};
  Branch (2570:17): [True: 0, False: 0]
  Branch (2570:17): [True: 0, False: 0]
  Branch (2570:17): [True: 0, False: 0]
2571
0
            BuildBack(ctx.MsContext(), Fragment::OR_C, constructed, /*reverse=*/true);
2572
0
            break;
2573
0
        }
2574
0
        case DecodeContext::OR_D: {
  Branch (2574:9): [True: 0, False: 0]
  Branch (2574:9): [True: 0, False: 0]
  Branch (2574:9): [True: 0, False: 0]
2575
0
            if (constructed.size() < 2) return {};
  Branch (2575:17): [True: 0, False: 0]
  Branch (2575:17): [True: 0, False: 0]
  Branch (2575:17): [True: 0, False: 0]
2576
0
            BuildBack(ctx.MsContext(), Fragment::OR_D, constructed, /*reverse=*/true);
2577
0
            break;
2578
0
        }
2579
0
        case DecodeContext::ANDOR: {
  Branch (2579:9): [True: 0, False: 0]
  Branch (2579:9): [True: 0, False: 0]
  Branch (2579:9): [True: 0, False: 0]
2580
0
            if (constructed.size() < 3) return {};
  Branch (2580:17): [True: 0, False: 0]
  Branch (2580:17): [True: 0, False: 0]
  Branch (2580:17): [True: 0, False: 0]
2581
0
            Node left{std::move(constructed.back())};
2582
0
            constructed.pop_back();
2583
0
            Node right{std::move(constructed.back())};
2584
0
            constructed.pop_back();
2585
0
            Node mid{std::move(constructed.back())};
2586
0
            constructed.back() = Node{internal::NoDupCheck{}, ctx.MsContext(), Fragment::ANDOR, Vector(std::move(left), std::move(mid), std::move(right))};
2587
0
            break;
2588
0
        }
2589
0
        case DecodeContext::THRESH_W: {
  Branch (2589:9): [True: 0, False: 0]
  Branch (2589:9): [True: 0, False: 0]
  Branch (2589:9): [True: 0, False: 0]
2590
0
            if (in >= last) return {};
  Branch (2590:17): [True: 0, False: 0]
  Branch (2590:17): [True: 0, False: 0]
  Branch (2590:17): [True: 0, False: 0]
2591
0
            if (in[0].first == OP_ADD) {
  Branch (2591:17): [True: 0, False: 0]
  Branch (2591:17): [True: 0, False: 0]
  Branch (2591:17): [True: 0, False: 0]
2592
0
                ++in;
2593
0
                to_parse.emplace_back(DecodeContext::THRESH_W, n+1, k);
2594
0
                to_parse.emplace_back(DecodeContext::W_EXPR, -1, -1);
2595
0
            } else {
2596
0
                to_parse.emplace_back(DecodeContext::THRESH_E, n+1, k);
2597
                // All children of thresh have type modifier d, so cannot be and_v
2598
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2599
0
            }
2600
0
            break;
2601
0
        }
2602
0
        case DecodeContext::THRESH_E: {
  Branch (2602:9): [True: 0, False: 0]
  Branch (2602:9): [True: 0, False: 0]
  Branch (2602:9): [True: 0, False: 0]
2603
0
            if (k < 1 || k > n || constructed.size() < static_cast<size_t>(n)) return {};
  Branch (2603:17): [True: 0, False: 0]
  Branch (2603:26): [True: 0, False: 0]
  Branch (2603:35): [True: 0, False: 0]
  Branch (2603:17): [True: 0, False: 0]
  Branch (2603:26): [True: 0, False: 0]
  Branch (2603:35): [True: 0, False: 0]
  Branch (2603:17): [True: 0, False: 0]
  Branch (2603:26): [True: 0, False: 0]
  Branch (2603:35): [True: 0, False: 0]
2604
0
            std::vector<Node<Key>> subs;
2605
0
            for (int i = 0; i < n; ++i) {
  Branch (2605:29): [True: 0, False: 0]
  Branch (2605:29): [True: 0, False: 0]
  Branch (2605:29): [True: 0, False: 0]
2606
0
                Node sub{std::move(constructed.back())};
2607
0
                constructed.pop_back();
2608
0
                subs.push_back(std::move(sub));
2609
0
            }
2610
0
            constructed.emplace_back(internal::NoDupCheck{}, ctx.MsContext(), Fragment::THRESH, std::move(subs), k);
2611
0
            break;
2612
0
        }
2613
0
        case DecodeContext::ENDIF: {
  Branch (2613:9): [True: 0, False: 0]
  Branch (2613:9): [True: 0, False: 0]
  Branch (2613:9): [True: 0, False: 0]
2614
0
            if (in >= last) return {};
  Branch (2614:17): [True: 0, False: 0]
  Branch (2614:17): [True: 0, False: 0]
  Branch (2614:17): [True: 0, False: 0]
2615
2616
            // could be andor or or_i
2617
0
            if (in[0].first == OP_ELSE) {
  Branch (2617:17): [True: 0, False: 0]
  Branch (2617:17): [True: 0, False: 0]
  Branch (2617:17): [True: 0, False: 0]
2618
0
                ++in;
2619
0
                to_parse.emplace_back(DecodeContext::ENDIF_ELSE, -1, -1);
2620
0
                to_parse.emplace_back(DecodeContext::BKV_EXPR, -1, -1);
2621
0
            }
2622
            // could be j: or d: wrapper
2623
0
            else if (in[0].first == OP_IF) {
  Branch (2623:22): [True: 0, False: 0]
  Branch (2623:22): [True: 0, False: 0]
  Branch (2623:22): [True: 0, False: 0]
2624
0
                if (last - in >= 2 && in[1].first == OP_DUP) {
  Branch (2624:21): [True: 0, False: 0]
  Branch (2624:39): [True: 0, False: 0]
  Branch (2624:21): [True: 0, False: 0]
  Branch (2624:39): [True: 0, False: 0]
  Branch (2624:21): [True: 0, False: 0]
  Branch (2624:39): [True: 0, False: 0]
2625
0
                    in += 2;
2626
0
                    to_parse.emplace_back(DecodeContext::DUP_IF, -1, -1);
2627
0
                } else if (last - in >= 3 && in[1].first == OP_0NOTEQUAL && in[2].first == OP_SIZE) {
  Branch (2627:28): [True: 0, False: 0]
  Branch (2627:46): [True: 0, False: 0]
  Branch (2627:77): [True: 0, False: 0]
  Branch (2627:28): [True: 0, False: 0]
  Branch (2627:46): [True: 0, False: 0]
  Branch (2627:77): [True: 0, False: 0]
  Branch (2627:28): [True: 0, False: 0]
  Branch (2627:46): [True: 0, False: 0]
  Branch (2627:77): [True: 0, False: 0]
2628
0
                    in += 3;
2629
0
                    to_parse.emplace_back(DecodeContext::NON_ZERO, -1, -1);
2630
0
                }
2631
0
                else {
2632
0
                    return {};
2633
0
                }
2634
            // could be or_c or or_d
2635
0
            } else if (in[0].first == OP_NOTIF) {
  Branch (2635:24): [True: 0, False: 0]
  Branch (2635:24): [True: 0, False: 0]
  Branch (2635:24): [True: 0, False: 0]
2636
0
                ++in;
2637
0
                to_parse.emplace_back(DecodeContext::ENDIF_NOTIF, -1, -1);
2638
0
            }
2639
0
            else {
2640
0
                return {};
2641
0
            }
2642
0
            break;
2643
0
        }
2644
0
        case DecodeContext::ENDIF_NOTIF: {
  Branch (2644:9): [True: 0, False: 0]
  Branch (2644:9): [True: 0, False: 0]
  Branch (2644:9): [True: 0, False: 0]
2645
0
            if (in >= last) return {};
  Branch (2645:17): [True: 0, False: 0]
  Branch (2645:17): [True: 0, False: 0]
  Branch (2645:17): [True: 0, False: 0]
2646
0
            if (in[0].first == OP_IFDUP) {
  Branch (2646:17): [True: 0, False: 0]
  Branch (2646:17): [True: 0, False: 0]
  Branch (2646:17): [True: 0, False: 0]
2647
0
                ++in;
2648
0
                to_parse.emplace_back(DecodeContext::OR_D, -1, -1);
2649
0
            } else {
2650
0
                to_parse.emplace_back(DecodeContext::OR_C, -1, -1);
2651
0
            }
2652
            // or_c and or_d both require X to have type modifier d so, can't contain and_v
2653
0
            to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2654
0
            break;
2655
0
        }
2656
0
        case DecodeContext::ENDIF_ELSE: {
  Branch (2656:9): [True: 0, False: 0]
  Branch (2656:9): [True: 0, False: 0]
  Branch (2656:9): [True: 0, False: 0]
2657
0
            if (in >= last) return {};
  Branch (2657:17): [True: 0, False: 0]
  Branch (2657:17): [True: 0, False: 0]
  Branch (2657:17): [True: 0, False: 0]
2658
0
            if (in[0].first == OP_IF) {
  Branch (2658:17): [True: 0, False: 0]
  Branch (2658:17): [True: 0, False: 0]
  Branch (2658:17): [True: 0, False: 0]
2659
0
                ++in;
2660
0
                BuildBack(ctx.MsContext(), Fragment::OR_I, constructed, /*reverse=*/true);
2661
0
            } else if (in[0].first == OP_NOTIF) {
  Branch (2661:24): [True: 0, False: 0]
  Branch (2661:24): [True: 0, False: 0]
  Branch (2661:24): [True: 0, False: 0]
2662
0
                ++in;
2663
0
                to_parse.emplace_back(DecodeContext::ANDOR, -1, -1);
2664
                // andor requires X to have type modifier d, so it can't be and_v
2665
0
                to_parse.emplace_back(DecodeContext::SINGLE_BKV_EXPR, -1, -1);
2666
0
            } else {
2667
0
                return {};
2668
0
            }
2669
0
            break;
2670
0
        }
2671
0
        }
2672
0
    }
2673
0
    if (constructed.size() != 1) return {};
  Branch (2673:9): [True: 0, False: 0]
  Branch (2673:9): [True: 0, False: 0]
  Branch (2673:9): [True: 0, False: 0]
2674
0
    Node tl_node{std::move(constructed.front())};
2675
0
    tl_node.DuplicateKeyCheck(ctx);
2676
    // Note that due to how ComputeType works (only assign the type to the node if the
2677
    // subs' types are valid) this would fail if any node of tree is badly typed.
2678
0
    if (!tl_node.IsValidTopLevel()) return {};
  Branch (2678:9): [True: 0, False: 0]
  Branch (2678:9): [True: 0, False: 0]
  Branch (2678:9): [True: 0, False: 0]
2679
0
    return tl_node;
2680
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&)
2681
2682
} // namespace internal
2683
2684
template <typename Ctx>
2685
inline std::optional<Node<typename Ctx::Key>> FromString(const std::string& str, const Ctx& ctx)
2686
0
{
2687
0
    return internal::Parse<typename Ctx::Key>(str, ctx);
2688
0
}
2689
2690
template <typename Ctx>
2691
inline std::optional<Node<typename Ctx::Key>> FromScript(const CScript& script, const Ctx& ctx)
2692
0
{
2693
0
    using namespace internal;
2694
    // A too large Script is necessarily invalid, don't bother parsing it.
2695
0
    if (script.size() > MaxScriptSize(ctx.MsContext())) return {};
  Branch (2695:9): [True: 0, False: 0]
  Branch (2695:9): [True: 0, False: 0]
  Branch (2695:9): [True: 0, False: 0]
2696
0
    auto decomposed = DecomposeScript(script);
2697
0
    if (!decomposed) 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 it = decomposed->begin();
2699
0
    auto ret = DecodeScript<typename Ctx::Key>(it, decomposed->end(), ctx);
2700
0
    if (!ret) return {};
  Branch (2700:9): [True: 0, False: 0]
  Branch (2700:9): [True: 0, False: 0]
  Branch (2700:9): [True: 0, False: 0]
2701
0
    if (it != decomposed->end()) return {};
  Branch (2701:9): [True: 0, False: 0]
  Branch (2701:9): [True: 0, False: 0]
  Branch (2701:9): [True: 0, False: 0]
2702
0
    return ret;
2703
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&)
2704
2705
} // namespace miniscript
2706
2707
#endif // BITCOIN_SCRIPT_MINISCRIPT_H