Bitcoin Core  27.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 
19 class CPubKey;
20 template <typename C> class Span;
21 
22 enum class TxoutType {
24  // 'standard' transaction types:
25  PUBKEY,
26  PUBKEYHASH,
27  SCRIPTHASH,
28  MULTISIG,
29  NULL_DATA,
34 };
35 
37 std::string GetTxnOutputType(TxoutType t);
38 
39 constexpr bool IsPushdataOp(opcodetype opcode)
40 {
41  return opcode > OP_FALSE && opcode <= OP_PUSHDATA4;
42 }
43 
54 TxoutType Solver(const CScript& scriptPubKey, std::vector<std::vector<unsigned char>>& vSolutionsRet);
55 
58 
61 std::optional<std::pair<int, std::vector<Span<const unsigned char>>>> MatchMultiA(const CScript& script LIFETIMEBOUND);
62 
64 CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys);
65 
66 #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:414
A Span is an object that can refer to a contiguous sequence of objects.
Definition: span.h:98
opcodetype
Script opcodes.
Definition: script.h:73
@ OP_PUSHDATA4
Definition: script.h:79
@ OP_FALSE
Definition: script.h:76
constexpr bool IsPushdataOp(opcodetype opcode)
Definition: solver.h:39
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:140
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
Definition: solver.cpp:214
CScript GetScriptForRawPubKey(const CPubKey &pubkey)
Generate a P2PK script for the given pubkey.
Definition: solver.cpp:209
std::optional< std::pair< int, std::vector< Span< const unsigned char > > > > MatchMultiA(const CScript &script LIFETIMEBOUND)
Determine if script is a "multi_a" script.
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.
@ WITNESS_V0_SCRIPTHASH
@ NULL_DATA
unspendable OP_RETURN script that carries data
@ WITNESS_V0_KEYHASH