You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

standard.h 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright (c) 2009-2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2015 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.
  5. #ifndef BITCOIN_SCRIPT_STANDARD_H
  6. #define BITCOIN_SCRIPT_STANDARD_H
  7. #include "script/interpreter.h"
  8. #include "uint256.h"
  9. #include <boost/variant.hpp>
  10. #include <stdint.h>
  11. static const bool DEFAULT_ACCEPT_DATACARRIER = true;
  12. class CKeyID;
  13. class CScript;
  14. /** A reference to a CScript: the Hash160 of its serialization (see script.h) */
  15. class CScriptID : public uint160
  16. {
  17. public:
  18. CScriptID() : uint160() {}
  19. CScriptID(const CScript& in);
  20. CScriptID(const uint160& in) : uint160(in) {}
  21. };
  22. static const unsigned int MAX_OP_RETURN_RELAY = 83; //!< bytes (+1 for OP_RETURN, +2 for the pushdata opcodes)
  23. extern bool fAcceptDatacarrier;
  24. extern unsigned nMaxDatacarrierBytes;
  25. /**
  26. * Mandatory script verification flags that all new blocks must comply with for
  27. * them to be valid. (but old blocks may not comply with) Currently just P2SH,
  28. * but in the future other flags may be added, such as a soft-fork to enforce
  29. * strict DER encoding.
  30. *
  31. * Failing one of these tests may trigger a DoS ban - see CheckInputs() for
  32. * details.
  33. */
  34. static const unsigned int MANDATORY_SCRIPT_VERIFY_FLAGS = SCRIPT_VERIFY_P2SH;
  35. enum txnouttype
  36. {
  37. TX_NONSTANDARD,
  38. // 'standard' transaction types:
  39. TX_PUBKEY,
  40. TX_PUBKEYHASH,
  41. TX_SCRIPTHASH,
  42. TX_MULTISIG,
  43. TX_NULL_DATA,
  44. };
  45. class CNoDestination {
  46. public:
  47. friend bool operator==(const CNoDestination &a, const CNoDestination &b) { return true; }
  48. friend bool operator<(const CNoDestination &a, const CNoDestination &b) { return true; }
  49. };
  50. /**
  51. * A txout script template with a specific destination. It is either:
  52. * * CNoDestination: no destination set
  53. * * CKeyID: TX_PUBKEYHASH destination
  54. * * CScriptID: TX_SCRIPTHASH destination
  55. * A CTxDestination is the internal data type encoded in a CBitcoinAddress
  56. */
  57. typedef boost::variant<CNoDestination, CKeyID, CScriptID> CTxDestination;
  58. const char* GetTxnOutputType(txnouttype t);
  59. bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet);
  60. bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet);
  61. bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int& nRequiredRet);
  62. CScript GetScriptForDestination(const CTxDestination& dest);
  63. CScript GetScriptForRawPubKey(const CPubKey& pubkey);
  64. CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys);
  65. #endif // BITCOIN_SCRIPT_STANDARD_H