Changeset View
Changeset View
Standalone View
Standalone View
src/script/standard.cpp
Show First 20 Lines • Show All 219 Lines • ▼ Show 20 Lines | if (typeRet == TxoutType::MULTISIG) { | ||||
} | } | ||||
addressRet.push_back(address); | addressRet.push_back(address); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
namespace { | namespace { | ||||
class CScriptVisitor : public boost::static_visitor<bool> { | class CScriptVisitor : public boost::static_visitor<CScript> { | ||||
private: | |||||
CScript *script; | |||||
public: | public: | ||||
explicit CScriptVisitor(CScript *scriptin) { script = scriptin; } | CScript operator()(const CNoDestination &dest) const { return CScript(); } | ||||
bool operator()(const CNoDestination &dest) const { | |||||
script->clear(); | |||||
return false; | |||||
} | |||||
bool operator()(const PKHash &keyID) const { | CScript operator()(const PKHash &keyID) const { | ||||
script->clear(); | return CScript() << OP_DUP << OP_HASH160 << ToByteVector(keyID) | ||||
*script << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY | << OP_EQUALVERIFY << OP_CHECKSIG; | ||||
<< OP_CHECKSIG; | |||||
return true; | |||||
} | } | ||||
bool operator()(const ScriptHash &scriptID) const { | CScript operator()(const ScriptHash &scriptID) const { | ||||
script->clear(); | return CScript() << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL; | ||||
*script << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL; | |||||
return true; | |||||
} | } | ||||
}; | }; | ||||
const CScriptVisitor g_script_visitor; | |||||
} // namespace | } // namespace | ||||
CScript GetScriptForDestination(const CTxDestination &dest) { | CScript GetScriptForDestination(const CTxDestination &dest) { | ||||
CScript script; | return boost::apply_visitor(::g_script_visitor, dest); | ||||
boost::apply_visitor(CScriptVisitor(&script), dest); | |||||
return script; | |||||
} | } | ||||
CScript GetScriptForRawPubKey(const CPubKey &pubKey) { | CScript GetScriptForRawPubKey(const CPubKey &pubKey) { | ||||
return CScript() << std::vector<uint8_t>(pubKey.begin(), pubKey.end()) | return CScript() << std::vector<uint8_t>(pubKey.begin(), pubKey.end()) | ||||
<< OP_CHECKSIG; | << OP_CHECKSIG; | ||||
} | } | ||||
CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey> &keys) { | CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey> &keys) { | ||||
Show All 13 Lines |