16 typedef std::vector<unsigned char>
valtype;
80 if (count < min || count > max)
return {};
92 if (!script.
GetOp(it, opcode, data))
return false;
94 if (!req_sigs)
return false;
95 required_sigs = *req_sigs;
97 pubkeys.emplace_back(std::move(data));
100 if (!num_keys)
return false;
101 if (pubkeys.size() !=
static_cast<unsigned long>(*num_keys))
return false;
103 return (it + 1 == script.
end());
106 std::optional<std::pair<int, std::vector<Span<const unsigned char>>>>
MatchMultiA(
const CScript& script)
108 std::vector<Span<const unsigned char>> keyspans;
114 auto it = script.
begin();
115 while (script.
end() - it >= 34) {
116 if (*it != 32)
return {};
118 keyspans.emplace_back(&*it, 32);
127 std::vector<unsigned char> data;
128 if (!script.
GetOp(it, opcode, data))
return {};
129 if (it == script.
end())
return {};
132 if (it != script.
end())
return {};
133 auto threshold =
GetScriptNumber(opcode, data, 1, (
int)keyspans.size());
134 if (!threshold)
return {};
137 return std::pair{*threshold, std::move(keyspans)};
142 vSolutionsRet.clear();
148 std::vector<unsigned char> hashBytes(scriptPubKey.
begin()+2, scriptPubKey.
begin()+22);
149 vSolutionsRet.push_back(hashBytes);
154 std::vector<unsigned char> witnessprogram;
157 vSolutionsRet.push_back(std::move(witnessprogram));
161 vSolutionsRet.push_back(std::move(witnessprogram));
165 vSolutionsRet.push_back(std::move(witnessprogram));
168 if (witnessversion != 0) {
169 vSolutionsRet.push_back(std::vector<unsigned char>{(
unsigned char)witnessversion});
170 vSolutionsRet.push_back(std::move(witnessprogram));
185 std::vector<unsigned char> data;
187 vSolutionsRet.push_back(std::move(data));
192 vSolutionsRet.push_back(std::move(data));
197 std::vector<std::vector<unsigned char>> keys;
199 vSolutionsRet.push_back({
static_cast<unsigned char>(required)});
200 vSolutionsRet.insert(vSolutionsRet.end(), keys.begin(), keys.end());
201 vSolutionsRet.push_back({
static_cast<unsigned char>(keys.size())});
205 vSolutionsRet.clear();
219 for (
const CPubKey& key : keys)
std::vector< unsigned char > valtype
An encapsulated public key.
const unsigned char * end() const
static constexpr unsigned int COMPRESSED_SIZE
static constexpr unsigned int SIZE
secp256k1:
static bool ValidSize(const std::vector< unsigned char > &vch)
const unsigned char * begin() const
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 GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) 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)
std::vector< unsigned char > ToByteVector(const T &in)
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
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,...
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 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.
@ NULL_DATA
unspendable OP_RETURN script that carries data