mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
miniscript: add an OpCode typedef for readability
Suggested-by: Vincenzo Palazzo
This commit is contained in:
parent
7a549c6c59
commit
8323e4249d
2 changed files with 7 additions and 5 deletions
|
@ -281,9 +281,9 @@ size_t ComputeScriptLen(Fragment fragment, Type sub0typ, size_t subsize, uint32_
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::optional<std::vector<std::pair<opcodetype, std::vector<unsigned char>>>> DecomposeScript(const CScript& script)
|
||||
std::optional<std::vector<Opcode>> DecomposeScript(const CScript& script)
|
||||
{
|
||||
std::vector<std::pair<opcodetype, std::vector<unsigned char>>> out;
|
||||
std::vector<Opcode> out;
|
||||
CScript::const_iterator it = script.begin(), itend = script.end();
|
||||
while (it != itend) {
|
||||
std::vector<unsigned char> push_data;
|
||||
|
@ -317,7 +317,7 @@ std::optional<std::vector<std::pair<opcodetype, std::vector<unsigned char>>>> De
|
|||
return out;
|
||||
}
|
||||
|
||||
std::optional<int64_t> ParseScriptNumber(const std::pair<opcodetype, std::vector<unsigned char>>& in) {
|
||||
std::optional<int64_t> ParseScriptNumber(const Opcode& in) {
|
||||
if (in.first == OP_0) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -180,6 +180,8 @@ inline constexpr Type operator"" _mst(const char* c, size_t l) {
|
|||
return typ;
|
||||
}
|
||||
|
||||
using Opcode = std::pair<opcodetype, std::vector<unsigned char>>;
|
||||
|
||||
template<typename Key> struct Node;
|
||||
template<typename Key> using NodeRef = std::shared_ptr<const Node<Key>>;
|
||||
|
||||
|
@ -1269,10 +1271,10 @@ inline NodeRef<Key> Parse(Span<const char> in, const Ctx& ctx)
|
|||
* and OP_EQUALVERIFY are decomposed into OP_CHECKSIG, OP_CHECKMULTISIG, OP_EQUAL
|
||||
* respectively, plus OP_VERIFY.
|
||||
*/
|
||||
std::optional<std::vector<std::pair<opcodetype, std::vector<unsigned char>>>> DecomposeScript(const CScript& script);
|
||||
std::optional<std::vector<Opcode>> DecomposeScript(const CScript& script);
|
||||
|
||||
/** Determine whether the passed pair (created by DecomposeScript) is pushing a number. */
|
||||
std::optional<int64_t> ParseScriptNumber(const std::pair<opcodetype, std::vector<unsigned char>>& in);
|
||||
std::optional<int64_t> ParseScriptNumber(const Opcode& in);
|
||||
|
||||
enum class DecodeContext {
|
||||
/** A single expression of type B, K, or V. Specifically, this can't be an
|
||||
|
|
Loading…
Add table
Reference in a new issue