Bitcoin Core  29.1.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 #include <span.h>
14 
15 #include <string>
16 #include <optional>
17 #include <utility>
18 #include <vector>
19 
20 class CPubKey;
21 
22 enum class TxoutType {
24  // 'standard' transaction types:
25  ANCHOR,
26  PUBKEY,
27  PUBKEYHASH,
28  SCRIPTHASH,
29  MULTISIG,
30  NULL_DATA,
35 };
36 
38 std::string GetTxnOutputType(TxoutType t);
39 
40 constexpr bool IsPushdataOp(opcodetype opcode)
41 {
42  return opcode > OP_FALSE && opcode <= OP_PUSHDATA4;
43 }
44 
55 TxoutType Solver(const CScript& scriptPubKey, std::vector<std::vector<unsigned char>>& vSolutionsRet);
56 
59 
62 std::optional<std::pair<int, std::vector<Span<const unsigned char>>>> MatchMultiA(const CScript& script LIFETIMEBOUND);
63 
65 CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys);
66 
67 #endif // BITCOIN_SCRIPT_SOLVER_H
constexpr bool IsPushdataOp(opcodetype opcode)
Definition: solver.h:40
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
Definition: solver.cpp:18
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
anyone can spend script
std::optional< std::pair< int, std::vector< Span< const unsigned char > > > > MatchMultiA(const CScript &script LIFETIMEBOUND)
Determine if script is a "multi_a" script.
#define LIFETIMEBOUND
Definition: attributes.h:16
An encapsulated public key.
Definition: pubkey.h:33
opcodetype
Script opcodes.
Definition: script.h:73
TxoutType
Definition: solver.h:22
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
Definition: solver.cpp:218
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:414
CScript GetScriptForRawPubKey(const CPubKey &pubkey)
Generate a P2PK script for the given pubkey.
Definition: solver.cpp:213
Only for Witness versions not already defined above.
unspendable OP_RETURN script that carries data