mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-22 05:19:42 +00:00
6960c81cbfa6208d4098353e53b313e13a21cb49 kernel: Remove Univalue from kernel library (TheCharlatan)
10eb3a9faa977371facacee937b2e6dc26f008e0 kernel: Split ParseSighashString (TheCharlatan)
Pull request description:
Besides the build system changes, this is a mostly move-only change for moving the few UniValue-related functions out of kernel files.
UniValue is not required by any of the kernel components and a JSON library should not need to be part of a consensus library.
ACKs for top commit:
achow101:
ACK 6960c81cbfa6208d4098353e53b313e13a21cb49
theuni:
Re-ACK 6960c81cbfa6208d4098353e53b313e13a21cb49
stickies-v:
re-ACK 6960c81cbf
Tree-SHA512: d92e4cb4e12134c94b517751bd746d39f9b8da528ec3a1c94aaedcce93274a3bae9277832e8a7c0243c13df0397ca70ae7bbb24ede200018c569f8d81103c1da
95 lines
2.5 KiB
C++
95 lines
2.5 KiB
C++
// Copyright (c) 2009-2022 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 <chainparams.h>
|
|
#include <rpc/client.h>
|
|
#include <rpc/util.h>
|
|
#include <test/fuzz/fuzz.h>
|
|
#include <util/chaintype.h>
|
|
|
|
#include <limits>
|
|
#include <string>
|
|
|
|
void initialize_parse_univalue()
|
|
{
|
|
SelectParams(ChainType::REGTEST);
|
|
}
|
|
|
|
FUZZ_TARGET(parse_univalue, .init = initialize_parse_univalue)
|
|
{
|
|
const std::string random_string(buffer.begin(), buffer.end());
|
|
bool valid = true;
|
|
const UniValue univalue = [&] {
|
|
UniValue uv;
|
|
if (!uv.read(random_string)) valid = false;
|
|
return valid ? uv : UniValue{};
|
|
}();
|
|
if (!valid) {
|
|
return;
|
|
}
|
|
try {
|
|
(void)ParseHashO(univalue, "A");
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseHashO(univalue, random_string);
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseHashV(univalue, "A");
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseHashV(univalue, random_string);
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseHexO(univalue, "A");
|
|
} catch (const UniValue&) {
|
|
}
|
|
try {
|
|
(void)ParseHexO(univalue, random_string);
|
|
} catch (const UniValue&) {
|
|
}
|
|
try {
|
|
(void)ParseHexV(univalue, "A");
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseHexV(univalue, random_string);
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseSighashString(univalue);
|
|
} catch (const UniValue&) {
|
|
}
|
|
try {
|
|
(void)AmountFromValue(univalue);
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
FlatSigningProvider provider;
|
|
(void)EvalDescriptorStringOrObject(univalue, provider);
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseConfirmTarget(univalue, std::numeric_limits<unsigned int>::max());
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
try {
|
|
(void)ParseDescriptorRange(univalue);
|
|
} catch (const UniValue&) {
|
|
} catch (const std::runtime_error&) {
|
|
}
|
|
}
|