mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
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:
parent
98990b683a
commit
b40f8f333c
2
.gitignore
vendored
2
.gitignore
vendored
@ -123,7 +123,7 @@ share/BitcoindComparisonTool.jar
|
||||
.autotools
|
||||
/doc/doxygen/
|
||||
|
||||
libbitcoinconsensus.pc
|
||||
libdashconsensus.pc
|
||||
src/qt/dash-qt.bash
|
||||
qa/pull-tester/tests-config.sh
|
||||
|
||||
|
@ -6,7 +6,7 @@ GZIP_ENV="-9n"
|
||||
|
||||
if BUILD_BITCOIN_LIBS
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libbitcoinconsensus.pc
|
||||
pkgconfig_DATA = libdashconsensus.pc
|
||||
endif
|
||||
|
||||
BITCOIND_BIN=$(top_builddir)/src/dashd$(EXEEXT)
|
||||
|
@ -789,7 +789,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([libdashconsensus.pc:libdashconsensus.pc.in])
|
||||
fi
|
||||
AC_MSG_RESULT($build_bitcoin_libs)
|
||||
|
||||
|
@ -1,21 +1,21 @@
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
`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
|
||||
|
||||
`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
|
||||
- `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 nIn` - The index of the input in `txTo` that spends the `scriptPubKey`.
|
||||
- `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
|
||||
- `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NONE`
|
||||
- `bitcoinconsensus_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_NONE`
|
||||
- `dashconsensus_SCRIPT_FLAGS_VERIFY_P2SH` - Evaluate P2SH ([BIP16](https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki)) subscripts
|
||||
- `dashconsensus_SCRIPT_FLAGS_VERIFY_DERSIG` - Enforce strict DER ([BIP66](https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki)) compliance
|
||||
|
||||
##### Errors
|
||||
- `bitcoinconsensus_ERR_OK` - No errors with input parameters *(see the return value of `bitcoinconsensus_verify_script` for the verification status)*
|
||||
- `bitcoinconsensus_ERR_TX_INDEX` - An invalid index for `txTo`
|
||||
- `bitcoinconsensus_ERR_TX_SIZE_MISMATCH` - `txToLen` did not match with the size of `txTo`
|
||||
- `bitcoinconsensus_ERR_DESERIALIZE` - An error deserializing `txTo`
|
||||
- `dashconsensus_ERR_OK` - No errors with input parameters *(see the return value of `dashconsensus_verify_script` for the verification status)*
|
||||
- `dashconsensus_ERR_TX_INDEX` - An invalid index for `txTo`
|
||||
- `dashconsensus_ERR_TX_SIZE_MISMATCH` - `txToLen` did not match with the size of `txTo`
|
||||
- `dashconsensus_ERR_DESERIALIZE` - An error deserializing `txTo`
|
||||
|
||||
### Example Implementations
|
||||
- [NBitcoin](https://github.com/NicolasDorier/NBitcoin/blob/master/NBitcoin/Script.cs#L814) (.NET Bindings)
|
||||
|
@ -6,6 +6,6 @@ includedir=@includedir@
|
||||
Name: Bitcoin Core consensus library
|
||||
Description: Library for the Bitcoin consensus protocol.
|
||||
Version: @PACKAGE_VERSION@
|
||||
Libs: -L${libdir} -lbitcoinconsensus
|
||||
Libs: -L${libdir} -ldashconsensus
|
||||
Cflags: -I${includedir}
|
||||
Requires.private: libcrypto
|
@ -44,8 +44,8 @@ EXTRA_LIBRARIES += libbitcoin_zmq.a
|
||||
endif
|
||||
|
||||
if BUILD_BITCOIN_LIBS
|
||||
lib_LTLIBRARIES = libbitcoinconsensus.la
|
||||
LIBBITCOIN_CONSENSUS=libbitcoinconsensus.la
|
||||
lib_LTLIBRARIES = libdashconsensus.la
|
||||
LIBBITCOIN_CONSENSUS=libdashconsensus.la
|
||||
else
|
||||
LIBBITCOIN_CONSENSUS=
|
||||
endif
|
||||
@ -454,10 +454,10 @@ dash_tx_LDADD = \
|
||||
dash_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
|
||||
#
|
||||
|
||||
# bitcoinconsensus library #
|
||||
# dashconsensus library #
|
||||
if BUILD_BITCOIN_LIBS
|
||||
include_HEADERS = script/bitcoinconsensus.h
|
||||
libbitcoinconsensus_la_SOURCES = \
|
||||
include_HEADERS = script/dashconsensus.h
|
||||
libdashconsensus_la_SOURCES = \
|
||||
crypto/hmac_sha512.cpp \
|
||||
crypto/ripemd160.cpp \
|
||||
crypto/sha1.cpp \
|
||||
@ -466,20 +466,20 @@ libbitcoinconsensus_la_SOURCES = \
|
||||
hash.cpp \
|
||||
primitives/transaction.cpp \
|
||||
pubkey.cpp \
|
||||
script/bitcoinconsensus.cpp \
|
||||
script/dashconsensus.cpp \
|
||||
script/interpreter.cpp \
|
||||
script/script.cpp \
|
||||
uint256.cpp \
|
||||
utilstrencodings.cpp
|
||||
|
||||
if GLIBC_BACK_COMPAT
|
||||
libbitcoinconsensus_la_SOURCES += compat/glibc_compat.cpp
|
||||
libdashconsensus_la_SOURCES += compat/glibc_compat.cpp
|
||||
endif
|
||||
|
||||
libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
|
||||
libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1)
|
||||
libbitcoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
|
||||
libbitcoinconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
libdashconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
|
||||
libdashconsensus_la_LIBADD = $(LIBSECP256K1)
|
||||
libdashconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
|
||||
libdashconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
|
||||
endif
|
||||
#
|
||||
|
@ -58,8 +58,8 @@ EXTRA_LIBRARIES += libbitcoin_zmq.a
|
||||
endif
|
||||
|
||||
if BUILD_BITCOIN_LIBS
|
||||
lib_LTLIBRARIES = libbitcoinconsensus.la
|
||||
LIBBITCOIN_CONSENSUS=libbitcoinconsensus.la
|
||||
lib_LTLIBRARIES = libdashconsensus.la
|
||||
LIBBITCOIN_CONSENSUS=libdashconsensus.la
|
||||
else
|
||||
LIBBITCOIN_CONSENSUS=
|
||||
endif
|
||||
@ -456,10 +456,10 @@ dash_tx_LDADD = \
|
||||
dash_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
|
||||
#
|
||||
|
||||
# bitcoinconsensus library #
|
||||
# dashconsensus library #
|
||||
if BUILD_BITCOIN_LIBS
|
||||
include_HEADERS = script/bitcoinconsensus.h
|
||||
libbitcoinconsensus_la_SOURCES = \
|
||||
include_HEADERS = script/dashconsensus.h
|
||||
libdashconsensus_la_SOURCES = \
|
||||
crypto/hmac_sha512.cpp \
|
||||
crypto/ripemd160.cpp \
|
||||
crypto/sha1.cpp \
|
||||
@ -468,20 +468,20 @@ libbitcoinconsensus_la_SOURCES = \
|
||||
hash.cpp \
|
||||
primitives/transaction.cpp \
|
||||
pubkey.cpp \
|
||||
script/bitcoinconsensus.cpp \
|
||||
script/dashconsensus.cpp \
|
||||
script/interpreter.cpp \
|
||||
script/script.cpp \
|
||||
uint256.cpp \
|
||||
utilstrencodings.cpp
|
||||
|
||||
if GLIBC_BACK_COMPAT
|
||||
libbitcoinconsensus_la_SOURCES += compat/glibc_compat.cpp
|
||||
libdashconsensus_la_SOURCES += compat/glibc_compat.cpp
|
||||
endif
|
||||
|
||||
libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
|
||||
libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1)
|
||||
libbitcoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
|
||||
libbitcoinconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
libdashconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
|
||||
libdashconsensus_la_LIBADD = $(LIBSECP256K1)
|
||||
libdashconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
|
||||
libdashconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
|
||||
endif
|
||||
#
|
||||
|
@ -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 "dashconsensus.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(dashconsensus_error* ret, dashconsensus_error serror)
|
||||
{
|
||||
if (ret)
|
||||
*ret = serror;
|
||||
@ -69,29 +69,29 @@ struct 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,
|
||||
unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err)
|
||||
unsigned int nIn, unsigned int flags, dashconsensus_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, dashconsensus_ERR_TX_INDEX);
|
||||
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.
|
||||
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);
|
||||
} 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
|
||||
return BITCOINCONSENSUS_API_VER;
|
@ -33,32 +33,32 @@ extern "C" {
|
||||
|
||||
#define BITCOINCONSENSUS_API_VER 0
|
||||
|
||||
typedef enum bitcoinconsensus_error_t
|
||||
typedef enum dashconsensus_error_t
|
||||
{
|
||||
bitcoinconsensus_ERR_OK = 0,
|
||||
bitcoinconsensus_ERR_TX_INDEX,
|
||||
bitcoinconsensus_ERR_TX_SIZE_MISMATCH,
|
||||
bitcoinconsensus_ERR_TX_DESERIALIZE,
|
||||
} bitcoinconsensus_error;
|
||||
dashconsensus_ERR_OK = 0,
|
||||
dashconsensus_ERR_TX_INDEX,
|
||||
dashconsensus_ERR_TX_SIZE_MISMATCH,
|
||||
dashconsensus_ERR_TX_DESERIALIZE,
|
||||
} dashconsensus_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)
|
||||
dashconsensus_SCRIPT_FLAGS_VERIFY_NONE = 0,
|
||||
dashconsensus_SCRIPT_FLAGS_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts
|
||||
dashconsensus_SCRIPT_FLAGS_VERIFY_DERSIG = (1U << 2), // enforce strict DER (BIP66) compliance
|
||||
dashconsensus_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 dashconsensus_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, dashconsensus_error* err);
|
||||
|
||||
EXPORT_SYMBOL unsigned int bitcoinconsensus_version();
|
||||
EXPORT_SYMBOL unsigned int dashconsensus_version();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
@ -15,7 +15,7 @@
|
||||
#include "test/test_dash.h"
|
||||
|
||||
#if defined(HAVE_CONSENSUS_LIB)
|
||||
#include "script/bitcoinconsensus.h"
|
||||
#include "script/dashconsensus.h"
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
@ -155,7 +155,7 @@ void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, int flags, co
|
||||
#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(dashconsensus_verify_script(begin_ptr(scriptPubKey), scriptPubKey.size(), (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect,message);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user