MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / InputStack

Class InputStack

src/script/miniscript.h:308–342  ·  view source on GitHub ↗

An object representing a sequence of witness stack elements.

Source from the content-addressed store, hash-verified

306
307//! An object representing a sequence of witness stack elements.
308struct InputStack {
309 /** Whether this stack is valid for its intended purpose (satisfaction or dissatisfaction of a Node).
310 * The MAYBE value is used for size estimation, when keys/preimages may actually be unavailable,
311 * but may be available at signing time. This makes the InputStack structure and signing logic,
312 * filled with dummy signatures/preimages usable for witness size estimation.
313 */
314 Availability available = Availability::YES;
315 //! Whether this stack contains a digital signature.
316 bool has_sig = false;
317 //! Whether this stack is malleable (can be turned into an equally valid other stack by a third party).
318 bool malleable = false;
319 //! Whether this stack is non-canonical (using a construction known to be unnecessary for satisfaction).
320 //! Note that this flag does not affect the satisfaction algorithm; it is only used for sanity checking.
321 bool non_canon = false;
322 //! Serialized witness size.
323 size_t size = 0;
324 //! Data elements.
325 std::vector<std::vector<unsigned char>> stack;
326 //! Construct an empty stack (valid).
327 InputStack() = default;
328 //! Construct a valid single-element stack (with an element up to 75 bytes).
329 InputStack(std::vector<unsigned char> in) : size(in.size() + 1), stack(Vector(std::move(in))) {}
330 //! Change availability
331 InputStack& SetAvailable(Availability avail);
332 //! Mark this input stack as having a signature.
333 InputStack& SetWithSig();
334 //! Mark this input stack as non-canonical (known to not be necessary in non-malleable satisfactions).
335 InputStack& SetNonCanon();
336 //! Mark this input stack as malleable.
337 InputStack& SetMalleable(bool x = true);
338 //! Concatenate two input stacks.
339 friend InputStack operator+(InputStack a, InputStack b);
340 //! Choose between two potential input stacks.
341 friend InputStack operator|(InputStack a, InputStack b);
342};
343
344/** A stack consisting of a single zero-length element (interpreted as 0 by the script interpreter in numeric context). */
345static const auto ZERO = InputStack(std::vector<unsigned char>());

Callers 2

miniscript.hFile · 0.85
ProduceInputMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected