16typedef std::vector<unsigned char>
valtype;
81 if (count < min || count > max)
return {};
93 if (!
script.GetOp(it, opcode,
data))
return false;
95 if (!req_sigs)
return false;
96 required_sigs = *req_sigs;
98 pubkeys.emplace_back(std::move(
data));
101 if (!num_keys)
return false;
102 if (pubkeys.size() !=
static_cast<unsigned long>(*num_keys))
return false;
104 return (it + 1 ==
script.end());
109 std::vector<Span<const unsigned char>> keyspans;
116 while (
script.end() - it >= 34) {
117 if (*it != 32)
return {};
119 keyspans.emplace_back(&*it, 32);
128 std::vector<unsigned char>
data;
129 if (!
script.GetOp(it, opcode,
data))
return {};
130 if (it ==
script.end())
return {};
133 if (it !=
script.end())
return {};
135 if (!threshold)
return {};
138 return std::pair{*threshold, std::move(keyspans)};
143 vSolutionsRet.clear();
149 std::vector<unsigned char> hashBytes(scriptPubKey.
begin()+2, scriptPubKey.
begin()+22);
150 vSolutionsRet.push_back(hashBytes);
155 std::vector<unsigned char> witnessprogram;
158 vSolutionsRet.push_back(std::move(witnessprogram));
162 vSolutionsRet.push_back(std::move(witnessprogram));
166 vSolutionsRet.push_back(std::move(witnessprogram));
172 if (witnessversion != 0) {
173 vSolutionsRet.push_back(std::vector<unsigned char>{(
unsigned char)witnessversion});
174 vSolutionsRet.push_back(std::move(witnessprogram));
189 std::vector<unsigned char>
data;
191 vSolutionsRet.push_back(std::move(
data));
196 vSolutionsRet.push_back(std::move(
data));
201 std::vector<std::vector<unsigned char>> keys;
203 vSolutionsRet.push_back({
static_cast<unsigned char>(required)});
204 vSolutionsRet.insert(vSolutionsRet.end(), keys.begin(), keys.end());
205 vSolutionsRet.push_back({
static_cast<unsigned char>(keys.size())});
209 vSolutionsRet.clear();
223 for (
const CPubKey& key : keys)
std::vector< unsigned char > valtype
An encapsulated public key.
static constexpr unsigned int COMPRESSED_SIZE
const unsigned char * end() const
static constexpr unsigned int SIZE
secp256k1:
const unsigned char * begin() const
static bool ValidSize(const std::vector< unsigned char > &vch)
Serialized script, used inside transaction inputs and outputs.
bool IsPushOnly(const_iterator pc) const
Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical).
bool IsPayToScriptHash() const
static int DecodeOP_N(opcodetype opcode)
Encode/decode small integers:
bool IsPayToAnchor() const
bool IsWitnessProgram(int &version, std::vector< unsigned char > &program) const
static constexpr size_t WITNESS_V0_KEYHASH_SIZE
static constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE
Signature hash sizes.
static constexpr size_t WITNESS_V1_TAPROOT_SIZE
bool CheckMinimalPush(const std::vector< unsigned char > &data, opcodetype opcode)
opcodetype
Script opcodes.
static constexpr unsigned int MAX_PUBKEYS_PER_MULTI_A
The limit of keys in OP_CHECKSIGADD-based scripts.
static const int MAX_PUBKEYS_PER_MULTISIG
std::vector< unsigned char > ToByteVector(const T &in)
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char > > &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
std::optional< std::pair< int, std::vector< Span< const unsigned char > > > > MatchMultiA(const CScript &script)
static bool MatchPayToPubkeyHash(const CScript &script, valtype &pubkeyhash)
static constexpr bool IsSmallInteger(opcodetype opcode)
Test for "small positive integer" script opcodes - OP_1 through OP_16.
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
std::vector< unsigned char > valtype
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
static std::optional< int > GetScriptNumber(opcodetype opcode, valtype data, int min, int max)
Retrieve a minimally-encoded number in range [min,max] from an (opcode, data) pair,...
static bool MatchMultisig(const CScript &script, int &required_sigs, std::vector< valtype > &pubkeys)
static bool MatchPayToPubkey(const CScript &script, valtype &pubkey)
constexpr bool IsPushdataOp(opcodetype opcode)
@ WITNESS_UNKNOWN
Only for Witness versions not already defined above.
@ ANCHOR
anyone can spend script
@ NULL_DATA
unspendable OP_RETURN script that carries data