mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
Merge bitcoin/bitcoin#28451: refactor: Remove unused SER_DISK, SER_NETWORK, CDataStream
fa98a097a3
Rename version.h to node/protocol_version.h (MarcoFalke)fa4fbd5816
Remove unused version.h include (MarcoFalke)fa0ae22ff2
Remove unused SER_NETWORK, SER_DISK (MarcoFalke)fae00fe9c2
Remove unused CDataStream (MarcoFalke)fa7eb4f5c3
fuzz: Drop unused version from fuzz input format (MarcoFalke) Pull request description: Seems odd to have code that is completely dead. Fix this by removing all of it. ACKs for top commit: sipa: utACKfa98a097a3
ajtowns: ACKfa98a097a3
ryanofsky: Seems odd to not code review ACKfa98a097a3
(looks good) Tree-SHA512: 9f1b9d9f92bda0512610bda6653e892756f637860362a9abfa439faab62de233cbad94b7df78ebacc160d9667aadfed4d9df08c0edefa618c040a049050fb913
This commit is contained in:
commit
ffb021612b
38 changed files with 69 additions and 138 deletions
|
@ -230,6 +230,7 @@ BITCOIN_CORE_H = \
|
|||
node/mini_miner.h \
|
||||
node/minisketchwrapper.h \
|
||||
node/peerman_args.h \
|
||||
node/protocol_version.h \
|
||||
node/psbt.h \
|
||||
node/transaction.h \
|
||||
node/txreconciliation.h \
|
||||
|
@ -658,8 +659,7 @@ libbitcoin_consensus_a_SOURCES = \
|
|||
uint256.cpp \
|
||||
uint256.h \
|
||||
util/strencodings.cpp \
|
||||
util/strencodings.h \
|
||||
version.h
|
||||
util/strencodings.h
|
||||
#
|
||||
|
||||
# common #
|
||||
|
|
|
@ -23,7 +23,7 @@ struct TestBlockAndIndex {
|
|||
|
||||
TestBlockAndIndex()
|
||||
{
|
||||
CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream stream{benchmark::data::block413567};
|
||||
std::byte a{0};
|
||||
stream.write({&a, 1}); // Prevent compaction
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <core_io.h>
|
||||
#include <psbt.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <netbase.h>
|
||||
#include <netgroup.h>
|
||||
#include <node/connection_types.h>
|
||||
#include <node/protocol_version.h>
|
||||
#include <policy/feerate.h>
|
||||
#include <protocol.h>
|
||||
#include <random.h>
|
||||
|
@ -30,7 +31,6 @@
|
|||
#include <util/check.h>
|
||||
#include <util/sock.h>
|
||||
#include <util/threadinterrupt.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright (c) 2012-2020 The Bitcoin Core developers
|
||||
// Copyright (c) 2012-present 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_VERSION_H
|
||||
#define BITCOIN_VERSION_H
|
||||
#ifndef BITCOIN_NODE_PROTOCOL_VERSION_H
|
||||
#define BITCOIN_NODE_PROTOCOL_VERSION_H
|
||||
|
||||
/**
|
||||
* network protocol versioning
|
||||
|
@ -35,4 +35,4 @@ static const int INVALID_CB_NO_BAN_VERSION = 70015;
|
|||
//! "wtxidrelay" command for wtxid-based relay starts with this version
|
||||
static const int WTXID_RELAY_VERSION = 70016;
|
||||
|
||||
#endif // BITCOIN_VERSION_H
|
||||
#endif // BITCOIN_NODE_PROTOCOL_VERSION_H
|
|
@ -8,7 +8,6 @@
|
|||
#include <script/signingprovider.h>
|
||||
#include <util/check.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <version.h>
|
||||
|
||||
|
||||
PartiallySignedTransaction::PartiallySignedTransaction(const CMutableTransaction& tx) : tx(tx)
|
||||
|
@ -546,7 +545,7 @@ bool DecodeBase64PSBT(PartiallySignedTransaction& psbt, const std::string& base6
|
|||
|
||||
bool DecodeRawPSBT(PartiallySignedTransaction& psbt, Span<const std::byte> tx_data, std::string& error)
|
||||
{
|
||||
CDataStream ss_data(tx_data, SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ss_data{tx_data};
|
||||
try {
|
||||
ss_data >> psbt;
|
||||
if (!ss_data.empty()) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <net_types.h> // For banmap_t
|
||||
#include <netbase.h>
|
||||
#include <node/context.h>
|
||||
#include <node/protocol_version.h>
|
||||
#include <policy/settings.h>
|
||||
#include <protocol.h>
|
||||
#include <rpc/blockchain.h>
|
||||
|
@ -29,7 +30,6 @@
|
|||
#include <util/time.h>
|
||||
#include <util/translation.h>
|
||||
#include <validation.h>
|
||||
#include <version.h>
|
||||
#include <warnings.h>
|
||||
|
||||
#include <optional>
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include <util/vector.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <numeric>
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -117,21 +117,8 @@ template<typename Stream> inline uint64_t ser_readdata64(Stream &s)
|
|||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Templates for serializing to anything that looks like a stream,
|
||||
// i.e. anything that supports .read(Span<std::byte>) and .write(Span<const std::byte>)
|
||||
//
|
||||
|
||||
class SizeComputer;
|
||||
|
||||
enum
|
||||
{
|
||||
// primary actions
|
||||
SER_NETWORK = (1 << 0),
|
||||
SER_DISK = (1 << 1),
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert any argument to a reference to X, maintaining constness.
|
||||
*
|
||||
|
@ -268,6 +255,9 @@ const Out& AsBase(const In& x)
|
|||
BASE_SERIALIZE_METHODS(cls) \
|
||||
FORMATTER_METHODS_PARAMS(cls, obj, paramcls, paramobj)
|
||||
|
||||
// Templates for serializing to anything that looks like a stream,
|
||||
// i.e. anything that supports .read(Span<std::byte>) and .write(Span<const std::byte>)
|
||||
//
|
||||
// clang-format off
|
||||
#ifndef CHAR_EQUALS_INT8
|
||||
template <typename Stream> void Serialize(Stream&, char) = delete; // char serialization forbidden. Use uint8_t or int8_t
|
||||
|
|
|
@ -279,42 +279,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class CDataStream : public DataStream
|
||||
{
|
||||
private:
|
||||
int nType;
|
||||
int nVersion;
|
||||
|
||||
public:
|
||||
explicit CDataStream(int nTypeIn, int nVersionIn)
|
||||
: nType{nTypeIn},
|
||||
nVersion{nVersionIn} {}
|
||||
|
||||
explicit CDataStream(Span<const uint8_t> sp, int type, int version) : CDataStream{AsBytes(sp), type, version} {}
|
||||
explicit CDataStream(Span<const value_type> sp, int nTypeIn, int nVersionIn)
|
||||
: DataStream{sp},
|
||||
nType{nTypeIn},
|
||||
nVersion{nVersionIn} {}
|
||||
|
||||
int GetType() const { return nType; }
|
||||
void SetVersion(int n) { nVersion = n; }
|
||||
int GetVersion() const { return nVersion; }
|
||||
|
||||
template <typename T>
|
||||
CDataStream& operator<<(const T& obj)
|
||||
{
|
||||
::Serialize(*this, obj);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
CDataStream& operator>>(T&& obj)
|
||||
{
|
||||
::Unserialize(*this, obj);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename IStream>
|
||||
class BitStreamReader
|
||||
{
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -13,7 +13,6 @@
|
|||
#include <test/fuzz/fuzz.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
@ -25,12 +24,9 @@ void initialize_block()
|
|||
|
||||
FUZZ_TARGET(block, .init = initialize_block)
|
||||
{
|
||||
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
||||
DataStream ds{buffer};
|
||||
CBlock block;
|
||||
try {
|
||||
int nVersion;
|
||||
ds >> nVersion;
|
||||
ds.SetVersion(nVersion);
|
||||
ds >> TX_WITH_WITNESS(block);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
return;
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <test/fuzz/util.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <undo.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <exception>
|
||||
#include <optional>
|
||||
|
@ -91,15 +90,15 @@ void DeserializeFromFuzzingInput(FuzzBufferType buffer, T&& obj, const P& params
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
CDataStream Serialize(const T& obj)
|
||||
DataStream Serialize(const T& obj)
|
||||
{
|
||||
CDataStream ds{SER_NETWORK, INIT_PROTO_VERSION};
|
||||
DataStream ds{};
|
||||
ds << obj;
|
||||
return ds;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Deserialize(CDataStream ds)
|
||||
T Deserialize(DataStream ds)
|
||||
{
|
||||
T obj;
|
||||
ds >> obj;
|
||||
|
@ -109,16 +108,7 @@ T Deserialize(CDataStream ds)
|
|||
template <typename T>
|
||||
void DeserializeFromFuzzingInput(FuzzBufferType buffer, T&& obj)
|
||||
{
|
||||
CDataStream ds{buffer, SER_NETWORK, INIT_PROTO_VERSION};
|
||||
{
|
||||
try {
|
||||
int version;
|
||||
ds >> version;
|
||||
ds.SetVersion(version);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
throw invalid_fuzzing_input_exception();
|
||||
}
|
||||
}
|
||||
DataStream ds{buffer};
|
||||
try {
|
||||
ds >> obj;
|
||||
} catch (const std::ios_base::failure&) {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <util/serfloat.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include <util/overflow.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/string.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
#include <util/time.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
#include <version.h>
|
||||
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdlib>
|
||||
|
@ -82,7 +80,7 @@ FUZZ_TARGET(process_message, .init = initialize_process_message)
|
|||
SetMockTime(mock_time);
|
||||
|
||||
// fuzzed_data_provider is fully consumed after this call, don't use it
|
||||
CDataStream random_bytes_data_stream{fuzzed_data_provider.ConsumeRemainingBytes<unsigned char>(), SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream random_bytes_data_stream{fuzzed_data_provider.ConsumeRemainingBytes<unsigned char>()};
|
||||
try {
|
||||
g_setup->m_node.peerman->ProcessMessage(p2p_node, random_message_type, random_bytes_data_stream,
|
||||
GetTime<std::chrono::microseconds>(), std::atomic<bool>{false});
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <script/script.h>
|
||||
#include <streams.h>
|
||||
#include <util/check.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
|
|
@ -254,7 +254,7 @@ std::string ConsumeScalarRPCArgument(FuzzedDataProvider& fuzzed_data_provider, b
|
|||
good_data = false;
|
||||
return;
|
||||
}
|
||||
CDataStream data_stream{SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream data_stream{};
|
||||
data_stream << TX_WITH_WITNESS(*opt_block);
|
||||
r = HexStr(data_stream);
|
||||
},
|
||||
|
@ -288,7 +288,7 @@ std::string ConsumeScalarRPCArgument(FuzzedDataProvider& fuzzed_data_provider, b
|
|||
good_data = false;
|
||||
return;
|
||||
}
|
||||
CDataStream data_stream{SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream data_stream{};
|
||||
data_stream << *opt_psbt;
|
||||
r = EncodeBase64(data_stream);
|
||||
},
|
||||
|
|
|
@ -36,14 +36,13 @@ FUZZ_TARGET(script_sign, .init = initialize_script_sign)
|
|||
const std::vector<uint8_t> key = ConsumeRandomLengthByteVector(fuzzed_data_provider, 128);
|
||||
|
||||
{
|
||||
DataStream stream{ConsumeDataStream(fuzzed_data_provider)};
|
||||
CDataStream random_data_stream{stream, SER_NETWORK, INIT_PROTO_VERSION}; // temporary copy, to be removed along with the version flag SERIALIZE_TRANSACTION_NO_WITNESS
|
||||
DataStream random_data_stream{ConsumeDataStream(fuzzed_data_provider)};
|
||||
std::map<CPubKey, KeyOriginInfo> hd_keypaths;
|
||||
try {
|
||||
DeserializeHDKeypaths(random_data_stream, key, hd_keypaths);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
}
|
||||
CDataStream serialized{SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream serialized{};
|
||||
SerializeHDKeypaths(serialized, hd_keypaths, CompactSizeWriter(fuzzed_data_provider.ConsumeIntegral<uint8_t>()));
|
||||
}
|
||||
|
||||
|
@ -60,7 +59,7 @@ FUZZ_TARGET(script_sign, .init = initialize_script_sign)
|
|||
}
|
||||
hd_keypaths[*pub_key] = *key_origin_info;
|
||||
}
|
||||
CDataStream serialized{SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream serialized{};
|
||||
try {
|
||||
SerializeHDKeypaths(serialized, hd_keypaths, CompactSizeWriter(fuzzed_data_provider.ConsumeIntegral<uint8_t>()));
|
||||
} catch (const std::ios_base::failure&) {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <util/chaintype.h>
|
||||
#include <util/rbf.h>
|
||||
#include <validation.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
@ -29,14 +28,7 @@ void initialize_transaction()
|
|||
|
||||
FUZZ_TARGET(transaction, .init = initialize_transaction)
|
||||
{
|
||||
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
||||
try {
|
||||
int nVersion;
|
||||
ds >> nVersion;
|
||||
ds.SetVersion(nVersion);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
return;
|
||||
}
|
||||
DataStream ds{buffer};
|
||||
bool valid_tx = true;
|
||||
const CTransaction tx = [&] {
|
||||
try {
|
||||
|
@ -47,12 +39,9 @@ FUZZ_TARGET(transaction, .init = initialize_transaction)
|
|||
}
|
||||
}();
|
||||
bool valid_mutable_tx = true;
|
||||
CDataStream ds_mtx(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
||||
DataStream ds_mtx{buffer};
|
||||
CMutableTransaction mutable_tx;
|
||||
try {
|
||||
int nVersion;
|
||||
ds_mtx >> nVersion;
|
||||
ds_mtx.SetVersion(nVersion);
|
||||
ds_mtx >> TX_WITH_WITNESS(mutable_tx);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
valid_mutable_tx = false;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <primitives/transaction.h>
|
||||
#include <streams.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <primitives/transaction.h>
|
||||
#include <streams.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <version.h>
|
||||
|
||||
FUZZ_TARGET(tx_out)
|
||||
{
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <util/overflow.h>
|
||||
#include <util/rbf.h>
|
||||
#include <util/time.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <uint256.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
@ -118,7 +117,7 @@ template <typename T>
|
|||
[[nodiscard]] inline std::optional<T> ConsumeDeserializable(FuzzedDataProvider& fuzzed_data_provider, const std::optional<size_t>& max_length = std::nullopt) noexcept
|
||||
{
|
||||
const std::vector<uint8_t> buffer = ConsumeRandomLengthByteVector(fuzzed_data_provider, max_length);
|
||||
CDataStream ds{buffer, SER_NETWORK, INIT_PROTO_VERSION};
|
||||
DataStream ds{buffer};
|
||||
T obj;
|
||||
try {
|
||||
ds >> obj;
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
#include <compat/compat.h>
|
||||
#include <netaddress.h>
|
||||
#include <node/protocol_version.h>
|
||||
#include <protocol.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <test/util/net.h>
|
||||
#include <util/sock.h>
|
||||
#include <util/time.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
#include <version.h>
|
||||
|
||||
FUZZ_TARGET(utxo_total_supply)
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <netbase.h>
|
||||
#include <netgroup.h>
|
||||
#include <node/connection_types.h>
|
||||
#include <node/protocol_version.h>
|
||||
#include <protocol.h>
|
||||
#include <random.h>
|
||||
#include <test/util/logging.h>
|
||||
|
@ -18,7 +19,6 @@
|
|||
#include <test/util/setup_common.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <netaddress.h>
|
||||
#include <netbase.h>
|
||||
#include <netmessagemaker.h>
|
||||
#include <node/protocol_version.h>
|
||||
#include <serialize.h>
|
||||
#include <span.h>
|
||||
#include <streams.h>
|
||||
|
@ -22,7 +23,6 @@
|
|||
#include <util/strencodings.h>
|
||||
#include <util/string.h>
|
||||
#include <validation.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
@ -858,13 +858,13 @@ BOOST_AUTO_TEST_CASE(initial_advertise_from_version_message)
|
|||
|
||||
const auto msg_version =
|
||||
NetMsg::Make(NetMsgType::VERSION, PROTOCOL_VERSION, services, time, services, CAddress::V1_NETWORK(peer_us));
|
||||
CDataStream msg_version_stream{msg_version.data, SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream msg_version_stream{msg_version.data};
|
||||
|
||||
m_node.peerman->ProcessMessage(
|
||||
peer, NetMsgType::VERSION, msg_version_stream, time_received_dummy, interrupt_dummy);
|
||||
|
||||
const auto msg_verack = NetMsg::Make(NetMsgType::VERACK);
|
||||
CDataStream msg_verack_stream{msg_verack.data, SER_NETWORK, PROTOCOL_VERSION};
|
||||
DataStream msg_verack_stream{msg_verack.data};
|
||||
|
||||
// Will set peer.fSuccessfullyConnected to true (necessary in SendMessages()).
|
||||
m_node.peerman->ProcessMessage(
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <test/util/setup_common.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/translation.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <uint256.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <streams.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <uint256.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -17,7 +17,6 @@
|
|||
#include <util/fs.h>
|
||||
#include <util/string.h>
|
||||
#include <util/vector.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include <wallet/rpc/util.h>
|
||||
#include <wallet/spend.h>
|
||||
#include <wallet/wallet.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
|
|
|
@ -32,12 +32,16 @@ BOOST_AUTO_TEST_CASE(psbt_updater_test)
|
|||
m_wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
||||
|
||||
// Create prevtxs and add to wallet
|
||||
CDataStream s_prev_tx1(ParseHex("0200000000010158e87a21b56daf0c23be8e7070456c336f7cbaa5c8757924f545887bb2abdd7501000000171600145f275f436b09a8cc9a2eb2a2f528485c68a56323feffffff02d8231f1b0100000017a914aed962d6654f9a2b36608eb9d64d2b260db4f1118700c2eb0b0000000017a914b7f5faf40e3d40a5a459b1db3535f2b72fa921e88702483045022100a22edcc6e5bc511af4cc4ae0de0fcd75c7e04d8c1c3a8aa9d820ed4b967384ec02200642963597b9b1bc22c75e9f3e117284a962188bf5e8a74c895089046a20ad770121035509a48eb623e10aace8bfd0212fdb8a8e5af3c94b0b133b95e114cab89e4f7965000000"), SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream s_prev_tx1{
|
||||
ParseHex("0200000000010158e87a21b56daf0c23be8e7070456c336f7cbaa5c8757924f545887bb2abdd7501000000171600145f275f436b09a8cc9a2eb2a2f528485c68a56323feffffff02d8231f1b0100000017a914aed962d6654f9a2b36608eb9d64d2b260db4f1118700c2eb0b0000000017a914b7f5faf40e3d40a5a459b1db3535f2b72fa921e88702483045022100a22edcc6e5bc511af4cc4ae0de0fcd75c7e04d8c1c3a8aa9d820ed4b967384ec02200642963597b9b1bc22c75e9f3e117284a962188bf5e8a74c895089046a20ad770121035509a48eb623e10aace8bfd0212fdb8a8e5af3c94b0b133b95e114cab89e4f7965000000"),
|
||||
};
|
||||
CTransactionRef prev_tx1;
|
||||
s_prev_tx1 >> TX_WITH_WITNESS(prev_tx1);
|
||||
m_wallet.mapWallet.emplace(std::piecewise_construct, std::forward_as_tuple(prev_tx1->GetHash()), std::forward_as_tuple(prev_tx1, TxStateInactive{}));
|
||||
|
||||
CDataStream s_prev_tx2(ParseHex("0200000001aad73931018bd25f84ae400b68848be09db706eac2ac18298babee71ab656f8b0000000048473044022058f6fc7c6a33e1b31548d481c826c015bd30135aad42cd67790dab66d2ad243b02204a1ced2604c6735b6393e5b41691dd78b00f0c5942fb9f751856faa938157dba01feffffff0280f0fa020000000017a9140fb9463421696b82c833af241c78c17ddbde493487d0f20a270100000017a91429ca74f8a08f81999428185c97b5d852e4063f618765000000"), SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream s_prev_tx2{
|
||||
ParseHex("0200000001aad73931018bd25f84ae400b68848be09db706eac2ac18298babee71ab656f8b0000000048473044022058f6fc7c6a33e1b31548d481c826c015bd30135aad42cd67790dab66d2ad243b02204a1ced2604c6735b6393e5b41691dd78b00f0c5942fb9f751856faa938157dba01feffffff0280f0fa020000000017a9140fb9463421696b82c833af241c78c17ddbde493487d0f20a270100000017a91429ca74f8a08f81999428185c97b5d852e4063f618765000000"),
|
||||
};
|
||||
CTransactionRef prev_tx2;
|
||||
s_prev_tx2 >> TX_WITH_WITNESS(prev_tx2);
|
||||
m_wallet.mapWallet.emplace(std::piecewise_construct, std::forward_as_tuple(prev_tx2->GetHash()), std::forward_as_tuple(prev_tx2, TxStateInactive{}));
|
||||
|
@ -49,7 +53,9 @@ BOOST_AUTO_TEST_CASE(psbt_updater_test)
|
|||
|
||||
// Call FillPSBT
|
||||
PartiallySignedTransaction psbtx;
|
||||
CDataStream ssData(ParseHex("70736274ff01009a020000000258e87a21b56daf0c23be8e7070456c336f7cbaa5c8757924f545887bb2abdd750000000000ffffffff838d0427d0ec650a68aa46bb0b098aea4422c071b2ca78352a077959d07cea1d0100000000ffffffff0270aaf00800000000160014d85c2b71d0060b09c9886aeb815e50991dda124d00e1f5050000000016001400aea9a2e5f0f876a588df5546e8742d1d87008f000000000000000000"), SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssData{
|
||||
ParseHex("70736274ff01009a020000000258e87a21b56daf0c23be8e7070456c336f7cbaa5c8757924f545887bb2abdd750000000000ffffffff838d0427d0ec650a68aa46bb0b098aea4422c071b2ca78352a077959d07cea1d0100000000ffffffff0270aaf00800000000160014d85c2b71d0060b09c9886aeb815e50991dda124d00e1f5050000000016001400aea9a2e5f0f876a588df5546e8742d1d87008f000000000000000000"),
|
||||
};
|
||||
ssData >> psbtx;
|
||||
|
||||
// Fill transaction with our data
|
||||
|
|
|
@ -17,11 +17,11 @@ BOOST_FIXTURE_TEST_SUITE(walletdb_tests, BasicTestingSetup)
|
|||
BOOST_AUTO_TEST_CASE(walletdb_readkeyvalue)
|
||||
{
|
||||
/**
|
||||
* When ReadKeyValue() reads from either a "key" or "wkey" it first reads the CDataStream steam into a
|
||||
* When ReadKeyValue() reads from either a "key" or "wkey" it first reads the DataStream into a
|
||||
* CPrivKey or CWalletKey respectively and then reads a hash of the pubkey and privkey into a uint256.
|
||||
* Wallets from 0.8 or before do not store the pubkey/privkey hash, trying to read the hash from old
|
||||
* wallets throws an exception, for backwards compatibility this read is wrapped in a try block to
|
||||
* silently fail. The test here makes sure the type of exception thrown from CDataStream::read()
|
||||
* silently fail. The test here makes sure the type of exception thrown from DataStream::read()
|
||||
* matches the type we expect, otherwise we need to update the "key"/"wkey" exception type caught.
|
||||
*/
|
||||
DataStream ssValue{};
|
||||
|
|
|
@ -104,7 +104,7 @@ bool HasAnyRecordOfType(WalletDatabase& db, const std::string& key)
|
|||
template<typename... Args>
|
||||
SerializeData MakeSerializeData(const Args&... args)
|
||||
{
|
||||
CDataStream s(0, 0);
|
||||
DataStream s{};
|
||||
SerializeMany(s, args...);
|
||||
return {s.begin(), s.end()};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue