]> Git Repo - VerusCoin.git/blame - src/script/standard.h
Merge pull request #5576
[VerusCoin.git] / src / script / standard.h
CommitLineData
c4408a6c 1// Copyright (c) 2009-2010 Satoshi Nakamoto
f914f1a7 2// Copyright (c) 2009-2014 The Bitcoin Core developers
2d79bba3 3// Distributed under the MIT software license, see the accompanying
c4408a6c 4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
84738627
PJ
6#ifndef BITCOIN_SCRIPT_STANDARD_H
7#define BITCOIN_SCRIPT_STANDARD_H
c4408a6c 8
c4408a6c 9#include "script/interpreter.h"
b4347f60 10#include "uint256.h"
c4408a6c 11
85c579e3
CF
12#include <boost/variant.hpp>
13
c4408a6c 14#include <stdint.h>
15
d2e74c55 16class CKeyID;
b4347f60 17class CScript;
c4408a6c 18
066e2a14
CF
19/** A reference to a CScript: the Hash160 of its serialization (see script.h) */
20class CScriptID : public uint160
21{
22public:
23 CScriptID() : uint160(0) {}
24 CScriptID(const CScript& in);
25 CScriptID(const uint160& in) : uint160(in) {}
26};
27
b9a36b15 28static const unsigned int MAX_OP_RETURN_RELAY = 40; //! bytes
2aa63292 29extern unsigned nMaxDatacarrierBytes;
c4408a6c 30
b9a36b15
MF
31/**
32 * Mandatory script verification flags that all new blocks must comply with for
33 * them to be valid. (but old blocks may not comply with) Currently just P2SH,
34 * but in the future other flags may be added, such as a soft-fork to enforce
35 * strict DER encoding.
36 *
37 * Failing one of these tests may trigger a DoS ban - see CheckInputs() for
38 * details.
39 */
c4408a6c 40static const unsigned int MANDATORY_SCRIPT_VERIFY_FLAGS = SCRIPT_VERIFY_P2SH;
41
b9a36b15
MF
42/**
43 * Standard script verification flags that standard transactions will comply
44 * with. However scripts violating these flags may still be present in valid
45 * blocks and we must accept those blocks.
46 */
c4408a6c 47static const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VERIFY_FLAGS |
48 SCRIPT_VERIFY_STRICTENC |
698c6abb 49 SCRIPT_VERIFY_MINIMALDATA |
03914234
PT
50 SCRIPT_VERIFY_NULLDUMMY |
51 SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS;
c4408a6c 52
b9a36b15 53/** For convenience, standard but not mandatory verify flags. */
c4408a6c 54static const unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS;
55
56enum txnouttype
57{
58 TX_NONSTANDARD,
59 // 'standard' transaction types:
60 TX_PUBKEY,
61 TX_PUBKEYHASH,
62 TX_SCRIPTHASH,
63 TX_MULTISIG,
64 TX_NULL_DATA,
65};
66
0be990ba
PW
67class CNoDestination {
68public:
69 friend bool operator==(const CNoDestination &a, const CNoDestination &b) { return true; }
70 friend bool operator<(const CNoDestination &a, const CNoDestination &b) { return true; }
71};
72
b9a36b15
MF
73/**
74 * A txout script template with a specific destination. It is either:
0be990ba
PW
75 * * CNoDestination: no destination set
76 * * CKeyID: TX_PUBKEYHASH destination
77 * * CScriptID: TX_SCRIPTHASH destination
78 * A CTxDestination is the internal data type encoded in a CBitcoinAddress
79 */
80typedef boost::variant<CNoDestination, CKeyID, CScriptID> CTxDestination;
81
c4408a6c 82const char* GetTxnOutputType(txnouttype t);
83
84bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet);
85int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned char> >& vSolutions);
86bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType);
87bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet);
88bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int& nRequiredRet);
89
0be990ba
PW
90CScript GetScriptForDestination(const CTxDestination& dest);
91CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys);
92
84738627 93#endif // BITCOIN_SCRIPT_STANDARD_H
This page took 0.057915 seconds and 4 git commands to generate.