diff --git a/src/Makefile.am b/src/Makefile.am index 03d461449e..ef55725dff 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -240,6 +240,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 \ @@ -695,8 +696,7 @@ libelements_consensus_a_SOURCES = \ uint256.cpp \ uint256.h \ util/strencodings.cpp \ - util/strencodings.h \ - version.h + util/strencodings.h # # common # diff --git a/src/bench/rpc_blockchain.cpp b/src/bench/rpc_blockchain.cpp index ad6573c52c..4d21c00610 100644 --- a/src/bench/rpc_blockchain.cpp +++ b/src/bench/rpc_blockchain.cpp @@ -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 diff --git a/src/external_signer.cpp b/src/external_signer.cpp index 8cf57cde92..749bb5f74f 100644 --- a/src/external_signer.cpp +++ b/src/external_signer.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include diff --git a/src/net.h b/src/net.h index b753fd2ec1..a1bde07f2a 100644 --- a/src/net.h +++ b/src/net.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -30,7 +31,6 @@ #include #include #include -#include #include #include diff --git a/src/version.h b/src/node/protocol_version.h similarity index 86% rename from src/version.h rename to src/node/protocol_version.h index c2ebeecbfb..43c1bf6c5b 100644 --- a/src/version.h +++ b/src/node/protocol_version.h @@ -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 diff --git a/src/pegins.cpp b/src/pegins.cpp index 41387e0f30..48bdff2a00 100644 --- a/src/pegins.cpp +++ b/src/pegins.cpp @@ -202,7 +202,7 @@ static bool GetBlockAndTxFromMerkleBlock(uint256& block_hash, uint256& tx_hash, try { std::vector tx_hashes; std::vector tx_indices; - CDataStream merkle_block_stream(merkle_block_raw, SER_NETWORK, PROTOCOL_VERSION); + DataStream merkle_block_stream{merkle_block_raw}; merkle_block_stream >> TX_NO_WITNESS(merkle_block); block_hash = merkle_block.header.GetHash(); @@ -270,7 +270,7 @@ bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const std::vector< return false; } - CDataStream stream(stack[0], SER_NETWORK, PROTOCOL_VERSION); + DataStream stream{stack[0]}; CAmount value; try { stream >> value; @@ -514,13 +514,13 @@ CScriptWitness CreatePeginWitnessInner(const CAmount& value, const CAsset& asset } // Strip witness data for proof inclusion since only TXID-covered fields matters - CDataStream ss_tx(SER_NETWORK, PROTOCOL_VERSION); + DataStream ss_tx{}; ss_tx << TX_NO_WITNESS(tx_ref); const auto* ss_tx_ptr = UCharCast(ss_tx.data()); std::vector tx_data_stripped(ss_tx_ptr, ss_tx_ptr + ss_tx.size()); // Serialize merkle block - CDataStream ss_txout_proof(SER_NETWORK, PROTOCOL_VERSION); + DataStream ss_txout_proof{}; ss_txout_proof << TX_NO_WITNESS(merkle_block); const auto* ss_txout_ptr = UCharCast(ss_txout_proof.data()); std::vector txout_proof_bytes(ss_txout_ptr, ss_txout_ptr + ss_txout_proof.size()); @@ -552,7 +552,7 @@ bool DecomposePeginWitness(const CScriptWitness& witness, CAmount& value, CAsset if (stack.size() < 5) return false; - CDataStream stream(stack[0], SER_NETWORK, PROTOCOL_VERSION); + DataStream stream{stack[0]}; stream >> value; CAsset tmp_asset(stack[1]); diff --git a/src/policy/discount.h b/src/policy/discount.h index a1a2d117f5..340c3dd2b8 100644 --- a/src/policy/discount.h +++ b/src/policy/discount.h @@ -9,7 +9,6 @@ #include #include #include -#include /** * Calculate a smaller weight for discounted Confidential Transactions. diff --git a/src/psbt.cpp b/src/psbt.cpp index 0894326c27..20f3d52d88 100644 --- a/src/psbt.cpp +++ b/src/psbt.cpp @@ -12,7 +12,6 @@ #include