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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright (c) 2009-2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2016 The Starwels 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 STARWELS_SCRIPT_STANDARD_H
  6. #define STARWELS_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. TX_WITNESS_V0_SCRIPTHASH,
  45. TX_WITNESS_V0_KEYHASH,
  46. };
  47. class CNoDestination {
  48. public:
  49. friend bool operator==(const CNoDestination &a, const CNoDestination &b) { return true; }
  50. friend bool operator<(const CNoDestination &a, const CNoDestination &b) { return true; }
  51. };
  52. /**
  53. * A txout script template with a specific destination. It is either:
  54. * * CNoDestination: no destination set
  55. * * CKeyID: TX_PUBKEYHASH destination
  56. * * CScriptID: TX_SCRIPTHASH destination
  57. * A CTxDestination is the internal data type encoded in a CStarwelsAddress
  58. */
  59. typedef boost::variant<CNoDestination, CKeyID, CScriptID> CTxDestination;
  60. const char* GetTxnOutputType(txnouttype t);
  61. bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet);
  62. bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet);
  63. bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int& nRequiredRet);
  64. CScript GetScriptForDestination(const CTxDestination& dest);
  65. CScript GetScriptForRawPubKey(const CPubKey& pubkey);
  66. CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys);
  67. CScript GetScriptForWitness(const CScript& redeemscript);
  68. #endif // STARWELS_SCRIPT_STANDARD_H