Compare commits
No commits in common. "a8c3a2f4f23bf3fd632dce34fc6c934b8b55dae7" and "0a9c16ded51d8c77aefceba2bd83447bb584b752" have entirely different histories.
a8c3a2f4f2
...
0a9c16ded5
2
.gitignore
vendored
2
.gitignore
vendored
@ -123,7 +123,7 @@ share/BitcoindComparisonTool.jar
|
||||
.autotools
|
||||
/doc/doxygen/
|
||||
|
||||
libneobytesconsensus.pc
|
||||
libbitcoinconsensus.pc
|
||||
src/qt/neobytes-qt.bash
|
||||
qa/pull-tester/tests-config.sh
|
||||
|
||||
|
6
INSTALL
6
INSTALL
@ -1,5 +1,5 @@
|
||||
Building NeoBytes
|
||||
=================
|
||||
|
||||
See doc/build-*.md for instructions on building neobytesd,
|
||||
the intended-for-services, no-graphical-interface, reference
|
||||
implementation of NeoBytes.
|
||||
See doc/build-*.md for instructions on building the various
|
||||
elements of the NeoBytes Core reference implementation of NeoBytes.
|
||||
|
@ -6,7 +6,7 @@ GZIP_ENV="-9n"
|
||||
|
||||
if BUILD_BITCOIN_LIBS
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libneobytesconsensus.pc
|
||||
pkgconfig_DATA = libbitcoinconsensus.pc
|
||||
endif
|
||||
|
||||
BITCOIND_BIN=$(top_builddir)/src/neobytesd$(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([libneobytesconsensus.pc:libneobytesconsensus.pc.in])
|
||||
AC_CONFIG_FILES([libbitcoinconsensus.pc:libbitcoinconsensus.pc.in])
|
||||
fi
|
||||
AC_MSG_RESULT($build_bitcoin_libs)
|
||||
|
||||
|
@ -3,9 +3,9 @@ exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: NeoBytes Core consensus library
|
||||
Description: Library for the NeoBytes consensus protocol.
|
||||
Name: Bitcoin Core consensus library
|
||||
Description: Library for the Bitcoin consensus protocol.
|
||||
Version: @PACKAGE_VERSION@
|
||||
Libs: -L${libdir} -lneobytesconsensus
|
||||
Libs: -L${libdir} -lbitcoinconsensus
|
||||
Cflags: -I${includedir}
|
||||
Requires.private: libcrypto
|
@ -44,8 +44,8 @@ EXTRA_LIBRARIES += libbitcoin_zmq.a
|
||||
endif
|
||||
|
||||
if BUILD_BITCOIN_LIBS
|
||||
lib_LTLIBRARIES = libneobytesconsensus.la
|
||||
LIBBITCOIN_CONSENSUS=libneobytesconsensus.la
|
||||
lib_LTLIBRARIES = libbitcoinconsensus.la
|
||||
LIBBITCOIN_CONSENSUS=libbitcoinconsensus.la
|
||||
else
|
||||
LIBBITCOIN_CONSENSUS=
|
||||
endif
|
||||
@ -454,10 +454,10 @@ neobytes_tx_LDADD = \
|
||||
neobytes_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
|
||||
#
|
||||
|
||||
# neobytescoinconsensus library #
|
||||
# bitcoinconsensus library #
|
||||
if BUILD_BITCOIN_LIBS
|
||||
include_HEADERS = script/neobytescoinconsensus.h
|
||||
libneobytesconsensus_la_SOURCES = \
|
||||
include_HEADERS = script/bitcoinconsensus.h
|
||||
libbitcoinconsensus_la_SOURCES = \
|
||||
crypto/hmac_sha512.cpp \
|
||||
crypto/ripemd160.cpp \
|
||||
crypto/sha1.cpp \
|
||||
@ -466,20 +466,20 @@ libneobytesconsensus_la_SOURCES = \
|
||||
hash.cpp \
|
||||
primitives/transaction.cpp \
|
||||
pubkey.cpp \
|
||||
script/neobytescoinconsensus.cpp \
|
||||
script/bitcoinconsensus.cpp \
|
||||
script/interpreter.cpp \
|
||||
script/script.cpp \
|
||||
uint256.cpp \
|
||||
utilstrencodings.cpp
|
||||
|
||||
if GLIBC_BACK_COMPAT
|
||||
libneobytesconsensus_la_SOURCES += compat/glibc_compat.cpp
|
||||
libbitcoinconsensus_la_SOURCES += compat/glibc_compat.cpp
|
||||
endif
|
||||
|
||||
libneobytesconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
|
||||
libneobytesconsensus_la_LIBADD = $(LIBSECP256K1)
|
||||
libneobytesconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
|
||||
libneobytesconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
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)
|
||||
|
||||
endif
|
||||
#
|
||||
|
@ -58,8 +58,8 @@ EXTRA_LIBRARIES += libbitcoin_zmq.a
|
||||
endif
|
||||
|
||||
if BUILD_BITCOIN_LIBS
|
||||
lib_LTLIBRARIES = libneobytesconsensus.la
|
||||
LIBBITCOIN_CONSENSUS=libneobytesconsensus.la
|
||||
lib_LTLIBRARIES = libbitcoinconsensus.la
|
||||
LIBBITCOIN_CONSENSUS=libbitcoinconsensus.la
|
||||
else
|
||||
LIBBITCOIN_CONSENSUS=
|
||||
endif
|
||||
@ -456,10 +456,10 @@ neobytes_tx_LDADD = \
|
||||
neobytes_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
|
||||
#
|
||||
|
||||
# neobytescoinconsensus library #
|
||||
# bitcoinconsensus library #
|
||||
if BUILD_BITCOIN_LIBS
|
||||
include_HEADERS = script/neobytescoinconsensus.h
|
||||
libneobytesconsensus_la_SOURCES = \
|
||||
include_HEADERS = script/bitcoinconsensus.h
|
||||
libbitcoinconsensus_la_SOURCES = \
|
||||
crypto/hmac_sha512.cpp \
|
||||
crypto/ripemd160.cpp \
|
||||
crypto/sha1.cpp \
|
||||
@ -468,20 +468,20 @@ libneobytesconsensus_la_SOURCES = \
|
||||
hash.cpp \
|
||||
primitives/transaction.cpp \
|
||||
pubkey.cpp \
|
||||
script/neobytescoinconsensus.cpp \
|
||||
script/bitcoinconsensus.cpp \
|
||||
script/interpreter.cpp \
|
||||
script/script.cpp \
|
||||
uint256.cpp \
|
||||
utilstrencodings.cpp
|
||||
|
||||
if GLIBC_BACK_COMPAT
|
||||
libneobytesconsensus_la_SOURCES += compat/glibc_compat.cpp
|
||||
libbitcoinconsensus_la_SOURCES += compat/glibc_compat.cpp
|
||||
endif
|
||||
|
||||
libneobytesconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
|
||||
libneobytesconsensus_la_LIBADD = $(LIBSECP256K1)
|
||||
libneobytesconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
|
||||
libneobytesconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
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)
|
||||
|
||||
endif
|
||||
#
|
||||
|
@ -1,98 +0,0 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "neobytescoinconsensus.h"
|
||||
|
||||
#include "primitives/transaction.h"
|
||||
#include "pubkey.h"
|
||||
#include "script/interpreter.h"
|
||||
#include "version.h"
|
||||
|
||||
namespace {
|
||||
|
||||
/** A class that deserializes a single CTransaction one time. */
|
||||
class TxInputStream
|
||||
{
|
||||
public:
|
||||
TxInputStream(int nTypeIn, int nVersionIn, const unsigned char *txTo, size_t txToLen) :
|
||||
m_type(nTypeIn),
|
||||
m_version(nVersionIn),
|
||||
m_data(txTo),
|
||||
m_remaining(txToLen)
|
||||
{}
|
||||
|
||||
TxInputStream& read(char* pch, size_t nSize)
|
||||
{
|
||||
if (nSize > m_remaining)
|
||||
throw std::ios_base::failure(std::string(__func__) + ": end of data");
|
||||
|
||||
if (pch == NULL)
|
||||
throw std::ios_base::failure(std::string(__func__) + ": bad destination buffer");
|
||||
|
||||
if (m_data == NULL)
|
||||
throw std::ios_base::failure(std::string(__func__) + ": bad source buffer");
|
||||
|
||||
memcpy(pch, m_data, nSize);
|
||||
m_remaining -= nSize;
|
||||
m_data += nSize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
TxInputStream& operator>>(T& obj)
|
||||
{
|
||||
::Unserialize(*this, obj, m_type, m_version);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
const int m_type;
|
||||
const int m_version;
|
||||
const unsigned char* m_data;
|
||||
size_t m_remaining;
|
||||
};
|
||||
|
||||
inline int set_error(neobytesconsensus_error* ret, neobytesconsensus_error serror)
|
||||
{
|
||||
if (ret)
|
||||
*ret = serror;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct ECCryptoClosure
|
||||
{
|
||||
ECCVerifyHandle handle;
|
||||
};
|
||||
|
||||
ECCryptoClosure instance_of_eccryptoclosure;
|
||||
}
|
||||
|
||||
int neobytesconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
|
||||
const unsigned char *txTo , unsigned int txToLen,
|
||||
unsigned int nIn, unsigned int flags, neobytesconsensus_error* err)
|
||||
{
|
||||
try {
|
||||
TxInputStream stream(SER_NETWORK, PROTOCOL_VERSION, txTo, txToLen);
|
||||
CTransaction tx;
|
||||
stream >> tx;
|
||||
if (nIn >= tx.vin.size())
|
||||
return set_error(err, neobytesconsensus_ERR_TX_INDEX);
|
||||
if (tx.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION) != txToLen)
|
||||
return set_error(err, neobytesconsensus_ERR_TX_SIZE_MISMATCH);
|
||||
|
||||
// Regardless of the verification result, the tx did not error.
|
||||
set_error(err, neobytesconsensus_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, neobytesconsensus_ERR_TX_DESERIALIZE); // Error deserializing
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int neobytesconsensus_version()
|
||||
{
|
||||
// Just use the API version for now
|
||||
return NEOBYTESCONSENSUS_API_VER;
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_NEOBYTESCONSENSUS_H
|
||||
#define BITCOIN_NEOBYTESCONSENSUS_H
|
||||
|
||||
#if defined(BUILD_BITCOIN_INTERNAL) && defined(HAVE_CONFIG_H)
|
||||
#include "config/neobytes-config.h"
|
||||
#if defined(_WIN32)
|
||||
#if defined(DLL_EXPORT)
|
||||
#if defined(HAVE_FUNC_ATTRIBUTE_DLLEXPORT)
|
||||
#define EXPORT_SYMBOL __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT_SYMBOL
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(HAVE_FUNC_ATTRIBUTE_VISIBILITY)
|
||||
#define EXPORT_SYMBOL __attribute__ ((visibility ("default")))
|
||||
#endif
|
||||
#elif defined(MSC_VER) && !defined(STATIC_LIBNEOBYTESCONSENSUS)
|
||||
#define EXPORT_SYMBOL __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#ifndef EXPORT_SYMBOL
|
||||
#define EXPORT_SYMBOL
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define NEOBYTESCONSENSUS_API_VER 0
|
||||
|
||||
typedef enum neobytesconsensus_error_t
|
||||
{
|
||||
neobytesconsensus_ERR_OK = 0,
|
||||
neobytesconsensus_ERR_TX_INDEX,
|
||||
neobytesconsensus_ERR_TX_SIZE_MISMATCH,
|
||||
neobytesconsensus_ERR_TX_DESERIALIZE,
|
||||
} neobytesconsensus_error;
|
||||
|
||||
/** Script verification flags */
|
||||
enum
|
||||
{
|
||||
neobytesconsensus_SCRIPT_FLAGS_VERIFY_NONE = 0,
|
||||
neobytesconsensus_SCRIPT_FLAGS_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts
|
||||
neobytesconsensus_SCRIPT_FLAGS_VERIFY_DERSIG = (1U << 2), // enforce strict DER (BIP66) compliance
|
||||
neobytesconsensus_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 neobytesconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
|
||||
const unsigned char *txTo , unsigned int txToLen,
|
||||
unsigned int nIn, unsigned int flags, neobytesconsensus_error* err);
|
||||
|
||||
EXPORT_SYMBOL unsigned int neobytesconsensus_version();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#undef EXPORT_SYMBOL
|
||||
|
||||
#endif // BITCOIN_NEOBYTESCONSENSUS_H
|
Loading…
Reference in New Issue
Block a user