14 typedef std::vector<unsigned char>
valtype;
80 pubkeyhash =
valtype(script.begin () + 3, script.begin() + 23);
102 pubkeys.emplace_back(std::move(data));
106 if (pubkeys.size() != keys || keys < required)
return false;
107 return (it + 1 == script.
end());
112 vSolutionsRet.clear();
118 std::vector<unsigned char> hashBytes(scriptPubKey.
begin()+2, scriptPubKey.
begin()+22);
119 vSolutionsRet.push_back(hashBytes);
124 std::vector<unsigned char> witnessprogram;
127 vSolutionsRet.push_back(witnessprogram);
131 vSolutionsRet.push_back(witnessprogram);
135 vSolutionsRet.push_back(std::vector<unsigned char>{(
unsigned char)witnessversion});
136 vSolutionsRet.push_back(std::move(witnessprogram));
139 if (witnessversion != 0) {
140 vSolutionsRet.push_back(std::vector<unsigned char>{(
unsigned char)witnessversion});
141 vSolutionsRet.push_back(std::move(witnessprogram));
156 std::vector<unsigned char>
data;
158 vSolutionsRet.push_back(std::move(data));
163 vSolutionsRet.push_back(std::move(data));
167 unsigned int required;
168 std::vector<std::vector<unsigned char>> keys;
170 vSolutionsRet.push_back({
static_cast<unsigned char>(required)});
171 vSolutionsRet.insert(vSolutionsRet.end(), keys.begin(), keys.end());
172 vSolutionsRet.push_back({
static_cast<unsigned char>(keys.size())});
176 vSolutionsRet.clear();
182 std::vector<valtype> vSolutions;
190 addressRet =
PKHash(pubKey);
204 std::copy(vSolutions[0].
begin(), vSolutions[0].
end(), hash.
begin());
209 std::copy(vSolutions[0].
begin(), vSolutions[0].
end(), hash.
begin());
214 unk.
version = vSolutions[0][0];
216 unk.
length = vSolutions[1].size();
227 std::vector<valtype> vSolutions;
228 typeRet =
Solver(scriptPubKey, vSolutions);
238 nRequiredRet = vSolutions.front()[0];
239 for (
unsigned int i = 1; i < vSolutions.size()-1; i++)
246 addressRet.push_back(address);
249 if (addressRet.empty())
258 addressRet.push_back(address);
302 return std::visit(CScriptVisitor(), dest);
315 for (
const CPubKey& key : keys)
322 return dest.index() != 0;
CSHA256 & Write(const unsigned char *data, size_t len)
static constexpr unsigned int SIZE
secp256k1:
std::deque< CInv >::iterator it
static int DecodeOP_N(opcodetype opcode)
Encode/decode small integers:
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
unsigned char program[40]
static const unsigned int MAX_OP_RETURN_RELAY
Default setting for nMaxDatacarrierBytes.
static constexpr size_t WITNESS_V1_TAPROOT_SIZE
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const
bool IsPayToScriptHash() const
static const bool DEFAULT_ACCEPT_DATACARRIER
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
bool fAcceptDatacarrier
A data carrying output is an unspendable output containing data.
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
bool IsWitnessProgram(int &version, std::vector< unsigned char > &program) const
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
unspendable OP_RETURN script that carries data
const unsigned char * begin() const
static bool ValidSize(const std::vector< unsigned char > &vch)
opcodetype
Script opcodes.
static constexpr unsigned int COMPRESSED_SIZE
const unsigned char * end() const
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
CTxDestination subtype to encode any future Witness version.
bool IsPushOnly(const_iterator pc) const
Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical).
An encapsulated public key.
std::vector< unsigned char > valtype
static constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE
Signature hash sizes.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
static bool MatchPayToPubkeyHash(const CScript &script, valtype &pubkeyhash)
uint160 Hash160(const T1 &in1)
Compute the 160-bit hash an object.
static opcodetype EncodeOP_N(int n)
bool ExtractDestinations(const CScript &scriptPubKey, TxoutType &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
Parse a standard scriptPubKey with one or more destination addresses.
Serialized script, used inside transaction inputs and outputs.
static constexpr size_t WITNESS_V0_KEYHASH_SIZE
static bool MatchPayToPubkey(const CScript &script, valtype &pubkey)
A reference to a CKey: the Hash160 of its serialized public key.
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
Only for Witness versions not already defined above.
std::vector< unsigned char > valtype
A reference to a CScript: the Hash160 of its serialization (see script.h)
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
A hasher class for SHA-256.
static bool MatchMultisig(const CScript &script, unsigned int &required, std::vector< valtype > &pubkeys)
unsigned nMaxDatacarrierBytes
Maximum size of TxoutType::NULL_DATA scripts that this node considers standard.
CKeyID ToKeyID(const PKHash &key_hash)
std::vector< unsigned char > ToByteVector(const T &in)
static constexpr bool IsSmallInteger(opcodetype opcode)
Test for "small positive integer" script opcodes - OP_1 through OP_16.