diff options
author | TheCharlatan <seb.kung@gmail.com> | 2023-07-21 14:37:03 +0200 |
---|---|---|
committer | TheCharlatan <seb.kung@gmail.com> | 2023-07-25 17:40:07 +0200 |
commit | 6960c81cbfa6208d4098353e53b313e13a21cb49 (patch) | |
tree | ff176ff287825a64169c92cbb3d73d5eaa3929e7 /src | |
parent | 10eb3a9faa977371facacee937b2e6dc26f008e0 (diff) |
kernel: Remove Univalue from kernel library
It is not required by any of the kernel components.
A JSON library should not need to be part of a consensus library.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/bitcoin-tx.cpp | 10 | ||||
-rw-r--r-- | src/core_io.h | 1 | ||||
-rw-r--r-- | src/core_read.cpp | 11 | ||||
-rw-r--r-- | src/test/fuzz/parse_univalue.cpp | 7 |
5 files changed, 12 insertions, 21 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 4e9c161c57..a5c1261073 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -896,8 +896,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 diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 0c25ddf373..103d8885db 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -562,6 +562,16 @@ static CAmount AmountFromValue(const UniValue& value) return amount; } +static 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); +} + static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr) { int nHashType = SIGHASH_ALL; diff --git a/src/core_io.h b/src/core_io.h index a8c62da3f3..1f5ecbaea6 100644 --- a/src/core_io.h +++ b/src/core_io.h @@ -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); [[nodiscard]] util::Result<int> SighashFromStr(const std::string& sighash); // core_write.cpp diff --git a/src/core_read.cpp b/src/core_read.cpp index c40f04a824..dfabf3a0c2 100644 --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -10,7 +10,6 @@ #include <script/sign.h> #include <serialize.h> #include <streams.h> -#include <univalue.h> #include <util/result.h> #include <util/strencodings.h> #include <version.h> @@ -243,16 +242,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> SighashFromStr(const std::string& sighash) { static std::map<std::string, int> map_sighash_values = { diff --git a/src/test/fuzz/parse_univalue.cpp b/src/test/fuzz/parse_univalue.cpp index ac3e393401..c96cd53f5c 100644 --- a/src/test/fuzz/parse_univalue.cpp +++ b/src/test/fuzz/parse_univalue.cpp @@ -3,7 +3,6 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <chainparams.h> -#include <core_io.h> #include <rpc/client.h> #include <rpc/util.h> #include <test/fuzz/fuzz.h> @@ -58,12 +57,6 @@ FUZZ_TARGET_INIT(parse_univalue, initialize_parse_univalue) } catch (const UniValue&) { } try { - (void)ParseHexUV(univalue, "A"); - (void)ParseHexUV(univalue, random_string); - } catch (const UniValue&) { - } catch (const std::runtime_error&) { - } - try { (void)ParseHexV(univalue, "A"); } catch (const UniValue&) { } catch (const std::runtime_error&) { |