Rename bitcoinconsensus library to dashconsensus. (#1432)

All names containing bitcoinconsensus remaned to contain dashconsensus.
This is needed to avoid conflicts with real bitcoinconsensus library
shipped with Bitcoin Core.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
This commit is contained in:
Oleg Girko 2017-04-15 08:29:09 +01:00 committed by Holger Schinzel
parent 98990b683a
commit b40f8f333c
10 changed files with 63 additions and 63 deletions

2
.gitignore vendored
View File

@ -123,7 +123,7 @@ share/BitcoindComparisonTool.jar
.autotools .autotools
/doc/doxygen/ /doc/doxygen/
libbitcoinconsensus.pc libdashconsensus.pc
src/qt/dash-qt.bash src/qt/dash-qt.bash
qa/pull-tester/tests-config.sh qa/pull-tester/tests-config.sh

View File

@ -6,7 +6,7 @@ GZIP_ENV="-9n"
if BUILD_BITCOIN_LIBS if BUILD_BITCOIN_LIBS
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libbitcoinconsensus.pc pkgconfig_DATA = libdashconsensus.pc
endif endif
BITCOIND_BIN=$(top_builddir)/src/dashd$(EXEEXT) BITCOIND_BIN=$(top_builddir)/src/dashd$(EXEEXT)

View File

@ -789,7 +789,7 @@ AC_MSG_CHECKING([whether to build libraries])
AM_CONDITIONAL([BUILD_BITCOIN_LIBS], [test x$build_bitcoin_libs = xyes]) AM_CONDITIONAL([BUILD_BITCOIN_LIBS], [test x$build_bitcoin_libs = xyes])
if test x$build_bitcoin_libs = xyes; then 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_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([libdashconsensus.pc:libdashconsensus.pc.in])
fi fi
AC_MSG_RESULT($build_bitcoin_libs) AC_MSG_RESULT($build_bitcoin_libs)

View File

@ -1,21 +1,21 @@
Shared Libraries Shared Libraries
================ ================
## bitcoinconsensus ## dashconsensus
The purpose of this library is to make the verification functionality that is critical to Bitcoin's consensus available to other applications, e.g. to language bindings. The purpose of this library is to make the verification functionality that is critical to Dash's consensus available to other applications, e.g. to language bindings.
### API ### API
The interface is defined in the C header `bitcoinconsensus.h` located in `src/script/bitcoinconsensus.h`. The interface is defined in the C header `dashconsensus.h` located in `src/script/dashconsensus.h`.
#### Version #### Version
`bitcoinconsensus_version` returns an `unsigned int` with the the API version *(currently at an experimental `0`)*. `dashconsensus_version` returns an `unsigned int` with the the API version *(currently at an experimental `0`)*.
#### Script Validation #### Script Validation
`bitcoinconsensus_verify_script` returns an `int` with the status of the verification. It will be `1` if the input script correctly spends the previous output `scriptPubKey`. `dashconsensus_verify_script` returns an `int` with the status of the verification. It will be `1` if the input script correctly spends the previous output `scriptPubKey`.
##### Parameters ##### Parameters
- `const unsigned char *scriptPubKey` - The previous output script that encumbers spending. - `const unsigned char *scriptPubKey` - The previous output script that encumbers spending.
@ -24,18 +24,18 @@ The interface is defined in the C header `bitcoinconsensus.h` located in `src/s
- `unsigned int txToLen` - The number of bytes for the `txTo`. - `unsigned int txToLen` - The number of bytes for the `txTo`.
- `unsigned int nIn` - The index of the input in `txTo` that spends the `scriptPubKey`. - `unsigned int nIn` - The index of the input in `txTo` that spends the `scriptPubKey`.
- `unsigned int flags` - The script validation flags *(see below)*. - `unsigned int flags` - The script validation flags *(see below)*.
- `bitcoinconsensus_error* err` - Will have the error/success code for the operation *(see below)*. - `dashconsensus_error* err` - Will have the error/success code for the operation *(see below)*.
##### Script Flags ##### Script Flags
- `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NONE` - `dashconsensus_SCRIPT_FLAGS_VERIFY_NONE`
- `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_P2SH` - Evaluate P2SH ([BIP16](https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki)) subscripts - `dashconsensus_SCRIPT_FLAGS_VERIFY_P2SH` - Evaluate P2SH ([BIP16](https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki)) subscripts
- `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_DERSIG` - Enforce strict DER ([BIP66](https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki)) compliance - `dashconsensus_SCRIPT_FLAGS_VERIFY_DERSIG` - Enforce strict DER ([BIP66](https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki)) compliance
##### Errors ##### Errors
- `bitcoinconsensus_ERR_OK` - No errors with input parameters *(see the return value of `bitcoinconsensus_verify_script` for the verification status)* - `dashconsensus_ERR_OK` - No errors with input parameters *(see the return value of `dashconsensus_verify_script` for the verification status)*
- `bitcoinconsensus_ERR_TX_INDEX` - An invalid index for `txTo` - `dashconsensus_ERR_TX_INDEX` - An invalid index for `txTo`
- `bitcoinconsensus_ERR_TX_SIZE_MISMATCH` - `txToLen` did not match with the size of `txTo` - `dashconsensus_ERR_TX_SIZE_MISMATCH` - `txToLen` did not match with the size of `txTo`
- `bitcoinconsensus_ERR_DESERIALIZE` - An error deserializing `txTo` - `dashconsensus_ERR_DESERIALIZE` - An error deserializing `txTo`
### Example Implementations ### Example Implementations
- [NBitcoin](https://github.com/NicolasDorier/NBitcoin/blob/master/NBitcoin/Script.cs#L814) (.NET Bindings) - [NBitcoin](https://github.com/NicolasDorier/NBitcoin/blob/master/NBitcoin/Script.cs#L814) (.NET Bindings)

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: Bitcoin Core consensus library Name: Bitcoin Core consensus library
Description: Library for the Bitcoin consensus protocol. Description: Library for the Bitcoin consensus protocol.
Version: @PACKAGE_VERSION@ Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lbitcoinconsensus Libs: -L${libdir} -ldashconsensus
Cflags: -I${includedir} Cflags: -I${includedir}
Requires.private: libcrypto Requires.private: libcrypto

View File

@ -44,8 +44,8 @@ EXTRA_LIBRARIES += libbitcoin_zmq.a
endif endif
if BUILD_BITCOIN_LIBS if BUILD_BITCOIN_LIBS
lib_LTLIBRARIES = libbitcoinconsensus.la lib_LTLIBRARIES = libdashconsensus.la
LIBBITCOIN_CONSENSUS=libbitcoinconsensus.la LIBBITCOIN_CONSENSUS=libdashconsensus.la
else else
LIBBITCOIN_CONSENSUS= LIBBITCOIN_CONSENSUS=
endif endif
@ -454,10 +454,10 @@ dash_tx_LDADD = \
dash_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) dash_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
# #
# bitcoinconsensus library # # dashconsensus library #
if BUILD_BITCOIN_LIBS if BUILD_BITCOIN_LIBS
include_HEADERS = script/bitcoinconsensus.h include_HEADERS = script/dashconsensus.h
libbitcoinconsensus_la_SOURCES = \ libdashconsensus_la_SOURCES = \
crypto/hmac_sha512.cpp \ crypto/hmac_sha512.cpp \
crypto/ripemd160.cpp \ crypto/ripemd160.cpp \
crypto/sha1.cpp \ crypto/sha1.cpp \
@ -466,20 +466,20 @@ libbitcoinconsensus_la_SOURCES = \
hash.cpp \ hash.cpp \
primitives/transaction.cpp \ primitives/transaction.cpp \
pubkey.cpp \ pubkey.cpp \
script/bitcoinconsensus.cpp \ script/dashconsensus.cpp \
script/interpreter.cpp \ script/interpreter.cpp \
script/script.cpp \ script/script.cpp \
uint256.cpp \ uint256.cpp \
utilstrencodings.cpp utilstrencodings.cpp
if GLIBC_BACK_COMPAT if GLIBC_BACK_COMPAT
libbitcoinconsensus_la_SOURCES += compat/glibc_compat.cpp libdashconsensus_la_SOURCES += compat/glibc_compat.cpp
endif endif
libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) libdashconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1) libdashconsensus_la_LIBADD = $(LIBSECP256K1)
libbitcoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL libdashconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
libbitcoinconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libdashconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
endif endif
# #

View File

@ -58,8 +58,8 @@ EXTRA_LIBRARIES += libbitcoin_zmq.a
endif endif
if BUILD_BITCOIN_LIBS if BUILD_BITCOIN_LIBS
lib_LTLIBRARIES = libbitcoinconsensus.la lib_LTLIBRARIES = libdashconsensus.la
LIBBITCOIN_CONSENSUS=libbitcoinconsensus.la LIBBITCOIN_CONSENSUS=libdashconsensus.la
else else
LIBBITCOIN_CONSENSUS= LIBBITCOIN_CONSENSUS=
endif endif
@ -456,10 +456,10 @@ dash_tx_LDADD = \
dash_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) dash_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
# #
# bitcoinconsensus library # # dashconsensus library #
if BUILD_BITCOIN_LIBS if BUILD_BITCOIN_LIBS
include_HEADERS = script/bitcoinconsensus.h include_HEADERS = script/dashconsensus.h
libbitcoinconsensus_la_SOURCES = \ libdashconsensus_la_SOURCES = \
crypto/hmac_sha512.cpp \ crypto/hmac_sha512.cpp \
crypto/ripemd160.cpp \ crypto/ripemd160.cpp \
crypto/sha1.cpp \ crypto/sha1.cpp \
@ -468,20 +468,20 @@ libbitcoinconsensus_la_SOURCES = \
hash.cpp \ hash.cpp \
primitives/transaction.cpp \ primitives/transaction.cpp \
pubkey.cpp \ pubkey.cpp \
script/bitcoinconsensus.cpp \ script/dashconsensus.cpp \
script/interpreter.cpp \ script/interpreter.cpp \
script/script.cpp \ script/script.cpp \
uint256.cpp \ uint256.cpp \
utilstrencodings.cpp utilstrencodings.cpp
if GLIBC_BACK_COMPAT if GLIBC_BACK_COMPAT
libbitcoinconsensus_la_SOURCES += compat/glibc_compat.cpp libdashconsensus_la_SOURCES += compat/glibc_compat.cpp
endif endif
libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) libdashconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1) libdashconsensus_la_LIBADD = $(LIBSECP256K1)
libbitcoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL libdashconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
libbitcoinconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libdashconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
endif endif
# #

View File

@ -3,7 +3,7 @@
// Distributed under the MIT software license, see the accompanying // Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "bitcoinconsensus.h" #include "dashconsensus.h"
#include "primitives/transaction.h" #include "primitives/transaction.h"
#include "pubkey.h" #include "pubkey.h"
@ -54,7 +54,7 @@ private:
size_t m_remaining; size_t m_remaining;
}; };
inline int set_error(bitcoinconsensus_error* ret, bitcoinconsensus_error serror) inline int set_error(dashconsensus_error* ret, dashconsensus_error serror)
{ {
if (ret) if (ret)
*ret = serror; *ret = serror;
@ -69,29 +69,29 @@ struct ECCryptoClosure
ECCryptoClosure instance_of_eccryptoclosure; ECCryptoClosure instance_of_eccryptoclosure;
} }
int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int dashconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
const unsigned char *txTo , unsigned int txToLen, const unsigned char *txTo , unsigned int txToLen,
unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err) unsigned int nIn, unsigned int flags, dashconsensus_error* err)
{ {
try { try {
TxInputStream stream(SER_NETWORK, PROTOCOL_VERSION, txTo, txToLen); TxInputStream stream(SER_NETWORK, PROTOCOL_VERSION, txTo, txToLen);
CTransaction tx; CTransaction tx;
stream >> tx; stream >> tx;
if (nIn >= tx.vin.size()) if (nIn >= tx.vin.size())
return set_error(err, bitcoinconsensus_ERR_TX_INDEX); return set_error(err, dashconsensus_ERR_TX_INDEX);
if (tx.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION) != txToLen) if (tx.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION) != txToLen)
return set_error(err, bitcoinconsensus_ERR_TX_SIZE_MISMATCH); return set_error(err, dashconsensus_ERR_TX_SIZE_MISMATCH);
// Regardless of the verification result, the tx did not error. // Regardless of the verification result, the tx did not error.
set_error(err, bitcoinconsensus_ERR_OK); set_error(err, dashconsensus_ERR_OK);
return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), flags, TransactionSignatureChecker(&tx, nIn), NULL); return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), flags, TransactionSignatureChecker(&tx, nIn), NULL);
} catch (const std::exception&) { } catch (const std::exception&) {
return set_error(err, bitcoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing return set_error(err, dashconsensus_ERR_TX_DESERIALIZE); // Error deserializing
} }
} }
unsigned int bitcoinconsensus_version() unsigned int dashconsensus_version()
{ {
// Just use the API version for now // Just use the API version for now
return BITCOINCONSENSUS_API_VER; return BITCOINCONSENSUS_API_VER;

View File

@ -33,32 +33,32 @@ extern "C" {
#define BITCOINCONSENSUS_API_VER 0 #define BITCOINCONSENSUS_API_VER 0
typedef enum bitcoinconsensus_error_t typedef enum dashconsensus_error_t
{ {
bitcoinconsensus_ERR_OK = 0, dashconsensus_ERR_OK = 0,
bitcoinconsensus_ERR_TX_INDEX, dashconsensus_ERR_TX_INDEX,
bitcoinconsensus_ERR_TX_SIZE_MISMATCH, dashconsensus_ERR_TX_SIZE_MISMATCH,
bitcoinconsensus_ERR_TX_DESERIALIZE, dashconsensus_ERR_TX_DESERIALIZE,
} bitcoinconsensus_error; } dashconsensus_error;
/** Script verification flags */ /** Script verification flags */
enum enum
{ {
bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NONE = 0, dashconsensus_SCRIPT_FLAGS_VERIFY_NONE = 0,
bitcoinconsensus_SCRIPT_FLAGS_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts dashconsensus_SCRIPT_FLAGS_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts
bitcoinconsensus_SCRIPT_FLAGS_VERIFY_DERSIG = (1U << 2), // enforce strict DER (BIP66) compliance dashconsensus_SCRIPT_FLAGS_VERIFY_DERSIG = (1U << 2), // enforce strict DER (BIP66) compliance
bitcoinconsensus_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9), // enable CHECKLOCKTIMEVERIFY (BIP65) dashconsensus_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9), // enable CHECKLOCKTIMEVERIFY (BIP65)
}; };
/// Returns 1 if the input nIn of the serialized transaction pointed to by /// Returns 1 if the input nIn of the serialized transaction pointed to by
/// txTo correctly spends the scriptPubKey pointed to by scriptPubKey under /// txTo correctly spends the scriptPubKey pointed to by scriptPubKey under
/// the additional constraints specified by flags. /// the additional constraints specified by flags.
/// If not NULL, err will contain an error/success code for the operation /// 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 dashconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
const unsigned char *txTo , unsigned int txToLen, const unsigned char *txTo , unsigned int txToLen,
unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err); unsigned int nIn, unsigned int flags, dashconsensus_error* err);
EXPORT_SYMBOL unsigned int bitcoinconsensus_version(); EXPORT_SYMBOL unsigned int dashconsensus_version();
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"

View File

@ -15,7 +15,7 @@
#include "test/test_dash.h" #include "test/test_dash.h"
#if defined(HAVE_CONSENSUS_LIB) #if defined(HAVE_CONSENSUS_LIB)
#include "script/bitcoinconsensus.h" #include "script/dashconsensus.h"
#endif #endif
#include <fstream> #include <fstream>
@ -155,7 +155,7 @@ void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, int flags, co
#if defined(HAVE_CONSENSUS_LIB) #if defined(HAVE_CONSENSUS_LIB)
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << tx2; 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(dashconsensus_verify_script(begin_ptr(scriptPubKey), scriptPubKey.size(), (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect,message);
#endif #endif
} }