9 #include <validation.h> 17 typedef std::vector<unsigned char>
valtype;
50 static std::multimap<txnouttype, CScript> mTemplates;
51 if (mTemplates.empty())
63 vSolutionsRet.clear();
70 std::vector<unsigned char> hashBytes(scriptPubKey.
begin()+2, scriptPubKey.
begin()+22);
71 vSolutionsRet.push_back(hashBytes);
76 bool fIsOwner =
false;
79 std::vector<unsigned char> hashBytes(scriptPubKey.
begin()+3, scriptPubKey.
begin()+23);
80 vSolutionsRet.push_back(hashBytes);
86 std::vector<unsigned char> witnessprogram;
88 if (witnessversion == 0 && witnessprogram.size() == 20) {
90 vSolutionsRet.push_back(witnessprogram);
93 if (witnessversion == 0 && witnessprogram.size() == 32) {
95 vSolutionsRet.push_back(witnessprogram);
119 std::vector<unsigned char> hashBytes(scriptPubKey.
begin() + 2, scriptPubKey.
begin() + 22);
120 vSolutionsRet.push_back(hashBytes);
126 const CScript& script1 = scriptPubKey;
127 for (
const std::pair<txnouttype, CScript>& tplate : mTemplates)
129 const CScript& script2 = tplate.second;
130 vSolutionsRet.
clear();
133 std::vector<unsigned char> vch1, vch2;
140 if (pc1 == script1.
end() && pc2 == script2.
end())
143 typeRet = tplate.first;
147 unsigned char m = vSolutionsRet.front()[0];
148 unsigned char n = vSolutionsRet.back()[0];
149 if (m < 1 || n < 1 || m > n || vSolutionsRet.size()-2 != n)
154 if (!script1.
GetOp(pc1, opcode1, vch1))
156 if (!script2.
GetOp(pc2, opcode2, vch2))
162 while (vch1.size() >= 33 && vch1.size() <= 65)
164 vSolutionsRet.push_back(vch1);
165 if (!script1.
GetOp(pc1, opcode1, vch1))
168 if (!script2.
GetOp(pc2, opcode2, vch2))
176 if (vch1.size() < 33 || vch1.size() > 65)
178 vSolutionsRet.push_back(vch1);
182 if (vch1.size() !=
sizeof(
uint160))
184 vSolutionsRet.push_back(vch1);
188 if (opcode1 ==
OP_0 ||
192 vSolutionsRet.push_back(
valtype(1, n));
197 else if (opcode1 != opcode2 || vch1 != vch2)
205 vSolutionsRet.clear();
212 std::vector<valtype> vSolutions;
214 if (!
Solver(scriptPubKey, whichType, vSolutions)) {
224 addressRet = pubKey.
GetID();
241 if (vSolutions.size()) {
255 std::vector<valtype> vSolutions;
256 if (!
Solver(scriptPubKey, typeRet, vSolutions))
265 nRequiredRet = vSolutions.front()[0];
266 for (
unsigned int i = 1; i < vSolutions.size()-1; i++)
273 addressRet.push_back(address);
276 if (addressRet.empty())
285 addressRet.push_back(address);
293 class CScriptVisitor :
public boost::static_visitor<bool>
298 explicit CScriptVisitor(
CScript *scriptin) { script = scriptin; }
305 bool operator()(
const CKeyID &keyID)
const {
311 bool operator()(
const CScriptID &scriptID)
const {
321 class CNullAssetScriptVisitor :
public boost::static_visitor<bool>
326 explicit CNullAssetScriptVisitor(
CScript *scriptin) { script = scriptin; }
333 bool operator()(
const CKeyID &keyID)
const {
339 bool operator()(
const CScriptID &scriptID)
const {
351 boost::apply_visitor(CScriptVisitor(&script), dest);
359 boost::apply_visitor(CNullAssetScriptVisitor(&script), dest);
373 for (
const CPubKey& key : keys)
384 std::vector<std::vector<unsigned char> > vSolutions;
385 if (
Solver(redeemscript, typ, vSolutions)) {
387 unsigned char h160[20];
389 ret << OP_0 << std::vector<unsigned char>(&h160[0], &h160[20]);
392 ret <<
OP_0 << vSolutions[0];
403 return dest.which() != 0;
CSHA256 & Write(const unsigned char *data, size_t len)
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
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.
unspendable OP_RETURN script that carries data
bool IsPayToScriptHash() const
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
uint160 Hash160(const T1 pbegin, const T1 pend)
Compute the 160-bit hash an object.
#define ASSET_TRANSFER_STRING
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
const unsigned char * begin() const
bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
Parse a standard scriptPubKey with one or more destination addresses.
opcodetype
Script opcodes.
const unsigned char * end() const
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
CHash160 & Write(const unsigned char *data, size_t len)
const char * GetTxnOutputType(txnouttype t)
Get the name of a txnouttype as a C string, or nullptr if unknown.
unsigned int size() const
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Raven scriptPubKey for the given CTxDestination.
bool Solver(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< std::vector< unsigned char > > &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
static opcodetype EncodeOP_N(int n)
Serialized script, used inside transaction inputs and outputs.
void Finalize(unsigned char hash[OUTPUT_SIZE])
A reference to a CKey: the Hash160 of its serialized public key.
#define ASSET_REISSUE_STRING
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.
bool GetOp(iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet)
A hasher class for Raven's 160-bit hash (SHA-256 + RIPEMD-160).
A hasher class for SHA-256.
CScript GetScriptForWitness(const CScript &redeemscript)
Generate a pay-to-witness script for the given redeem script.
unsigned nMaxDatacarrierBytes
Maximum size of TX_NULL_DATA scripts that this node considers standard.
unspendable OP_RAVEN_ASSET script that carries data
CScript GetScriptForNullAssetDataDestination(const CTxDestination &dest)
Generate a script that contains an address used for qualifier, and restricted assets data transaction...
std::vector< unsigned char > ToByteVector(const T &in)
bool IsAssetScript(int &nType, bool &fIsOwner, int &nStartingIndex) const