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.

bitcoinconsensus.h 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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.
  5. #ifndef BITCOIN_BITCOINCONSENSUS_H
  6. #define BITCOIN_BITCOINCONSENSUS_H
  7. #include <stdint.h>
  8. #if defined(BUILD_BITCOIN_INTERNAL) && defined(HAVE_CONFIG_H)
  9. #include "config/bitcoin-config.h"
  10. #if defined(_WIN32)
  11. #if defined(DLL_EXPORT)
  12. #if defined(HAVE_FUNC_ATTRIBUTE_DLLEXPORT)
  13. #define EXPORT_SYMBOL __declspec(dllexport)
  14. #else
  15. #define EXPORT_SYMBOL
  16. #endif
  17. #endif
  18. #elif defined(HAVE_FUNC_ATTRIBUTE_VISIBILITY)
  19. #define EXPORT_SYMBOL __attribute__ ((visibility ("default")))
  20. #endif
  21. #elif defined(MSC_VER) && !defined(STATIC_LIBBITCOINCONSENSUS)
  22. #define EXPORT_SYMBOL __declspec(dllimport)
  23. #endif
  24. #ifndef EXPORT_SYMBOL
  25. #define EXPORT_SYMBOL
  26. #endif
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #define BITCOINCONSENSUS_API_VER 1
  31. typedef enum bitcoinconsensus_error_t
  32. {
  33. bitcoinconsensus_ERR_OK = 0,
  34. bitcoinconsensus_ERR_TX_INDEX,
  35. bitcoinconsensus_ERR_TX_SIZE_MISMATCH,
  36. bitcoinconsensus_ERR_TX_DESERIALIZE,
  37. bitcoinconsensus_ERR_AMOUNT_REQUIRED,
  38. } bitcoinconsensus_error;
  39. /** Script verification flags */
  40. enum
  41. {
  42. bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NONE = 0,
  43. bitcoinconsensus_SCRIPT_FLAGS_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts
  44. bitcoinconsensus_SCRIPT_FLAGS_VERIFY_DERSIG = (1U << 2), // enforce strict DER (BIP66) compliance
  45. bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NULLDUMMY = (1U << 4), // enforce NULLDUMMY (BIP147)
  46. bitcoinconsensus_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9), // enable CHECKLOCKTIMEVERIFY (BIP65)
  47. bitcoinconsensus_SCRIPT_FLAGS_VERIFY_CHECKSEQUENCEVERIFY = (1U << 10), // enable CHECKSEQUENCEVERIFY (BIP112)
  48. bitcoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS = (1U << 11), // enable WITNESS (BIP141)
  49. };
  50. /// Returns 1 if the input nIn of the serialized transaction pointed to by
  51. /// txTo correctly spends the scriptPubKey pointed to by scriptPubKey under
  52. /// the additional constraints specified by flags.
  53. /// If not NULL, err will contain an error/success code for the operation
  54. EXPORT_SYMBOL int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
  55. const unsigned char *txTo , unsigned int txToLen,
  56. unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err);
  57. EXPORT_SYMBOL int bitcoinconsensus_verify_script_with_amount(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount,
  58. const unsigned char *txTo , unsigned int txToLen,
  59. unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err);
  60. EXPORT_SYMBOL unsigned int bitcoinconsensus_version();
  61. #ifdef __cplusplus
  62. } // extern "C"
  63. #endif
  64. #undef EXPORT_SYMBOL
  65. #endif // BITCOIN_BITCOINCONSENSUS_H