diff --git a/.gitignore b/.gitignore index b0dac187c7d..4b798be8751 100644 --- a/.gitignore +++ b/.gitignore @@ -121,4 +121,4 @@ qa/pull-tester/test.*/* /doc/doxygen/ -libbitcoinconsensus.pc +libzcashconsensus.pc diff --git a/Makefile.am b/Makefile.am index 09cd9b92e70..7cbd5c69b58 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,7 @@ GZIP_ENV="-9n" if BUILD_BITCOIN_LIBS pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libbitcoinconsensus.pc +pkgconfig_DATA = libzcashconsensus.pc endif BITCOIND_BIN=$(top_builddir)/src/zcashd$(EXEEXT) diff --git a/configure.ac b/configure.ac index 99365afd347..e504af39dcc 100644 --- a/configure.ac +++ b/configure.ac @@ -754,7 +754,7 @@ AC_MSG_CHECKING([whether to build libraries]) AM_CONDITIONAL([BUILD_BITCOIN_LIBS], [test x$build_bitcoin_libs = xyes]) if test x$build_bitcoin_libs = xyes; then AC_DEFINE(HAVE_CONSENSUS_LIB, 1, [Define this symbol if the consensus lib has been built]) - AC_CONFIG_FILES([libbitcoinconsensus.pc:libbitcoinconsensus.pc.in]) + AC_CONFIG_FILES([libzcashconsensus.pc:libzcashconsensus.pc.in]) fi AC_MSG_RESULT($build_bitcoin_libs) diff --git a/libbitcoinconsensus.pc.in b/libzcashconsensus.pc.in similarity index 55% rename from libbitcoinconsensus.pc.in rename to libzcashconsensus.pc.in index 3ca1696a31c..5cb2d05e3cf 100644 --- a/libbitcoinconsensus.pc.in +++ b/libzcashconsensus.pc.in @@ -3,9 +3,9 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ -Name: Bitcoin Core consensus library -Description: Library for the Bitcoin consensus protocol. +Name: Zcash consensus library +Description: Library for the Zcash consensus protocol. Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lbitcoinconsensus +Libs: -L${libdir} -lzcashconsensus Cflags: -I${includedir} Requires.private: libcrypto diff --git a/src/Makefile.am b/src/Makefile.am index 9f8a181897e..19243ae7645 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,10 +52,10 @@ EXTRA_LIBRARIES += libbitcoin_wallet.a endif if BUILD_BITCOIN_LIBS -lib_LTLIBRARIES = libbitcoinconsensus.la -LIBBITCOIN_CONSENSUS=libbitcoinconsensus.la +lib_LTLIBRARIES = libzcashconsensus.la +LIBZCASH_CONSENSUS=libzcashconsensus.la else -LIBBITCOIN_CONSENSUS= +LIBZCASH_CONSENSUS= endif bin_PROGRAMS = @@ -440,10 +440,10 @@ libzcash_a_LDFLAGS = $(HARDENED_LDFLAGS) libzcash_a_CPPFLAGS += -DMONTGOMERY_OUTPUT -# bitcoinconsensus library # +# zcashconsensus library # if BUILD_BITCOIN_LIBS -include_HEADERS = script/bitcoinconsensus.h -libbitcoinconsensus_la_SOURCES = \ +include_HEADERS = script/zcashconsensus.h +libzcashconsensus_la_SOURCES = \ crypto/equihash.cpp \ crypto/hmac_sha512.cpp \ crypto/ripemd160.cpp \ @@ -455,19 +455,19 @@ libbitcoinconsensus_la_SOURCES = \ hash.cpp \ primitives/transaction.cpp \ pubkey.cpp \ - script/bitcoinconsensus.cpp \ + script/zcashconsensus.cpp \ script/interpreter.cpp \ script/script.cpp \ uint256.cpp \ utilstrencodings.cpp if GLIBC_BACK_COMPAT - libbitcoinconsensus_la_SOURCES += compat/glibc_compat.cpp + libzcashconsensus_la_SOURCES += compat/glibc_compat.cpp endif -libbitcoinconsensus_la_LDFLAGS = -no-undefined $(RELDFLAGS) -libbitcoinconsensus_la_LIBADD = $(CRYPTO_LIBS) -libbitcoinconsensus_la_CPPFLAGS = $(CRYPTO_CFLAGS) -I$(builddir)/obj -DBUILD_BITCOIN_INTERNAL +libzcashconsensus_la_LDFLAGS = -no-undefined $(RELDFLAGS) +libzcashconsensus_la_LIBADD = $(CRYPTO_LIBS) +libzcashconsensus_la_CPPFLAGS = $(CRYPTO_CFLAGS) -I$(builddir)/obj -DBUILD_BITCOIN_INTERNAL endif # diff --git a/src/Makefile.gtest.include b/src/Makefile.gtest.include index d68c9a98a52..e6291efe48a 100644 --- a/src/Makefile.gtest.include +++ b/src/Makefile.gtest.include @@ -32,7 +32,7 @@ if ENABLE_WALLET zcash_gtest_LDADD += $(LIBBITCOIN_WALLET) endif -zcash_gtest_LDADD += $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) +zcash_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) zcash_gtest_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static diff --git a/src/Makefile.test.include b/src/Makefile.test.include index f8fd7a33453..e296428054b 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -103,7 +103,7 @@ if ENABLE_WALLET test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET) endif -test_test_bitcoin_LDADD += $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) +test_test_bitcoin_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES) diff --git a/src/script/bitcoinconsensus.cpp b/src/script/zcashconsensus.cpp similarity index 78% rename from src/script/bitcoinconsensus.cpp rename to src/script/zcashconsensus.cpp index b0d5faaf777..d66cf21c0aa 100644 --- a/src/script/bitcoinconsensus.cpp +++ b/src/script/zcashconsensus.cpp @@ -3,7 +3,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "bitcoinconsensus.h" +#include "zcashconsensus.h" #include "primitives/transaction.h" #include "script/interpreter.h" @@ -53,7 +53,7 @@ class TxInputStream size_t m_remaining; }; -inline int set_error(bitcoinconsensus_error* ret, bitcoinconsensus_error serror) +inline int set_error(zcashconsensus_error* ret, zcashconsensus_error serror) { if (ret) *ret = serror; @@ -62,30 +62,30 @@ inline int set_error(bitcoinconsensus_error* ret, bitcoinconsensus_error serror) } // anon namespace -int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, +int zcashconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, const unsigned char *txTo , unsigned int txToLen, - unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err) + unsigned int nIn, unsigned int flags, zcashconsensus_error* err) { try { TxInputStream stream(SER_NETWORK, PROTOCOL_VERSION, txTo, txToLen); CTransaction tx; stream >> tx; if (nIn >= tx.vin.size()) - return set_error(err, bitcoinconsensus_ERR_TX_INDEX); + return set_error(err, zcashconsensus_ERR_TX_INDEX); if (tx.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION) != txToLen) - return set_error(err, bitcoinconsensus_ERR_TX_SIZE_MISMATCH); + return set_error(err, zcashconsensus_ERR_TX_SIZE_MISMATCH); // Regardless of the verification result, the tx did not error. - set_error(err, bitcoinconsensus_ERR_OK); + set_error(err, zcashconsensus_ERR_OK); return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), flags, TransactionSignatureChecker(&tx, nIn), NULL); } catch (const std::exception&) { - return set_error(err, bitcoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing + return set_error(err, zcashconsensus_ERR_TX_DESERIALIZE); // Error deserializing } } -unsigned int bitcoinconsensus_version() +unsigned int zcashconsensus_version() { // Just use the API version for now - return BITCOINCONSENSUS_API_VER; + return ZCASHCONSENSUS_API_VER; } diff --git a/src/script/bitcoinconsensus.h b/src/script/zcashconsensus.h similarity index 57% rename from src/script/bitcoinconsensus.h rename to src/script/zcashconsensus.h index a48ff1e18d3..a68921d908d 100644 --- a/src/script/bitcoinconsensus.h +++ b/src/script/zcashconsensus.h @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef BITCOIN_BITCOINCONSENSUS_H -#define BITCOIN_BITCOINCONSENSUS_H +#ifndef BITCOIN_ZCASHCONSENSUS_H +#define BITCOIN_ZCASHCONSENSUS_H #if defined(BUILD_BITCOIN_INTERNAL) && defined(HAVE_CONFIG_H) #include "config/bitcoin-config.h" @@ -19,7 +19,7 @@ #elif defined(HAVE_FUNC_ATTRIBUTE_VISIBILITY) #define EXPORT_SYMBOL __attribute__ ((visibility ("default"))) #endif -#elif defined(MSC_VER) && !defined(STATIC_LIBBITCOINCONSENSUS) +#elif defined(MSC_VER) && !defined(STATIC_LIBZCASHCONSENSUS) #define EXPORT_SYMBOL __declspec(dllimport) #endif @@ -31,34 +31,34 @@ extern "C" { #endif -#define BITCOINCONSENSUS_API_VER 0 +#define ZCASHCONSENSUS_API_VER 0 -typedef enum bitcoinconsensus_error_t +typedef enum zcashconsensus_error_t { - bitcoinconsensus_ERR_OK = 0, - bitcoinconsensus_ERR_TX_INDEX, - bitcoinconsensus_ERR_TX_SIZE_MISMATCH, - bitcoinconsensus_ERR_TX_DESERIALIZE, -} bitcoinconsensus_error; + zcashconsensus_ERR_OK = 0, + zcashconsensus_ERR_TX_INDEX, + zcashconsensus_ERR_TX_SIZE_MISMATCH, + zcashconsensus_ERR_TX_DESERIALIZE, +} zcashconsensus_error; /** Script verification flags */ enum { - bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NONE = 0, - bitcoinconsensus_SCRIPT_FLAGS_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts - bitcoinconsensus_SCRIPT_FLAGS_VERIFY_DERSIG = (1U << 2), // enforce strict DER (BIP66) compliance - bitcoinconsensus_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9), // enable CHECKLOCKTIMEVERIFY (BIP65) + zcashconsensus_SCRIPT_FLAGS_VERIFY_NONE = 0, + zcashconsensus_SCRIPT_FLAGS_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts + zcashconsensus_SCRIPT_FLAGS_VERIFY_DERSIG = (1U << 2), // enforce strict DER (BIP66) compliance + zcashconsensus_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9), // enable CHECKLOCKTIMEVERIFY (BIP65) }; /// Returns 1 if the input nIn of the serialized transaction pointed to by /// txTo correctly spends the scriptPubKey pointed to by scriptPubKey under /// the additional constraints specified by flags. /// If not NULL, err will contain an error/success code for the operation -EXPORT_SYMBOL int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, +EXPORT_SYMBOL int zcashconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, const unsigned char *txTo , unsigned int txToLen, - unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err); + unsigned int nIn, unsigned int flags, zcashconsensus_error* err); -EXPORT_SYMBOL unsigned int bitcoinconsensus_version(); +EXPORT_SYMBOL unsigned int zcashconsensus_version(); #ifdef __cplusplus } // extern "C" @@ -66,4 +66,4 @@ EXPORT_SYMBOL unsigned int bitcoinconsensus_version(); #undef EXPORT_SYMBOL -#endif // BITCOIN_BITCOINCONSENSUS_H +#endif // BITCOIN_ZCASHCONSENSUS_H diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index c0614cca431..cb028dfbb01 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -16,7 +16,7 @@ #include "test/test_bitcoin.h" #if defined(HAVE_CONSENSUS_LIB) -#include "script/bitcoinconsensus.h" +#include "script/zcashconsensus.h" #endif #include @@ -99,7 +99,7 @@ void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, int flags, bo #if defined(HAVE_CONSENSUS_LIB) CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << tx2; - BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script(begin_ptr(scriptPubKey), scriptPubKey.size(), (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect,message); + BOOST_CHECK_MESSAGE(zcashconsensus_verify_script(begin_ptr(scriptPubKey), scriptPubKey.size(), (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect,message); #endif }