Merge #9980: Fix mem access violation merkleblock
[bitcoinplatinum.git] / src / script / standard.h
blob097e0c3748c34688259b6c1d64c35e59a70a403f
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2016 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 #ifndef BITCOIN_SCRIPT_STANDARD_H
7 #define BITCOIN_SCRIPT_STANDARD_H
9 #include "script/interpreter.h"
10 #include "uint256.h"
12 #include <boost/variant.hpp>
14 #include <stdint.h>
16 static const bool DEFAULT_ACCEPT_DATACARRIER = true;
18 class CKeyID;
19 class CScript;
21 /** A reference to a CScript: the Hash160 of its serialization (see script.h) */
22 class CScriptID : public uint160
24 public:
25 CScriptID() : uint160() {}
26 CScriptID(const CScript& in);
27 CScriptID(const uint160& in) : uint160(in) {}
30 static const unsigned int MAX_OP_RETURN_RELAY = 83; //!< bytes (+1 for OP_RETURN, +2 for the pushdata opcodes)
31 extern bool fAcceptDatacarrier;
32 extern unsigned nMaxDatacarrierBytes;
34 /**
35 * Mandatory script verification flags that all new blocks must comply with for
36 * them to be valid. (but old blocks may not comply with) Currently just P2SH,
37 * but in the future other flags may be added, such as a soft-fork to enforce
38 * strict DER encoding.
40 * Failing one of these tests may trigger a DoS ban - see CheckInputs() for
41 * details.
43 static const unsigned int MANDATORY_SCRIPT_VERIFY_FLAGS = SCRIPT_VERIFY_P2SH;
45 enum txnouttype
47 TX_NONSTANDARD,
48 // 'standard' transaction types:
49 TX_PUBKEY,
50 TX_PUBKEYHASH,
51 TX_SCRIPTHASH,
52 TX_MULTISIG,
53 TX_NULL_DATA,
54 TX_WITNESS_V0_SCRIPTHASH,
55 TX_WITNESS_V0_KEYHASH,
58 class CNoDestination {
59 public:
60 friend bool operator==(const CNoDestination &a, const CNoDestination &b) { return true; }
61 friend bool operator<(const CNoDestination &a, const CNoDestination &b) { return true; }
64 /**
65 * A txout script template with a specific destination. It is either:
66 * * CNoDestination: no destination set
67 * * CKeyID: TX_PUBKEYHASH destination
68 * * CScriptID: TX_SCRIPTHASH destination
69 * A CTxDestination is the internal data type encoded in a CBitcoinAddress
71 typedef boost::variant<CNoDestination, CKeyID, CScriptID> CTxDestination;
73 const char* GetTxnOutputType(txnouttype t);
75 bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet);
76 bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet);
77 bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int& nRequiredRet);
79 CScript GetScriptForDestination(const CTxDestination& dest);
80 CScript GetScriptForRawPubKey(const CPubKey& pubkey);
81 CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys);
82 CScript GetScriptForWitness(const CScript& redeemscript);
84 #endif // BITCOIN_SCRIPT_STANDARD_H