Bitcoin Core 28.99.0
P2P Digital Currency
|
Classes | |
struct | InputResult |
A pair of a satisfaction and a dissatisfaction InputStack. More... | |
struct | InputStack |
An object representing a sequence of witness stack elements. More... | |
struct | MaxInt |
Class whose objects represent the maximum of a list of integers. More... | |
struct | NoDupCheck |
struct | Ops |
struct | SatInfo |
A data structure to help the calculation of stack size limits. More... | |
struct | StackSize |
struct | WitnessSize |
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, MiniscriptContext ms_ctx) |
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, MiniscriptContext ms_ctx) |
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) |
constexpr uint32_t | MaxScriptSize (MiniscriptContext ms_ctx) |
The maximum size of a script depending on the context. More... | |
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 (const MiniscriptContext script_ctx, 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 constexpr uint32_t | MAX_TAPMINISCRIPT_STACK_ELEM_SIZE {65} |
The maximum size of a witness item for a Miniscript under Tapscript context. (A BIP340 signature with a sighash type byte.) More... | |
constexpr uint32_t | TX_OVERHEAD {4 + 4} |
version + nLockTime More... | |
constexpr uint32_t | TXIN_BYTES_NO_WITNESS {36 + 4 + 1} |
prevout + nSequence + scriptSig More... | |
constexpr uint32_t | P2WSH_TXOUT_BYTES {8 + 1 + 1 + 33} |
nValue + script len + OP_0 + pushdata 32. More... | |
constexpr uint32_t | TX_BODY_LEEWAY_WEIGHT {(TX_OVERHEAD + GetSizeOfCompactSize(1) + TXIN_BYTES_NO_WITNESS + GetSizeOfCompactSize(1) + P2WSH_TXOUT_BYTES) * WITNESS_SCALE_FACTOR + 2} |
Data other than the witness in a transaction. Overhead + vin count + one vin + vout count + one vout + segwit marker. More... | |
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} |
Maximum possible stack size to spend a Taproot output (excluding the script itself). More... | |
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 2158 of file miniscript.h.
|
strong |
Definition at line 1670 of file miniscript.h.
void miniscript::internal::BuildBack | ( | const MiniscriptContext | script_ctx, |
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 1753 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, | ||
MiniscriptContext | ms_ctx | ||
) |
Helper function for Node::CalcScriptLen.
Definition at line 265 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, | ||
MiniscriptContext | ms_ctx | ||
) |
Helper function for Node::CalcType.
Definition at line 39 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 2228 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, OP_NUMEQUALVERIFY and OP_EQUALVERIFY are decomposed into OP_CHECKSIG, OP_CHECKMULTISIG, OP_EQUAL and OP_NUMEQUAL respectively, plus OP_VERIFY.
Definition at line 369 of file miniscript.cpp.
int miniscript::internal::FindNextChar | ( | Span< const char > | sp, |
const char | m | ||
) |
Definition at line 422 of file miniscript.cpp.
|
constexpr |
The maximum size of a script depending on the context.
Definition at line 270 of file miniscript.h.
InputStack miniscript::internal::operator+ | ( | InputStack | a, |
InputStack | b | ||
) |
Definition at line 326 of file miniscript.cpp.
InputStack miniscript::internal::operator| | ( | InputStack | a, |
InputStack | b | ||
) |
Definition at line 340 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 1770 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 1739 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 1728 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 409 of file miniscript.cpp.
A helper sanitizer/checker for the output of CalcType.
Definition at line 19 of file miniscript.cpp.
|
static |
The empty stack.
Definition at line 337 of file miniscript.h.
|
static |
A stack representing the lack of any (dis)satisfactions.
Definition at line 339 of file miniscript.h.
|
staticconstexpr |
The maximum size of a witness item for a Miniscript under Tapscript context. (A BIP340 signature with a sighash type byte.)
Definition at line 257 of file miniscript.h.
|
constexpr |
Maximum possible stack size to spend a Taproot output (excluding the script itself).
Definition at line 268 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 335 of file miniscript.h.
|
constexpr |
nValue + script len + OP_0 + pushdata 32.
Definition at line 264 of file miniscript.h.
|
constexpr |
Data other than the witness in a transaction. Overhead + vin count + one vin + vout count + one vout + segwit marker.
Definition at line 266 of file miniscript.h.
|
constexpr |
version + nLockTime
Definition at line 260 of file miniscript.h.
|
constexpr |
prevout + nSequence + scriptSig
Definition at line 262 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 331 of file miniscript.h.
|
static |
A stack consisting of a single malleable 32-byte 0x0000...0000 element (for dissatisfying hash challenges).
Definition at line 333 of file miniscript.h.