From 2f946226275023c175da9b17b93c1f2db8d4a848 Mon Sep 17 00:00:00 2001 From: Musee Ullah Date: Thu, 22 Jun 2017 06:26:58 -0700 Subject: [PATCH] rename libbitcoinconsensus to libmonacoinconsensus --- .gitignore | 2 +- Makefile.am | 2 +- configure.ac | 2 +- ...inconsensus.pc.in => libmonacoinconsensus.pc.in | 4 +-- src/Makefile.am | 28 +++++++-------- ...{bitcoinconsensus.cpp => monacoinconsensus.cpp} | 30 ++++++++-------- .../{bitcoinconsensus.h => monacoinconsensus.h} | 40 +++++++++++----------- src/test/script_tests.cpp | 10 +++--- 8 files changed, 59 insertions(+), 59 deletions(-) rename libbitcoinconsensus.pc.in => libmonacoinconsensus.pc.in (67%) rename src/script/{bitcoinconsensus.cpp => monacoinconsensus.cpp} (76%) rename src/script/{bitcoinconsensus.h => monacoinconsensus.h} (54%) diff --git a/.gitignore b/.gitignore index 6dcf89aed..530da5afc 100644 --- a/.gitignore +++ b/.gitignore @@ -113,5 +113,5 @@ share/BitcoindComparisonTool.jar /doc/doxygen/ -libbitcoinconsensus.pc +libmonacoinconsensus.pc contrib/devtools/split-debug.sh diff --git a/Makefile.am b/Makefile.am index bacf36b90..639aea4b8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,7 +11,7 @@ export PYTHONPATH if BUILD_BITCOIN_LIBS pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libbitcoinconsensus.pc +pkgconfig_DATA = libmonacoinconsensus.pc endif BITCOIND_BIN=$(top_builddir)/src/$(BITCOIN_DAEMON_NAME)$(EXEEXT) diff --git a/configure.ac b/configure.ac index 7398c4bda..51d3ae5a6 100644 --- a/configure.ac +++ b/configure.ac @@ -905,7 +905,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([libmonacoinconsensus.pc:libmonacoinconsensus.pc.in]) fi AC_MSG_RESULT($build_bitcoin_libs) diff --git a/libbitcoinconsensus.pc.in b/libmonacoinconsensus.pc.in similarity index 67% rename from libbitcoinconsensus.pc.in rename to libmonacoinconsensus.pc.in index eb920c47e..47960d29c 100644 --- a/libbitcoinconsensus.pc.in +++ b/libmonacoinconsensus.pc.in @@ -4,8 +4,8 @@ libdir=@libdir@ includedir=@includedir@ Name: @PACKAGE_NAME@ consensus library -Description: Library for the Bitcoin consensus protocol. +Description: Library for the Monacoin consensus protocol. Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lbitcoinconsensus +Libs: -L${libdir} -lmonacoinconsensus Cflags: -I${includedir} Requires.private: libcrypto diff --git a/src/Makefile.am b/src/Makefile.am index c731c8c56..14f6e492f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,7 +26,7 @@ BITCOIN_INCLUDES += $(UNIVALUE_CFLAGS) LIBBITCOIN_SERVER=libbitcoin_server.a LIBBITCOIN_COMMON=libbitcoin_common.a -LIBBITCOIN_CONSENSUS=libbitcoin_consensus.a +LIBBITCOIN_CONSENSUS=libmonacoin_consensus.a LIBBITCOIN_CLI=libbitcoin_cli.a LIBBITCOIN_UTIL=libbitcoin_util.a LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a @@ -37,7 +37,7 @@ if ENABLE_ZMQ LIBBITCOIN_ZMQ=libbitcoin_zmq.a endif if BUILD_BITCOIN_LIBS -LIBBITCOINCONSENSUS=libbitcoinconsensus.la +LIBBITCOINCONSENSUS=libmonacoinconsensus.la endif if ENABLE_WALLET LIBBITCOIN_WALLET=libbitcoin_wallet.a @@ -250,9 +250,9 @@ crypto_libbitcoin_crypto_a_SOURCES = \ crypto/sha512.h # consensus: shared between all executables that validate any consensus rules. -libbitcoin_consensus_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -fPIC -libbitcoin_consensus_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -fPIC -libbitcoin_consensus_a_SOURCES = \ +libmonacoin_consensus_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -fPIC +libmonacoin_consensus_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -fPIC +libmonacoin_consensus_a_SOURCES = \ amount.h \ arith_uint256.cpp \ arith_uint256.h \ @@ -269,7 +269,7 @@ libbitcoin_consensus_a_SOURCES = \ primitives/transaction.h \ pubkey.cpp \ pubkey.h \ - script/bitcoinconsensus.cpp \ + script/monacoinconsensus.cpp \ script/interpreter.cpp \ script/interpreter.h \ script/script.cpp \ @@ -425,19 +425,19 @@ monacoin_tx_LDADD = \ monacoin_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) # -# bitcoinconsensus library # +# monacoinconsensus library # if BUILD_BITCOIN_LIBS -include_HEADERS = script/bitcoinconsensus.h -libbitcoinconsensus_la_SOURCES = $(crypto_libbitcoin_crypto_a_SOURCES) $(libbitcoin_consensus_a_SOURCES) +include_HEADERS = script/monacoinconsensus.h +libmonacoinconsensus_la_SOURCES = $(crypto_libbitcoin_crypto_a_SOURCES) $(libmonacoin_consensus_a_SOURCES) if GLIBC_BACK_COMPAT - libbitcoinconsensus_la_SOURCES += compat/glibc_compat.cpp + libmonacoinconsensus_la_SOURCES += compat/glibc_compat.cpp endif -libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) -libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1) $(CRYPTO_LIBS) -libbitcoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL $(SSL_CFLAGS) -libbitcoinconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +libmonacoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) +libmonacoinconsensus_la_LIBADD = $(LIBSECP256K1) $(CRYPTO_LIBS) +libmonacoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL $(SSL_CFLAGS) +libmonacoinconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) endif # diff --git a/src/script/bitcoinconsensus.cpp b/src/script/monacoinconsensus.cpp similarity index 76% rename from src/script/bitcoinconsensus.cpp rename to src/script/monacoinconsensus.cpp index b629f4278..1471c3ecd 100644 --- a/src/script/bitcoinconsensus.cpp +++ b/src/script/monacoinconsensus.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 "monacoinconsensus.h" #include "primitives/transaction.h" #include "pubkey.h" @@ -54,7 +54,7 @@ private: size_t m_remaining; }; -inline int set_error(bitcoinconsensus_error* ret, bitcoinconsensus_error serror) +inline int set_error(monacoinconsensus_error* ret, monacoinconsensus_error serror) { if (ret) *ret = serror; @@ -71,49 +71,49 @@ ECCryptoClosure instance_of_eccryptoclosure; static int verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, CAmount amount, const unsigned char *txTo , unsigned int txToLen, - unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err) + unsigned int nIn, unsigned int flags, monacoinconsensus_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, monacoinconsensus_ERR_TX_INDEX); if (tx.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION) != txToLen) - return set_error(err, bitcoinconsensus_ERR_TX_SIZE_MISMATCH); + return set_error(err, monacoinconsensus_ERR_TX_SIZE_MISMATCH); // Regardless of the verification result, the tx did not error. - set_error(err, bitcoinconsensus_ERR_OK); + set_error(err, monacoinconsensus_ERR_OK); PrecomputedTransactionData txdata(tx); return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), nIn < tx.wit.vtxinwit.size() ? &tx.wit.vtxinwit[nIn].scriptWitness : NULL, flags, TransactionSignatureChecker(&tx, nIn, amount, txdata), NULL); } catch (const std::exception&) { - return set_error(err, bitcoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing + return set_error(err, monacoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing } } -int bitcoinconsensus_verify_script_with_amount(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount, +int monacoinconsensus_verify_script_with_amount(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount, const unsigned char *txTo , unsigned int txToLen, - unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err) + unsigned int nIn, unsigned int flags, monacoinconsensus_error* err) { CAmount am(amount); return ::verify_script(scriptPubKey, scriptPubKeyLen, am, txTo, txToLen, nIn, flags, err); } -int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, +int monacoinconsensus_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, monacoinconsensus_error* err) { - if (flags & bitcoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS) { - return set_error(err, bitcoinconsensus_ERR_AMOUNT_REQUIRED); + if (flags & monacoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS) { + return set_error(err, monacoinconsensus_ERR_AMOUNT_REQUIRED); } CAmount am(0); return ::verify_script(scriptPubKey, scriptPubKeyLen, am, txTo, txToLen, nIn, flags, err); } -unsigned int bitcoinconsensus_version() +unsigned int monacoinconsensus_version() { // Just use the API version for now - return BITCOINCONSENSUS_API_VER; + return MONACOINCONSENSUS_API_VER; } diff --git a/src/script/bitcoinconsensus.h b/src/script/monacoinconsensus.h similarity index 54% rename from src/script/bitcoinconsensus.h rename to src/script/monacoinconsensus.h index 1d2d5c23e..219964f36 100644 --- a/src/script/bitcoinconsensus.h +++ b/src/script/monacoinconsensus.h @@ -33,42 +33,42 @@ extern "C" { #endif -#define BITCOINCONSENSUS_API_VER 1 +#define MONACOINCONSENSUS_API_VER 1 -typedef enum bitcoinconsensus_error_t +typedef enum monacoinconsensus_error_t { - bitcoinconsensus_ERR_OK = 0, - bitcoinconsensus_ERR_TX_INDEX, - bitcoinconsensus_ERR_TX_SIZE_MISMATCH, - bitcoinconsensus_ERR_TX_DESERIALIZE, - bitcoinconsensus_ERR_AMOUNT_REQUIRED, -} bitcoinconsensus_error; + monacoinconsensus_ERR_OK = 0, + monacoinconsensus_ERR_TX_INDEX, + monacoinconsensus_ERR_TX_SIZE_MISMATCH, + monacoinconsensus_ERR_TX_DESERIALIZE, + monacoinconsensus_ERR_AMOUNT_REQUIRED, +} monacoinconsensus_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_NULLDUMMY = (1U << 4), // enforce NULLDUMMY (BIP147) - bitcoinconsensus_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9), // enable CHECKLOCKTIMEVERIFY (BIP65) - bitcoinconsensus_SCRIPT_FLAGS_VERIFY_CHECKSEQUENCEVERIFY = (1U << 10), // enable CHECKSEQUENCEVERIFY (BIP112) - bitcoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS = (1U << 11), // enable WITNESS (BIP141) + monacoinconsensus_SCRIPT_FLAGS_VERIFY_NONE = 0, + monacoinconsensus_SCRIPT_FLAGS_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts + monacoinconsensus_SCRIPT_FLAGS_VERIFY_DERSIG = (1U << 2), // enforce strict DER (BIP66) compliance + monacoinconsensus_SCRIPT_FLAGS_VERIFY_NULLDUMMY = (1U << 4), // enforce NULLDUMMY (BIP147) + monacoinconsensus_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9), // enable CHECKLOCKTIMEVERIFY (BIP65) + monacoinconsensus_SCRIPT_FLAGS_VERIFY_CHECKSEQUENCEVERIFY = (1U << 10), // enable CHECKSEQUENCEVERIFY (BIP112) + monacoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS = (1U << 11), // enable WITNESS (BIP141) }; /// 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 monacoinconsensus_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, monacoinconsensus_error* err); -EXPORT_SYMBOL int bitcoinconsensus_verify_script_with_amount(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount, +EXPORT_SYMBOL int monacoinconsensus_verify_script_with_amount(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount, const unsigned char *txTo , unsigned int txToLen, - unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err); + unsigned int nIn, unsigned int flags, monacoinconsensus_error* err); -EXPORT_SYMBOL unsigned int bitcoinconsensus_version(); +EXPORT_SYMBOL unsigned int monacoinconsensus_version(); #ifdef __cplusplus } // extern "C" diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 532921a72..5a2132198 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -16,7 +16,7 @@ #include "rpc/server.h" #if defined(HAVE_CONSENSUS_LIB) -#include "script/bitcoinconsensus.h" +#include "script/monacoinconsensus.h" #endif #include @@ -173,11 +173,11 @@ void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, const CScript #if defined(HAVE_CONSENSUS_LIB) CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << tx2; - if (flags & bitcoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS) { - BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script_with_amount(begin_ptr(scriptPubKey), scriptPubKey.size(), txCredit.vout[0].nValue, (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect, message); + if (flags & monacoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS) { + BOOST_CHECK_MESSAGE(monacoinconsensus_verify_script_with_amount(begin_ptr(scriptPubKey), scriptPubKey.size(), txCredit.vout[0].nValue, (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect, message); } else { - BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script_with_amount(begin_ptr(scriptPubKey), scriptPubKey.size(), 0, (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect, message); - 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(monacoinconsensus_verify_script_with_amount(begin_ptr(scriptPubKey), scriptPubKey.size(), 0, (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect, message); + BOOST_CHECK_MESSAGE(monacoinconsensus_verify_script(begin_ptr(scriptPubKey), scriptPubKey.size(), (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect,message); } #endif } -- 2.13.1