Skip to content

Commit

Permalink
kernel: Remove Univalue from kernel library
Browse files Browse the repository at this point in the history
It is not required by any of the kernel components.

A JSON library should not need to be part of a consensus library.
  • Loading branch information
TheCharlatan committed Jul 21, 2023
1 parent 90094ea commit 05477b5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -898,8 +898,8 @@ if BUILD_BITCOIN_KERNEL_LIB
lib_LTLIBRARIES += $(LIBBITCOINKERNEL)

libbitcoinkernel_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) $(PTHREAD_FLAGS)
libbitcoinkernel_la_LIBADD = $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) $(LIBSECP256K1)
libbitcoinkernel_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)
libbitcoinkernel_la_LIBADD = $(LIBBITCOIN_CRYPTO) $(LIBLEVELDB) $(LIBMEMENV) $(LIBSECP256K1)
libbitcoinkernel_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS)

# libbitcoinkernel requires default symbol visibility, explicitly specify that
# here so that things still work even when user configures with
Expand Down
1 change: 1 addition & 0 deletions src/bitcoin-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <coins.h>
#include <common/args.h>
#include <common/system.h>
#include <common/univalue_helpers.h>
#include <compat/compat.h>
#include <consensus/amount.h>
#include <consensus/consensus.h>
Expand Down
11 changes: 11 additions & 0 deletions src/common/univalue_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@
#include <core_io.h>
#include <script/interpreter.h>
#include <util/result.h>
#include <util/strencodings.h>
#include <util/translation.h>

#include <stdexcept>
#include <string>

std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName)
{
std::string strHex;
if (v.isStr())
strHex = v.getValStr();
if (!IsHex(strHex))
throw std::runtime_error(strName + " must be hexadecimal string (not '" + strHex + "')");
return ParseHex(strHex);
}

int ParseSighashString(const UniValue& sighash)
{
if (sighash.isNull()) {
Expand Down
5 changes: 5 additions & 0 deletions src/common/univalue_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

#include <univalue.h> // IWYU pragma: export

#include <string>
#include <vector>

std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName);

int ParseSighashString(const UniValue& sighash);

#endif // BITCOIN_COMMON_UNIVALUE_HELPERS_H
1 change: 0 additions & 1 deletion src/core_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header);
* @see ParseHashV for an RPC-oriented version of this
*/
bool ParseHashStr(const std::string& strHex, uint256& result);
std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName);
util::Result<int> ParseSighash(const std::string& sighash);

// core_write.cpp
Expand Down
11 changes: 0 additions & 11 deletions src/core_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <script/sign.h>
#include <serialize.h>
#include <streams.h>
#include <univalue.h>
#include <util/strencodings.h>
#include <version.h>

Expand Down Expand Up @@ -242,16 +241,6 @@ bool ParseHashStr(const std::string& strHex, uint256& result)
return true;
}

std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName)
{
std::string strHex;
if (v.isStr())
strHex = v.getValStr();
if (!IsHex(strHex))
throw std::runtime_error(strName + " must be hexadecimal string (not '" + strHex + "')");
return ParseHex(strHex);
}

util::Result<int> ParseSighash(const std::string& strHashType)
{
static std::map<std::string, int> map_sighash_values = {
Expand Down

0 comments on commit 05477b5

Please sign in to comment.