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.

starwelsconsensus.h 3.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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_STARWELSCONSENSUS_H
  6. #define STARWELS_STARWELSCONSENSUS_H
  7. #include <stdint.h>
  8. #if defined(BUILD_STARWELS_INTERNAL) && defined(HAVE_CONFIG_H)
  9. #include "config/starwels-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_LIBSTARWELSCONSENSUS)
  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 STARWELSCONSENSUS_API_VER 1
  31. typedef enum starwelsconsensus_error_t
  32. {
  33. starwelsconsensus_ERR_OK = 0,
  34. starwelsconsensus_ERR_TX_INDEX,
  35. starwelsconsensus_ERR_TX_SIZE_MISMATCH,
  36. starwelsconsensus_ERR_TX_DESERIALIZE,
  37. starwelsconsensus_ERR_AMOUNT_REQUIRED,
  38. starwelsconsensus_ERR_INVALID_FLAGS,
  39. } starwelsconsensus_error;
  40. /** Script verification flags */
  41. enum
  42. {
  43. starwelsconsensus_SCRIPT_FLAGS_VERIFY_NONE = 0,
  44. starwelsconsensus_SCRIPT_FLAGS_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts
  45. starwelsconsensus_SCRIPT_FLAGS_VERIFY_DERSIG = (1U << 2), // enforce strict DER (BIP66) compliance
  46. starwelsconsensus_SCRIPT_FLAGS_VERIFY_NULLDUMMY = (1U << 4), // enforce NULLDUMMY (BIP147)
  47. starwelsconsensus_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9), // enable CHECKLOCKTIMEVERIFY (BIP65)
  48. starwelsconsensus_SCRIPT_FLAGS_VERIFY_CHECKSEQUENCEVERIFY = (1U << 10), // enable CHECKSEQUENCEVERIFY (BIP112)
  49. starwelsconsensus_SCRIPT_FLAGS_VERIFY_WITNESS = (1U << 11), // enable WITNESS (BIP141)
  50. starwelsconsensus_SCRIPT_FLAGS_VERIFY_ALL = starwelsconsensus_SCRIPT_FLAGS_VERIFY_P2SH | starwelsconsensus_SCRIPT_FLAGS_VERIFY_DERSIG |
  51. starwelsconsensus_SCRIPT_FLAGS_VERIFY_NULLDUMMY | starwelsconsensus_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY |
  52. starwelsconsensus_SCRIPT_FLAGS_VERIFY_CHECKSEQUENCEVERIFY | starwelsconsensus_SCRIPT_FLAGS_VERIFY_WITNESS
  53. };
  54. /// Returns 1 if the input nIn of the serialized transaction pointed to by
  55. /// txTo correctly spends the scriptPubKey pointed to by scriptPubKey under
  56. /// the additional constraints specified by flags.
  57. /// If not nullptr, err will contain an error/success code for the operation
  58. EXPORT_SYMBOL int starwelsconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
  59. const unsigned char *txTo , unsigned int txToLen,
  60. unsigned int nIn, unsigned int flags, starwelsconsensus_error* err);
  61. EXPORT_SYMBOL int starwelsconsensus_verify_script_with_amount(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount,
  62. const unsigned char *txTo , unsigned int txToLen,
  63. unsigned int nIn, unsigned int flags, starwelsconsensus_error* err);
  64. EXPORT_SYMBOL unsigned int starwelsconsensus_version();
  65. #ifdef __cplusplus
  66. } // extern "C"
  67. #endif
  68. #undef EXPORT_SYMBOL
  69. #endif // STARWELS_STARWELSCONSENSUS_H