Changeset View
Changeset View
Standalone View
Standalone View
src/script/standard.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <script/standard.h> | #include <script/standard.h> | ||||
#include <crypto/sha256.h> | #include <crypto/sha256.h> | ||||
#include <script/script.h> | #include <script/script.h> | ||||
#include <string> | |||||
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) | ScriptHash::ScriptHash(const CScript &in) | ||||
: uint160(Hash160(in.begin(), in.end())) {} | : uint160(Hash160(in.begin(), in.end())) {} | ||||
PKHash::PKHash(const CPubKey &pubkey) : uint160(pubkey.GetID()) {} | PKHash::PKHash(const CPubKey &pubkey) : uint160(pubkey.GetID()) {} | ||||
const char *GetTxnOutputType(txnouttype t) { | std::string 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"; | ||||
case TX_SCRIPTHASH: | case TX_SCRIPTHASH: | ||||
return "scripthash"; | return "scripthash"; | ||||
case TX_MULTISIG: | case TX_MULTISIG: | ||||
return "multisig"; | return "multisig"; | ||||
case TX_NULL_DATA: | case TX_NULL_DATA: | ||||
return "nulldata"; | return "nulldata"; | ||||
} | } | ||||
return nullptr; | assert(false); | ||||
} | } | ||||
static bool MatchPayToPubkey(const CScript &script, valtype &pubkey) { | static bool MatchPayToPubkey(const CScript &script, valtype &pubkey) { | ||||
if (script.size() == CPubKey::SIZE + 2 && script[0] == CPubKey::SIZE && | if (script.size() == CPubKey::SIZE + 2 && script[0] == CPubKey::SIZE && | ||||
script.back() == OP_CHECKSIG) { | script.back() == OP_CHECKSIG) { | ||||
pubkey = | pubkey = | ||||
valtype(script.begin() + 1, script.begin() + CPubKey::SIZE + 1); | valtype(script.begin() + 1, script.begin() + CPubKey::SIZE + 1); | ||||
return CPubKey::ValidSize(pubkey); | return CPubKey::ValidSize(pubkey); | ||||
▲ Show 20 Lines • Show All 225 Lines • Show Last 20 Lines |