Changeset View
Changeset View
Standalone View
Standalone View
src/script/standard.cpp
Show All 10 Lines | |||||
typedef std::vector<uint8_t> valtype; | typedef std::vector<uint8_t> valtype; | ||||
bool fAcceptDatacarrier = DEFAULT_ACCEPT_DATACARRIER; | bool fAcceptDatacarrier = DEFAULT_ACCEPT_DATACARRIER; | ||||
CScriptID::CScriptID(const CScript &in) | CScriptID::CScriptID(const CScript &in) | ||||
: uint160(Hash160(in.begin(), in.end())) {} | : uint160(Hash160(in.begin(), in.end())) {} | ||||
ScriptHash::ScriptHash(const CScript &in) | |||||
: uint160(Hash160(in.begin(), in.end())) {} | |||||
PKHash::PKHash(const CPubKey &pubkey) : uint160(pubkey.GetID()) {} | |||||
const char *GetTxnOutputType(txnouttype t) { | const char *GetTxnOutputType(txnouttype t) { | ||||
switch (t) { | switch (t) { | ||||
case TX_NONSTANDARD: | case TX_NONSTANDARD: | ||||
return "nonstandard"; | return "nonstandard"; | ||||
case TX_PUBKEY: | case TX_PUBKEY: | ||||
return "pubkey"; | return "pubkey"; | ||||
case TX_PUBKEYHASH: | case TX_PUBKEYHASH: | ||||
return "pubkeyhash"; | return "pubkeyhash"; | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | bool ExtractDestination(const CScript &scriptPubKey, | ||||
txnouttype whichType = Solver(scriptPubKey, vSolutions); | txnouttype whichType = Solver(scriptPubKey, vSolutions); | ||||
if (whichType == TX_PUBKEY) { | if (whichType == TX_PUBKEY) { | ||||
CPubKey pubKey(vSolutions[0]); | CPubKey pubKey(vSolutions[0]); | ||||
if (!pubKey.IsValid()) { | if (!pubKey.IsValid()) { | ||||
return false; | return false; | ||||
} | } | ||||
addressRet = pubKey.GetID(); | addressRet = PKHash(pubKey); | ||||
return true; | return true; | ||||
} | } | ||||
if (whichType == TX_PUBKEYHASH) { | if (whichType == TX_PUBKEYHASH) { | ||||
addressRet = CKeyID(uint160(vSolutions[0])); | addressRet = PKHash(uint160(vSolutions[0])); | ||||
return true; | return true; | ||||
} | } | ||||
if (whichType == TX_SCRIPTHASH) { | if (whichType == TX_SCRIPTHASH) { | ||||
addressRet = CScriptID(uint160(vSolutions[0])); | addressRet = ScriptHash(uint160(vSolutions[0])); | ||||
return true; | return true; | ||||
} | } | ||||
// Multisig txns have more than one address... | // Multisig txns have more than one address... | ||||
return false; | return false; | ||||
} | } | ||||
bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, | bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, | ||||
std::vector<CTxDestination> &addressRet, | std::vector<CTxDestination> &addressRet, | ||||
Show All 11 Lines | bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, | ||||
if (typeRet == TX_MULTISIG) { | if (typeRet == TX_MULTISIG) { | ||||
nRequiredRet = vSolutions.front()[0]; | nRequiredRet = vSolutions.front()[0]; | ||||
for (size_t i = 1; i < vSolutions.size() - 1; i++) { | for (size_t i = 1; i < vSolutions.size() - 1; i++) { | ||||
CPubKey pubKey(vSolutions[i]); | CPubKey pubKey(vSolutions[i]); | ||||
if (!pubKey.IsValid()) { | if (!pubKey.IsValid()) { | ||||
continue; | continue; | ||||
} | } | ||||
CTxDestination address = pubKey.GetID(); | CTxDestination address = PKHash(pubKey); | ||||
addressRet.push_back(address); | addressRet.push_back(address); | ||||
} | } | ||||
if (addressRet.empty()) { | if (addressRet.empty()) { | ||||
return false; | return false; | ||||
} | } | ||||
} else { | } else { | ||||
nRequiredRet = 1; | nRequiredRet = 1; | ||||
Show All 15 Lines | |||||
public: | public: | ||||
explicit CScriptVisitor(CScript *scriptin) { script = scriptin; } | explicit CScriptVisitor(CScript *scriptin) { script = scriptin; } | ||||
bool operator()(const CNoDestination &dest) const { | bool operator()(const CNoDestination &dest) const { | ||||
script->clear(); | script->clear(); | ||||
return false; | return false; | ||||
} | } | ||||
bool operator()(const CKeyID &keyID) const { | bool operator()(const PKHash &keyID) const { | ||||
script->clear(); | script->clear(); | ||||
*script << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY | *script << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY | ||||
<< OP_CHECKSIG; | << OP_CHECKSIG; | ||||
return true; | return true; | ||||
} | } | ||||
bool operator()(const CScriptID &scriptID) const { | bool operator()(const ScriptHash &scriptID) const { | ||||
script->clear(); | script->clear(); | ||||
*script << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL; | *script << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL; | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
} // namespace | } // namespace | ||||
CScript GetScriptForDestination(const CTxDestination &dest) { | CScript GetScriptForDestination(const CTxDestination &dest) { | ||||
Show All 25 Lines |