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.

policy.h 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (c) 2009-2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2015 The Bitcoin 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_POLICY_POLICY_H
  6. #define BITCOIN_POLICY_POLICY_H
  7. #include "consensus/consensus.h"
  8. #include "script/interpreter.h"
  9. #include "script/standard.h"
  10. #include <string>
  11. class CCoinsViewCache;
  12. /** Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will create **/
  13. static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000;
  14. static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
  15. /** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/
  16. static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 0;
  17. /** The maximum size for transactions we're willing to relay/mine */
  18. static const unsigned int MAX_STANDARD_TX_SIZE = 100000;
  19. /** Maximum number of signature check operations in an IsStandard() P2SH script */
  20. static const unsigned int MAX_P2SH_SIGOPS = 15;
  21. /** The maximum number of sigops we're willing to relay/mine in a single tx */
  22. static const unsigned int MAX_STANDARD_TX_SIGOPS = MAX_BLOCK_SIGOPS/5;
  23. /** Default for -maxmempool, maximum megabytes of mempool memory usage */
  24. static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300;
  25. /**
  26. * Standard script verification flags that standard transactions will comply
  27. * with. However scripts violating these flags may still be present in valid
  28. * blocks and we must accept those blocks.
  29. */
  30. static const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VERIFY_FLAGS |
  31. SCRIPT_VERIFY_DERSIG |
  32. SCRIPT_VERIFY_STRICTENC |
  33. SCRIPT_VERIFY_MINIMALDATA |
  34. SCRIPT_VERIFY_NULLDUMMY |
  35. SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS |
  36. SCRIPT_VERIFY_CLEANSTACK |
  37. SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY |
  38. SCRIPT_VERIFY_LOW_S;
  39. /** For convenience, standard but not mandatory verify flags. */
  40. static const unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS;
  41. /** Used as the flags parameter to CheckFinalTx() in non-consensus code */
  42. static const unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS = LOCKTIME_MEDIAN_TIME_PAST;
  43. bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType);
  44. /**
  45. * Check for standard transaction types
  46. * @return True if all outputs (scriptPubKeys) use only standard transaction forms
  47. */
  48. bool IsStandardTx(const CTransaction& tx, std::string& reason);
  49. /**
  50. * Check for standard transaction types
  51. * @param[in] mapInputs Map of previous transactions that have outputs we're spending
  52. * @return True if all inputs (scriptSigs) use only standard transaction forms
  53. */
  54. bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs);
  55. #endif // BITCOIN_POLICY_POLICY_H