Bitcoin Core 28.99.0
P2P Digital Currency
solver.h
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2022 The Bitcoin Core developers
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6// The Solver functions are used by policy and the wallet, but not consensus.
7
8#ifndef BITCOIN_SCRIPT_SOLVER_H
9#define BITCOIN_SCRIPT_SOLVER_H
10
11#include <attributes.h>
12#include <script/script.h>
13
14#include <string>
15#include <optional>
16#include <utility>
17#include <vector>
18
19class CPubKey;
20template <typename C> class Span;
21
22enum class TxoutType {
24 // 'standard' transaction types:
25 ANCHOR,
26 PUBKEY,
30 NULL_DATA,
35};
36
38std::string GetTxnOutputType(TxoutType t);
39
40constexpr bool IsPushdataOp(opcodetype opcode)
41{
42 return opcode > OP_FALSE && opcode <= OP_PUSHDATA4;
43}
44
55TxoutType Solver(const CScript& scriptPubKey, std::vector<std::vector<unsigned char>>& vSolutionsRet);
56
59
62std::optional<std::pair<int, std::vector<Span<const unsigned char>>>> MatchMultiA(const CScript& script LIFETIMEBOUND);
63
65CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys);
66
67#endif // BITCOIN_SCRIPT_SOLVER_H
#define LIFETIMEBOUND
Definition: attributes.h:16
An encapsulated public key.
Definition: pubkey.h:34
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:415
A Span is an object that can refer to a contiguous sequence of objects.
Definition: span.h:98
opcodetype
Script opcodes.
Definition: script.h:74
@ OP_PUSHDATA4
Definition: script.h:80
@ OP_FALSE
Definition: script.h:77
constexpr bool IsPushdataOp(opcodetype opcode)
Definition: solver.h:40
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char > > &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
Definition: solver.cpp:141
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
Definition: solver.cpp:218
CScript GetScriptForRawPubKey(const CPubKey &pubkey)
Generate a P2PK script for the given pubkey.
Definition: solver.cpp:213
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
Definition: solver.cpp:18
TxoutType
Definition: solver.h:22
@ WITNESS_V1_TAPROOT
@ WITNESS_UNKNOWN
Only for Witness versions not already defined above.
@ ANCHOR
anyone can spend script
@ WITNESS_V0_SCRIPTHASH
@ NULL_DATA
unspendable OP_RETURN script that carries data
@ WITNESS_V0_KEYHASH
std::optional< std::pair< int, std::vector< Span< const unsigned char > > > > MatchMultiA(const CScript &script LIFETIMEBOUND)
Determine if script is a "multi_a" script.