![]() |
Bitcoin Core
25.99.0
P2P Digital Currency
|
Classes | |
struct | InputStack |
An object representing a sequence of witness stack elements. More... | |
struct | InputResult |
A pair of a satisfaction and a dissatisfaction InputStack. More... | |
struct | MaxInt |
Class whose objects represent the maximum of a list of integers. More... | |
struct | Ops |
struct | StackSize |
struct | WitnessSize |
struct | NoDupCheck |
Enumerations | |
enum class | ParseContext { WRAPPED_EXPR , EXPR , SWAP , ALT , CHECK , DUP_IF , VERIFY , NON_ZERO , ZERO_NOTEQUAL , WRAP_U , WRAP_T , AND_N , AND_V , AND_B , ANDOR , OR_B , OR_C , OR_D , OR_I , THRESH , COMMA , CLOSE_BRACKET } |
enum class | DecodeContext { SINGLE_BKV_EXPR , BKV_EXPR , W_EXPR , SWAP , ALT , CHECK , DUP_IF , VERIFY , NON_ZERO , ZERO_NOTEQUAL , MAYBE_AND_V , AND_V , AND_B , ANDOR , OR_B , OR_C , OR_D , THRESH_W , THRESH_E , ENDIF , ENDIF_NOTIF , ENDIF_ELSE } |
Functions | |
Type | SanitizeType (Type x) |
A helper sanitizer/checker for the output of CalcType. More... | |
Type | ComputeType (Fragment fragment, Type x, Type y, Type z, const std::vector< Type > &sub_types, uint32_t k, size_t data_size, size_t n_subs, size_t n_keys) |
Helper function for Node::CalcType. More... | |
size_t | ComputeScriptLen (Fragment fragment, Type sub0typ, size_t subsize, uint32_t k, size_t n_subs, size_t n_keys) |
Helper function for Node::CalcScriptLen. More... | |
InputStack | operator+ (InputStack a, InputStack b) |
InputStack | operator| (InputStack a, InputStack b) |
std::optional< std::vector< Opcode > > | DecomposeScript (const CScript &script) |
Decode a script into opcode/push pairs. More... | |
std::optional< int64_t > | ParseScriptNumber (const Opcode &in) |
Determine whether the passed pair (created by DecomposeScript) is pushing a number. More... | |
int | FindNextChar (Span< const char > sp, const char m) |
template<typename Key , typename Ctx > | |
std::optional< std::pair< Key, int > > | ParseKeyEnd (Span< const char > in, const Ctx &ctx) |
Parse a key string ending at the end of the fragment's text representation. More... | |
template<typename Ctx > | |
std::optional< std::pair< std::vector< unsigned char >, int > > | ParseHexStrEnd (Span< const char > in, const size_t expected_size, const Ctx &ctx) |
Parse a hex string ending at the end of the fragment's text representation. More... | |
template<typename Key > | |
void | BuildBack (Fragment nt, std::vector< NodeRef< Key >> &constructed, const bool reverse=false) |
BuildBack pops the last two elements off constructed and wraps them in the specified Fragment. More... | |
template<typename Key , typename Ctx > | |
NodeRef< Key > | Parse (Span< const char > in, const Ctx &ctx) |
Parse a miniscript from its textual descriptor form. More... | |
template<typename Key , typename Ctx , typename I > | |
NodeRef< Key > | DecodeScript (I &in, I last, const Ctx &ctx) |
Parse a miniscript from a bitcoin script. More... | |
Variables | |
static const auto | ZERO = InputStack(std::vector<unsigned char>()) |
A stack consisting of a single zero-length element (interpreted as 0 by the script interpreter in numeric context). More... | |
static const auto | ZERO32 = InputStack(std::vector<unsigned char>(32, 0)).SetMalleable() |
A stack consisting of a single malleable 32-byte 0x0000...0000 element (for dissatisfying hash challenges). More... | |
static const auto | ONE = InputStack(Vector((unsigned char)1)) |
A stack consisting of a single 0x01 element (interpreted as 1 by the script interpreted in numeric context). More... | |
static const auto | EMPTY = InputStack() |
The empty stack. More... | |
static const auto | INVALID = InputStack().SetAvailable(Availability::NO) |
A stack representing the lack of any (dis)satisfactions. More... | |
|
strong |
Definition at line 1819 of file miniscript.h.
|
strong |
Definition at line 1349 of file miniscript.h.
void miniscript::internal::BuildBack | ( | Fragment | nt, |
std::vector< NodeRef< Key >> & | constructed, | ||
const bool | reverse = false |
||
) |
BuildBack pops the last two elements off constructed
and wraps them in the specified Fragment.
Definition at line 1432 of file miniscript.h.
size_t miniscript::internal::ComputeScriptLen | ( | Fragment | fragment, |
Type | sub0typ, | ||
size_t | subsize, | ||
uint32_t | k, | ||
size_t | n_subs, | ||
size_t | n_keys | ||
) |
Helper function for Node::CalcScriptLen.
Definition at line 249 of file miniscript.cpp.
Type miniscript::internal::ComputeType | ( | Fragment | fragment, |
Type | x, | ||
Type | y, | ||
Type | z, | ||
const std::vector< Type > & | sub_types, | ||
uint32_t | k, | ||
size_t | data_size, | ||
size_t | n_subs, | ||
size_t | n_keys | ||
) |
Helper function for Node::CalcType.
Definition at line 35 of file miniscript.cpp.
|
inline |
Parse a miniscript from a bitcoin script.
In the following wrappers, we only need to push SINGLE_BKV_EXPR rather than BKV_EXPR, because and_v commutes with these wrappers. For example, c:and_v(X,Y) produces the same script as and_v(X,c:Y).
In and_b and or_b nodes, we only look for SINGLE_BKV_EXPR, because or_b(and_v(X,Y),Z) has script [X] [Y] [Z] OP_BOOLOR, the same as and_v(X,or_b(Y,Z)). In this example, the former of these is invalid as miniscript, while the latter is valid. So we leave the and_v "outside" while decoding.
Definition at line 1889 of file miniscript.h.
std::optional< std::vector< Opcode > > miniscript::internal::DecomposeScript | ( | const CScript & | script | ) |
Decode a script into opcode/push pairs.
Construct a vector with one element per opcode in the script, in reverse order. Each element is a pair consisting of the opcode, as well as the data pushed by the opcode (including OP_n), if any. OP_CHECKSIGVERIFY, OP_CHECKMULTISIGVERIFY, and OP_EQUALVERIFY are decomposed into OP_CHECKSIG, OP_CHECKMULTISIG, OP_EQUAL respectively, plus OP_VERIFY.
Definition at line 351 of file miniscript.cpp.
int miniscript::internal::FindNextChar | ( | Span< const char > | sp, |
const char | m | ||
) |
Definition at line 400 of file miniscript.cpp.
InputStack miniscript::internal::operator+ | ( | InputStack | a, |
InputStack | b | ||
) |
Definition at line 308 of file miniscript.cpp.
InputStack miniscript::internal::operator| | ( | InputStack | a, |
InputStack | b | ||
) |
Definition at line 322 of file miniscript.cpp.
|
inline |
Parse a miniscript from its textual descriptor form.
This does not check whether the script is valid, let alone sane. The caller is expected to use the IsValidTopLevel()
and IsSaneTopLevel()
to check for these properties on the node.
Definition at line 1449 of file miniscript.h.
std::optional<std::pair<std::vector<unsigned char>, int> > miniscript::internal::ParseHexStrEnd | ( | Span< const char > | in, |
const size_t | expected_size, | ||
const Ctx & | ctx | ||
) |
Parse a hex string ending at the end of the fragment's text representation.
Definition at line 1418 of file miniscript.h.
std::optional<std::pair<Key, int> > miniscript::internal::ParseKeyEnd | ( | Span< const char > | in, |
const Ctx & | ctx | ||
) |
Parse a key string ending at the end of the fragment's text representation.
Definition at line 1407 of file miniscript.h.
std::optional< int64_t > miniscript::internal::ParseScriptNumber | ( | const Opcode & | in | ) |
Determine whether the passed pair (created by DecomposeScript) is pushing a number.
Definition at line 387 of file miniscript.cpp.
A helper sanitizer/checker for the output of CalcType.
Definition at line 15 of file miniscript.cpp.
|
static |
The empty stack.
Definition at line 287 of file miniscript.h.
|
static |
A stack representing the lack of any (dis)satisfactions.
Definition at line 289 of file miniscript.h.
|
static |
A stack consisting of a single 0x01 element (interpreted as 1 by the script interpreted in numeric context).
Definition at line 285 of file miniscript.h.
|
static |
A stack consisting of a single zero-length element (interpreted as 0 by the script interpreter in numeric context).
Definition at line 281 of file miniscript.h.
|
static |
A stack consisting of a single malleable 32-byte 0x0000...0000 element (for dissatisfying hash challenges).
Definition at line 283 of file miniscript.h.