diff options
| author | Pieter Wuille <[email protected]> | 2014-09-11 19:15:29 +0200 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2014-09-16 19:14:32 +0200 |
| commit | 0be990ba34110184c8a5a2c04094311dab5cd84c (patch) | |
| tree | 2eb24931c396ae0dc0c57fee42f345c581bd58c6 /src/script/standard.cpp | |
| parent | Merge pull request #4928 (diff) | |
| download | discoin-0be990ba34110184c8a5a2c04094311dab5cd84c.tar.xz discoin-0be990ba34110184c8a5a2c04094311dab5cd84c.zip | |
Move CTxDestination from script/script to script/standard
Diffstat (limited to 'src/script/standard.cpp')
| -rw-r--r-- | src/script/standard.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/script/standard.cpp b/src/script/standard.cpp index bda4b8b0a..407baf621 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -252,3 +252,50 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto return true; } + +namespace +{ +class CScriptVisitor : public boost::static_visitor<bool> +{ +private: + CScript *script; +public: + CScriptVisitor(CScript *scriptin) { script = scriptin; } + + bool operator()(const CNoDestination &dest) const { + script->clear(); + return false; + } + + bool operator()(const CKeyID &keyID) const { + script->clear(); + *script << OP_DUP << OP_HASH160 << keyID << OP_EQUALVERIFY << OP_CHECKSIG; + return true; + } + + bool operator()(const CScriptID &scriptID) const { + script->clear(); + *script << OP_HASH160 << scriptID << OP_EQUAL; + return true; + } +}; +} + +CScript GetScriptForDestination(const CTxDestination& dest) +{ + CScript script; + + boost::apply_visitor(CScriptVisitor(&script), dest); + return script; +} + +CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys) +{ + CScript script; + + script << CScript::EncodeOP_N(nRequired); + BOOST_FOREACH(const CPubKey& key, keys) + script << key; + script << CScript::EncodeOP_N(keys.size()) << OP_CHECKMULTISIG; + return script; +} |