mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
merge #18863: Make CScriptVisitor stateless
This commit is contained in:
parent
dfea329f69
commit
c60491eef1
@ -202,38 +202,32 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::
|
||||
|
||||
namespace
|
||||
{
|
||||
class CScriptVisitor : public boost::static_visitor<bool>
|
||||
class CScriptVisitor : public boost::static_visitor<CScript>
|
||||
{
|
||||
private:
|
||||
CScript *script;
|
||||
public:
|
||||
explicit CScriptVisitor(CScript *scriptin) { script = scriptin; }
|
||||
|
||||
bool operator()(const CNoDestination &dest) const {
|
||||
script->clear();
|
||||
return false;
|
||||
CScript operator()(const CNoDestination& dest) const
|
||||
{
|
||||
return CScript();
|
||||
}
|
||||
|
||||
bool operator()(const CKeyID &keyID) const {
|
||||
script->clear();
|
||||
*script << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||
return true;
|
||||
CScript operator()(const CKeyID& keyID) const
|
||||
{
|
||||
return CScript() << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||
}
|
||||
|
||||
bool operator()(const CScriptID &scriptID) const {
|
||||
script->clear();
|
||||
*script << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL;
|
||||
return true;
|
||||
CScript operator()(const CScriptID& scriptID) const
|
||||
{
|
||||
return CScript() << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL;
|
||||
}
|
||||
};
|
||||
|
||||
const CScriptVisitor g_script_visitor;
|
||||
|
||||
} // namespace
|
||||
|
||||
CScript GetScriptForDestination(const CTxDestination& dest)
|
||||
{
|
||||
CScript script;
|
||||
|
||||
boost::apply_visitor(CScriptVisitor(&script), dest);
|
||||
return script;
|
||||
return boost::apply_visitor(::g_script_visitor, dest);
|
||||
}
|
||||
|
||||
CScript GetScriptForRawPubKey(const CPubKey& pubKey)
|
||||
|
Loading…
Reference in New Issue
Block a user