![]() |
Bitcoin Core
24.1.0
P2P Digital Currency
|
A node in a miniscript expression. More...
#include <miniscript.h>
Public Member Functions | |
| template<typename Ctx > | |
| CScript | ToScript (const Ctx &ctx) const |
| template<typename CTx > | |
| std::optional< std::string > | ToString (const CTx &ctx) const |
| template<typename Ctx > | |
| void | DuplicateKeyCheck (const Ctx &ctx) const |
| Update duplicate key information in this Node. More... | |
| size_t | ScriptSize () const |
| Return the size of the script for this expression (faster than ToScript().size()). More... | |
| uint32_t | GetOps () const |
| Return the maximum number of ops needed to satisfy this script non-malleably. More... | |
| bool | CheckOpsLimit () const |
| Check the ops limit of this script against the consensus limit. More... | |
| uint32_t | GetStackSize () const |
| Return the maximum number of stack elements needed to satisfy this script non-malleably, including the script push. More... | |
| bool | CheckStackSize () const |
| Check the maximum stack size for this script against the policy limit. More... | |
| Type | GetType () const |
| Return the expression type. More... | |
| const Node * | FindInsaneSub () const |
| Find an insane subnode which has no insane children. Nullptr if there is none. More... | |
| bool | IsValid () const |
| Check whether this node is valid at all. More... | |
| bool | IsValidTopLevel () const |
| Check whether this node is valid as a script on its own. More... | |
| bool | IsNonMalleable () const |
| Check whether this script can always be satisfied in a non-malleable way. More... | |
| bool | NeedsSignature () const |
| Check whether this script always needs a signature. More... | |
| bool | CheckTimeLocksMix () const |
| Check whether there is no satisfaction path that contains both timelocks and heightlocks. More... | |
| bool | CheckDuplicateKey () const |
| Check whether there is no duplicate key across this fragment and all its sub-fragments. More... | |
| bool | ValidSatisfactions () const |
| Whether successful non-malleable satisfactions are guaranteed to be valid. More... | |
| bool | IsSaneSubexpression () const |
| Whether the apparent policy of this node matches its script semantics. Doesn't guarantee it is a safe script on its own. More... | |
| bool | IsSane () const |
| Check whether this node is safe as a script on its own. More... | |
| bool | operator== (const Node< Key > &arg) const |
| Equality testing. More... | |
| Node (internal::NoDupCheck, Fragment nt, std::vector< NodeRef< Key >> sub, std::vector< unsigned char > arg, uint32_t val=0) | |
| Node (internal::NoDupCheck, Fragment nt, std::vector< unsigned char > arg, uint32_t val=0) | |
| Node (internal::NoDupCheck, Fragment nt, std::vector< NodeRef< Key >> sub, std::vector< Key > key, uint32_t val=0) | |
| Node (internal::NoDupCheck, Fragment nt, std::vector< Key > key, uint32_t val=0) | |
| Node (internal::NoDupCheck, Fragment nt, std::vector< NodeRef< Key >> sub, uint32_t val=0) | |
| Node (internal::NoDupCheck, Fragment nt, uint32_t val=0) | |
| template<typename Ctx > | |
| Node (const Ctx &ctx, Fragment nt, std::vector< NodeRef< Key >> sub, std::vector< unsigned char > arg, uint32_t val=0) | |
| template<typename Ctx > | |
| Node (const Ctx &ctx, Fragment nt, std::vector< unsigned char > arg, uint32_t val=0) | |
| template<typename Ctx > | |
| Node (const Ctx &ctx, Fragment nt, std::vector< NodeRef< Key >> sub, std::vector< Key > key, uint32_t val=0) | |
| template<typename Ctx > | |
| Node (const Ctx &ctx, Fragment nt, std::vector< Key > key, uint32_t val=0) | |
| template<typename Ctx > | |
| Node (const Ctx &ctx, Fragment nt, std::vector< NodeRef< Key >> sub, uint32_t val=0) | |
| template<typename Ctx > | |
| Node (const Ctx &ctx, Fragment nt, uint32_t val=0) | |
Public Attributes | |
| const Fragment | fragment |
| What node type this node is. More... | |
| const uint32_t | k = 0 |
| The k parameter (time for OLDER/AFTER, threshold for THRESH(_M)) More... | |
| const std::vector< Key > | keys |
| The keys used by this expression (only for PK_K/PK_H/MULTI) More... | |
| const std::vector< unsigned char > | data |
| The data bytes in this expression (only for HASH160/HASH256/SHA256/RIPEMD10). More... | |
| const std::vector< NodeRef< Key > > | subs |
| Subexpressions (for WRAP_*/AND_*/OR_*/ANDOR/THRESH) More... | |
Private Member Functions | |
| size_t | CalcScriptLen () const |
| Compute the length of the script for this miniscript (including children). More... | |
| template<typename Result , typename State , typename DownFn , typename UpFn > | |
| std::optional< Result > | TreeEvalMaybe (State root_state, DownFn downfn, UpFn upfn) const |
| template<typename Result , typename UpFn > | |
| std::optional< Result > | TreeEvalMaybe (UpFn upfn) const |
| Like TreeEvalMaybe, but without downfn or State type. More... | |
| template<typename Result , typename State , typename DownFn , typename UpFn > | |
| Result | TreeEval (State root_state, DownFn &&downfn, UpFn upfn) const |
| Like TreeEvalMaybe, but always produces a result. More... | |
| template<typename Result , typename UpFn > | |
| Result | TreeEval (UpFn upfn) const |
| Like TreeEval, but without downfn or State type. More... | |
| Type | CalcType () const |
| Compute the type for this miniscript. More... | |
| internal::Ops | CalcOps () const |
| internal::StackSize | CalcStackSize () const |
Private Attributes | |
| const internal::Ops | ops |
| Cached ops counts. More... | |
| const internal::StackSize | ss |
| Cached stack size bounds. More... | |
| const Type | typ |
| Cached expression type (computed by CalcType and fed through SanitizeType). More... | |
| const size_t | scriptlen |
| Cached script length (computed by CalcScriptLen). More... | |
| std::optional< bool > | has_duplicate_keys |
| Whether a public key appears more than once in this node. More... | |
Friends | |
| int | Compare (const Node< Key > &node1, const Node< Key > &node2) |
| Compare two miniscript subtrees, using a non-recursive algorithm. More... | |
A node in a miniscript expression.
Definition at line 185 of file miniscript.h.
|
inline |
Definition at line 911 of file miniscript.h.
|
inline |
Definition at line 912 of file miniscript.h.
|
inline |
Definition at line 913 of file miniscript.h.
|
inline |
Definition at line 914 of file miniscript.h.
|
inline |
Definition at line 915 of file miniscript.h.
|
inline |
Definition at line 916 of file miniscript.h.
|
inline |
Definition at line 919 of file miniscript.h.
|
inline |
Definition at line 920 of file miniscript.h.
|
inline |
Definition at line 921 of file miniscript.h.
|
inline |
Definition at line 922 of file miniscript.h.
|
inline |
Definition at line 923 of file miniscript.h.
|
inline |
Definition at line 924 of file miniscript.h.
|
inlineprivate |
|
inlineprivate |
Compute the length of the script for this miniscript (including children).
Definition at line 315 of file miniscript.h.
|
inlineprivate |
|
inlineprivate |
Compute the type for this miniscript.
Definition at line 475 of file miniscript.h.
|
inline |
Check whether there is no duplicate key across this fragment and all its sub-fragments.
Definition at line 896 of file miniscript.h.
|
inline |
Check the ops limit of this script against the consensus limit.
Definition at line 859 of file miniscript.h.
|
inline |
Check the maximum stack size for this script against the policy limit.
Definition at line 866 of file miniscript.h.
|
inline |
Check whether there is no satisfaction path that contains both timelocks and heightlocks.
Definition at line 893 of file miniscript.h.
|
inline |
Update duplicate key information in this Node.
This uses a custom key comparator provided by the context in order to still detect duplicates for more complicated types.
Definition at line 794 of file miniscript.h.
|
inline |
Find an insane subnode which has no insane children. Nullptr if there is none.
Definition at line 872 of file miniscript.h.
|
inline |
Return the maximum number of ops needed to satisfy this script non-malleably.
Definition at line 856 of file miniscript.h.
|
inline |
Return the maximum number of stack elements needed to satisfy this script non-malleably, including the script push.
Definition at line 863 of file miniscript.h.
|
inline |
Return the expression type.
Definition at line 869 of file miniscript.h.
|
inline |
Check whether this script can always be satisfied in a non-malleable way.
Definition at line 887 of file miniscript.h.
|
inline |
Check whether this node is safe as a script on its own.
Definition at line 905 of file miniscript.h.
|
inline |
Whether the apparent policy of this node matches its script semantics. Doesn't guarantee it is a safe script on its own.
Definition at line 902 of file miniscript.h.
|
inline |
Check whether this node is valid at all.
Definition at line 881 of file miniscript.h.
|
inline |
Check whether this node is valid as a script on its own.
Definition at line 884 of file miniscript.h.
|
inline |
Check whether this script always needs a signature.
Definition at line 890 of file miniscript.h.
|
inline |
Equality testing.
Definition at line 908 of file miniscript.h.
|
inline |
Return the size of the script for this expression (faster than ToScript().size()).
Definition at line 853 of file miniscript.h.
|
inline |
|
inline |
|
inlineprivate |
Like TreeEvalMaybe, but always produces a result.
upfn must return Result.
Definition at line 426 of file miniscript.h.
|
inlineprivate |
Like TreeEval, but without downfn or State type.
upfn takes (const Node&, Span<Result>) and returns Result.
Definition at line 442 of file miniscript.h.
|
inlineprivate |
Entries of the explicit stack tracked in this algorithm.
< The node being evaluated.
< How many children of this node have been expanded.
< The state for that node.
Definition at line 348 of file miniscript.h.
|
inlineprivate |
Like TreeEvalMaybe, but without downfn or State type.
upfn takes (const Node&, Span<Result>) and returns std::optional<Result>.
Definition at line 413 of file miniscript.h.
|
inline |
Whether successful non-malleable satisfactions are guaranteed to be valid.
Definition at line 899 of file miniscript.h.
Compare two miniscript subtrees, using a non-recursive algorithm.
Definition at line 455 of file miniscript.h.
| const std::vector<unsigned char> miniscript::Node< Key >::data |
The data bytes in this expression (only for HASH160/HASH256/SHA256/RIPEMD10).
Definition at line 293 of file miniscript.h.
| const Fragment miniscript::Node< Key >::fragment |
What node type this node is.
Definition at line 287 of file miniscript.h.
|
mutableprivate |
Whether a public key appears more than once in this node.
This value is initialized by all constructors except the NoDupCheck ones. The NoDupCheck ones skip the computation, requiring it to be done manually by invoking DuplicateKeyCheck(). DuplicateKeyCheck(), or a non-NoDupCheck constructor, will compute has_duplicate_keys for all subnodes as well.
Definition at line 311 of file miniscript.h.
| const uint32_t miniscript::Node< Key >::k = 0 |
The k parameter (time for OLDER/AFTER, threshold for THRESH(_M))
Definition at line 289 of file miniscript.h.
| const std::vector<Key> miniscript::Node< Key >::keys |
The keys used by this expression (only for PK_K/PK_H/MULTI)
Definition at line 291 of file miniscript.h.
|
private |
Cached ops counts.
Definition at line 299 of file miniscript.h.
|
private |
Cached script length (computed by CalcScriptLen).
Definition at line 305 of file miniscript.h.
|
private |
Cached stack size bounds.
Definition at line 301 of file miniscript.h.
| const std::vector<NodeRef<Key> > miniscript::Node< Key >::subs |
Subexpressions (for WRAP_*/AND_*/OR_*/ANDOR/THRESH)
Definition at line 295 of file miniscript.h.
|
private |
Cached expression type (computed by CalcType and fed through SanitizeType).
Definition at line 303 of file miniscript.h.
1.8.14