diff --git a/src/bls/bls.h b/src/bls/bls.h index 82abc2c6de04..59e6af0319e1 100644 --- a/src/bls/bls.h +++ b/src/bls/bls.h @@ -554,7 +554,7 @@ class CBLSLazyWrapper hash.SetNull(); } if (hash.IsNull()) { - CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); + HashWriter ss{}; ss.write(MakeByteSpan(vecBytes)); hash = ss.GetHash(); } diff --git a/src/chain.h b/src/chain.h index a67a88641e9f..7b82ea1c8762 100644 --- a/src/chain.h +++ b/src/chain.h @@ -372,6 +372,14 @@ const CBlockIndex* LastCommonAncestor(const CBlockIndex* pa, const CBlockIndex* /** Used to marshal pointers into hashes for db storage. */ class CDiskBlockIndex : public CBlockIndex { + /** Historically CBlockLocator's version field has been written to disk + * streams as the client version, but the value has never been used. + * + * Hard-code to the highest client version ever written. + * SerParams can be used if the field requires any meaning in the future. + **/ + static constexpr int DUMMY_VERSION = 240100; + public: uint256 hash; uint256 hashPrev; @@ -391,8 +399,8 @@ class CDiskBlockIndex : public CBlockIndex SERIALIZE_METHODS(CDiskBlockIndex, obj) { LOCK(::cs_main); - int _nVersion = s.GetVersion(); - if (!(s.GetType() & SER_GETHASH)) READWRITE(VARINT_MODE(_nVersion, VarIntMode::NONNEGATIVE_SIGNED)); + int _nVersion = DUMMY_VERSION; + READWRITE(VARINT_MODE(_nVersion, VarIntMode::NONNEGATIVE_SIGNED)); READWRITE(VARINT_MODE(obj.nHeight, VarIntMode::NONNEGATIVE_SIGNED)); READWRITE(VARINT(obj.nStatus)); diff --git a/src/chainlock/clsig.cpp b/src/chainlock/clsig.cpp index 9313824eb007..9c3750ae7b7f 100644 --- a/src/chainlock/clsig.cpp +++ b/src/chainlock/clsig.cpp @@ -89,7 +89,7 @@ class DecodedSignatureCache // process-wide scheme flag, including its opposite-scheme rejection. The // flag is part of the key so a transient value cannot leak into later calls. const bool legacy = bls::bls_legacy_scheme.load(); - const uint256 key = (CHashWriter(SER_GETHASH, 0) << Span{bytes} << legacy).GetHash(); + const uint256 key = (HashWriter{} << Span{bytes} << legacy).GetHash(); CBLSSignature sig; { LOCK(m_mutex); diff --git a/src/coinjoin/coinjoin.cpp b/src/coinjoin/coinjoin.cpp index 5fe5de73a1ab..8c5d985ec051 100644 --- a/src/coinjoin/coinjoin.cpp +++ b/src/coinjoin/coinjoin.cpp @@ -42,7 +42,7 @@ bool CCoinJoinEntry::AddScriptSig(const CTxIn& txin) uint256 CCoinJoinQueue::GetSignatureHash() const { - return SerializeHash(*this, SER_GETHASH, PROTOCOL_VERSION); + return SerializeSigHash(*this); } uint256 CCoinJoinQueue::GetHash() const { return SerializeHash(*this, SER_NETWORK, PROTOCOL_VERSION); } @@ -76,7 +76,7 @@ bool CCoinJoinQueue::IsTimeOutOfBounds() const uint256 CCoinJoinBroadcastTx::GetSignatureHash() const { - return SerializeHash(*this, SER_GETHASH, PROTOCOL_VERSION); + return SerializeSigHash(*this); } bool CCoinJoinBroadcastTx::CheckSignature(const CBLSPublicKey& blsPubKey) const diff --git a/src/coinjoin/coinjoin.h b/src/coinjoin/coinjoin.h index df89dbddaf5a..873f9a8e8278 100644 --- a/src/coinjoin/coinjoin.h +++ b/src/coinjoin/coinjoin.h @@ -31,6 +31,7 @@ class CBLSPublicKey; class CBlockIndex; class ChainstateManager; class CTxMemPool; +class SigHashWriter; namespace chainlock { class Chainlocks; @@ -270,7 +271,7 @@ class CCoinJoinQueue SERIALIZE_METHODS(CCoinJoinQueue, obj) { READWRITE(obj.nDenom, obj.m_protxHash, obj.nTime, obj.fReady); - if (!(s.GetType() & SER_GETHASH)) { + if (!std::is_same_v) { READWRITE(obj.vchSig); } } @@ -325,7 +326,7 @@ class CCoinJoinBroadcastTx { READWRITE(obj.tx, obj.m_protxHash); - if (!(s.GetType() & SER_GETHASH)) { + if (!std::is_same_v) { READWRITE(obj.vchSig); } READWRITE(obj.sigTime); diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index ecc406699b32..431161479487 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -4,7 +4,6 @@ #include -#include #include #include #include @@ -157,9 +156,9 @@ struct CDBBatch::WriteBatchImpl { leveldb::WriteBatch batch; }; -CDBBatch::CDBBatch(const CDBWrapper& _parent) : parent(_parent), - m_impl_batch{std::make_unique()}, - ssValue(SER_DISK, CLIENT_VERSION){}; +CDBBatch::CDBBatch(const CDBWrapper& _parent) + : parent{_parent}, + m_impl_batch{std::make_unique()} {}; CDBBatch::~CDBBatch() = default; @@ -169,7 +168,7 @@ void CDBBatch::Clear() size_estimate = 0; } -void CDBBatch::WriteImpl(Span key, CDataStream& ssValue) +void CDBBatch::WriteImpl(Span key, DataStream& ssValue) { leveldb::Slice slKey(CharCast(key.data()), key.size()); ssValue.Xor(dbwrapper_private::GetObfuscateKey(parent)); diff --git a/src/dbwrapper.h b/src/dbwrapper.h index affdb583438a..4c09a1174339 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -91,11 +91,11 @@ class CDBBatch const std::unique_ptr m_impl_batch; DataStream ssKey{}; - CDataStream ssValue; + DataStream ssValue{}; size_t size_estimate{0}; - void WriteImpl(Span key, CDataStream& ssValue); + void WriteImpl(Span key, DataStream& ssValue); void EraseImpl(Span key); public: @@ -199,7 +199,7 @@ class CDBIterator template bool GetValue(V& value) { try { - CDataStream ssValue{GetValueImpl(), SER_DISK, CLIENT_VERSION}; + DataStream ssValue{GetValueImpl()}; ssValue.Xor(dbwrapper_private::GetObfuscateKey(parent)); ssValue >> value; } catch (const std::exception&) { @@ -252,7 +252,7 @@ class CDBWrapper CDBWrapper& operator=(const CDBWrapper&) = delete; template - bool ReadDataStream(const K& key, CDataStream& ssValue) const + bool ReadDataStream(const K& key, DataStream& ssValue) const { DataStream ssKey{}; ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE); @@ -260,13 +260,13 @@ class CDBWrapper return ReadDataStream(ssKey, ssValue); } - bool ReadDataStream(const DataStream& ssKey, CDataStream& ssValue) const + bool ReadDataStream(const DataStream& ssKey, DataStream& ssValue) const { std::optional strValue{ReadImpl(ssKey)}; if (!strValue) { return false; } - CDataStream ssValueTmp{MakeByteSpan(*strValue), SER_DISK, CLIENT_VERSION}; + DataStream ssValueTmp{MakeByteSpan(*strValue)}; ssValueTmp.Xor(obfuscate_key); ssValue = std::move(ssValueTmp); return true; @@ -284,7 +284,7 @@ class CDBWrapper template bool Read(const DataStream& ssKey, V& value) const { - CDataStream ssValue(SER_DISK, CLIENT_VERSION); + DataStream ssValue{}; if (!ReadDataStream(ssKey, ssValue)) { return false; } diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index 70288671d0a6..da21fb5175df 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -1068,7 +1068,7 @@ bool CDeterministicMNManager::MigrateLegacyDiffs(const CBlockIndex* const tip_in } // Use legacy-aware deserialization for DB_LIST_DIFF_LEGACY entries - CDataStream s(SER_DISK, CLIENT_VERSION); + DataStream s{}; if (!m_evoDb.GetRawDB().ReadDataStream(key, s)) { break; } diff --git a/src/evo/deterministicmns.h b/src/evo/deterministicmns.h index ce4df7367fab..4eb155a17667 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -73,14 +73,7 @@ class CDeterministicMN READWRITE(obj.collateralOutpoint); READWRITE(obj.nOperatorReward); READWRITE(obj.pdmnState); - // We can't know if we are serialising for the Disk or for the Network here (s.GetType() is not accessible) - // Therefore if s.GetVersion() == CLIENT_VERSION -> Then we know we are serialising for the Disk - // Otherwise, we can safely check with protocol versioning logic so we won't break old clients - if (s.GetVersion() == CLIENT_VERSION || s.GetVersion() >= DMN_TYPE_PROTO_VERSION) { - READWRITE(obj.nType); - } else { - SER_READ(obj, obj.nType = MnType::Regular); - } + READWRITE(obj.nType); } [[nodiscard]] bool HasInternalId() const { return internalId != std::numeric_limits::max(); } @@ -544,9 +537,9 @@ class CDeterministicMNList // an invalid entry and subsequent attempts at registering ADDRv2 entries get blocked. We cannot // apply this treatment ADDRv1 compatible addresses for backwards compatibility with the existing map. const auto& ser_params{v.IsAddrV1Compatible() ? CNetAddr::V1 : CNetAddr::V2}; - return ::SerializeHash(ser_params(v), /*nType=*/SER_GETHASH, /*nVersion=*/PROTOCOL_VERSION); + return ::SerializeHash(ser_params(v)); } else { - return ::SerializeHash(v, /*nType=*/SER_GETHASH, /*nVersion=*/PROTOCOL_VERSION); + return ::SerializeHash(v); } } template diff --git a/src/evo/providertx.cpp b/src/evo/providertx.cpp index 36385f051c1a..823994aa4fc8 100644 --- a/src/evo/providertx.cpp +++ b/src/evo/providertx.cpp @@ -386,7 +386,7 @@ uint256 CProRegTx::MakeSharedRegConsentHash(const CTransaction& tx) const // signatures. Covering the sequences matters: BIP68 gives them consensus meaning on // version >= 2 transactions, so an uncovered sequence rewrite could impose a months-long // relative timelock on a fully consented registration. - CHashWriter hw(SER_GETHASH, CLIENT_VERSION); + HashWriter hw{}; hw << std::string("DashSharedMNReg"); hw << nVersion; hw << tx.nVersion; @@ -434,7 +434,7 @@ std::string CProRegTx::MakeSignString() const s += EncodeDestination(PKHash(keyIDVoting)) + "|"; // ... and also the full hash of the payload as a protection against malleability and replays - s += ::SerializeHash(*this).ToString(); + s += ::SerializeSigHash(*this).ToString(); return s; } @@ -551,7 +551,7 @@ uint256 CProDisTx::MakeSignHash(const CTransaction& tx, uint8_t sig_count) const // unanimous dissolution as a unilateral one (or vice versa) by dropping/adding signatures. // Together with the empty-scriptSig rule and the low-S requirement this pins every free byte of // a ProDisTx, so its txid is non-malleable by third parties. - CHashWriter hw(SER_GETHASH, CLIENT_VERSION); + HashWriter hw{}; hw << std::string("DashSharedMNDissolve"); hw << nVersion; hw << tx.nVersion; diff --git a/src/evo/providertx.h b/src/evo/providertx.h index aa1c1f907a3a..a9d9959f6494 100644 --- a/src/evo/providertx.h +++ b/src/evo/providertx.h @@ -229,7 +229,7 @@ class CProRegTx obj.platformHTTPPort); } } - if (!(s.GetType() & SER_GETHASH)) { + if (!std::is_same_v) { READWRITE(obj.vchSig); } } @@ -304,7 +304,7 @@ class CProUpServTx obj.platformHTTPPort); } } - if (!(s.GetType() & SER_GETHASH)) { + if (!std::is_same_v) { READWRITE( CBLSSignatureVersionWrapper(const_cast(obj.sig), (obj.nVersion == ProTxVersion::LegacyBLS)) ); @@ -368,7 +368,7 @@ class CProUpRegTx READWRITE( obj.inputsHash ); - if (!(s.GetType() & SER_GETHASH)) { + if (!std::is_same_v) { READWRITE( obj.vchSig ); @@ -422,7 +422,7 @@ class CProUpRevTx obj.nReason, obj.inputsHash ); - if (!(s.GetType() & SER_GETHASH)) { + if (!std::is_same_v) { READWRITE( CBLSSignatureVersionWrapper(const_cast(obj.sig), (obj.nVersion == ProTxVersion::LegacyBLS)) ); @@ -505,7 +505,7 @@ class CProUpShareTx SERIALIZE_METHODS(CProUpShareTx, obj) { READWRITE(obj.nVersion, obj.proTxHash, obj.shareIndex, obj.scriptReward, obj.inputsHash); - if (!(s.GetType() & SER_GETHASH)) { + if (!std::is_same_v) { READWRITE(obj.vchSig); } } @@ -541,7 +541,7 @@ class CProUpSharedRegTx READWRITE(obj.nVersion, obj.proTxHash, CBLSLazyPublicKeyVersionWrapper(const_cast(obj.pubKeyOperator), /*legacy=*/false), obj.keyIDVoting, obj.inputsHash); - if (!(s.GetType() & SER_GETHASH)) { + if (!std::is_same_v) { uint8_t sig_count{0}; SER_WRITE(obj, sig_count = static_cast(obj.vchSigs.size())); READWRITE(sig_count); diff --git a/src/evo/providertx_service.cpp b/src/evo/providertx_service.cpp index 75bbfae250ed..6730cf1ef2d5 100644 --- a/src/evo/providertx_service.cpp +++ b/src/evo/providertx_service.cpp @@ -337,7 +337,7 @@ std::optional SignPayload(const CMutableTransaction& tx, Payloa { UpdateInputsHash(tx, payload); payload.vchSig.clear(); - if (!wallet.signSpecialTxPayload(::SerializeHash(payload), key_id, payload.vchSig)) { + if (!wallet.signSpecialTxPayload(::SerializeSigHash(payload), key_id, payload.vchSig)) { return Error(ProviderTxErrorCode::INTERNAL_ERROR, "failed to sign special tx"); } return std::nullopt; @@ -347,7 +347,7 @@ template void SignPayload(const CMutableTransaction& tx, Payload& payload, const CBLSSecretKey& key, bool legacy) { UpdateInputsHash(tx, payload); - payload.sig = key.Sign(::SerializeHash(payload), legacy); + payload.sig = key.Sign(::SerializeSigHash(payload), legacy); } using MutableTxResult = std::variant; @@ -1282,7 +1282,7 @@ ProviderTxResult SignShared(node::NodeContext& node, Wallet& w const auto dmn{GetSharedMn(node, payload->proTxHash)}; if (!dmn) return SharedMnNotFound(); shares = dmn->pdmnState->shares; - sign_hash = ::SerializeHash(*payload); + sign_hash = ::SerializeSigHash(*payload); result.kind = SharedSignResult::Kind::RegistrarUpdate; } else { return Error(ProviderTxErrorCode::INVALID_PARAMETER, "transaction is not a shared masternode transaction"); @@ -1500,7 +1500,7 @@ ProviderTxResult PrepareSharedRegistrarUpdate(node::NodeC tx = std::get(std::move(funded_result)); UpdateInputsHash(tx, payload); SetTxPayload(tx, payload); - return PreparedSharedConsent{MakeTransactionRef(std::move(tx)), ::SerializeHash(payload)}; + return PreparedSharedConsent{MakeTransactionRef(std::move(tx)), ::SerializeSigHash(payload)}; } } // namespace evo::provider diff --git a/src/evo/specialtx.cpp b/src/evo/specialtx.cpp index 4a62209cb3a8..7ba4b15d17ee 100644 --- a/src/evo/specialtx.cpp +++ b/src/evo/specialtx.cpp @@ -9,7 +9,7 @@ uint256 CalcTxInputsHash(const CTransaction& tx) { - CHashWriter hw(SER_GETHASH, CLIENT_VERSION); + HashWriter hw{}; for (const auto& in : tx.vin) { hw << in.prevout; } @@ -18,7 +18,7 @@ uint256 CalcTxInputsHash(const CTransaction& tx) uint256 CalcTxOutputsHash(const CTransaction& tx) { - CHashWriter hw(SER_GETHASH, CLIENT_VERSION); + HashWriter hw{}; for (const auto& out : tx.vout) { hw << out; } diff --git a/src/evo/specialtxman.cpp b/src/evo/specialtxman.cpp index eb2f68cb730a..a4c3cdb54b20 100644 --- a/src/evo/specialtxman.cpp +++ b/src/evo/specialtxman.cpp @@ -1181,7 +1181,7 @@ bool CSpecialTxProcessor::CheckCreditPoolDiffForBlock(const CBlock& block, const template static bool CheckHashSig(const ProTx& proTx, const PKHash& pkhash, TxValidationState& state) { - if (std::string strError; !CHashSigner::VerifyHash(::SerializeHash(proTx), ToKeyID(pkhash), proTx.vchSig, strError)) { + if (std::string strError; !CHashSigner::VerifyHash(::SerializeSigHash(proTx), ToKeyID(pkhash), proTx.vchSig, strError)) { return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-sig"); } return true; @@ -1200,7 +1200,7 @@ static bool CheckStringSig(const ProTx& proTx, const PKHash& pkhash, TxValidatio template static bool CheckHashSig(const ProTx& proTx, const CBLSPublicKey& pubKey, TxValidationState& state) { - if (!proTx.sig.VerifyInsecure(pubKey, ::SerializeHash(proTx))) { + if (!proTx.sig.VerifyInsecure(pubKey, ::SerializeSigHash(proTx))) { return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-sig"); } return true; @@ -1720,7 +1720,7 @@ bool CheckProUpShareTx(const CTransaction& tx, gsl::not_null } if (check_sigs) { if (std::string strError; - !CHashSigner::VerifyHashCanonical(::SerializeHash(*opt_ptx), + !CHashSigner::VerifyHashCanonical(::SerializeSigHash(*opt_ptx), mnState.shares[opt_ptx->shareIndex].keyIDOwner, opt_ptx->vchSig, strError)) { return state.Invalid(TxValidationResult::TX_BAD_SPECIAL, "bad-proupshare-sig"); @@ -1775,7 +1775,7 @@ bool CheckProUpSharedRegTx(const CTransaction& tx, gsl::not_nullvchSigs[i], strError)) { diff --git a/src/governance/common.cpp b/src/governance/common.cpp index 063b4aba33c1..906a9df3b371 100644 --- a/src/governance/common.cpp +++ b/src/governance/common.cpp @@ -26,7 +26,7 @@ uint256 Object::GetHash() const // CREATE HASH OF ALL IMPORTANT PIECES OF DATA - CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); + HashWriter ss{}; ss << hashParent; ss << revision; ss << time; diff --git a/src/governance/common.h b/src/governance/common.h index 0078b8572e58..8966e18374d1 100644 --- a/src/governance/common.h +++ b/src/governance/common.h @@ -14,6 +14,7 @@ #include #include +class SigHashWriter; struct RPCResult; class UniValue; @@ -81,7 +82,7 @@ class Object obj.type, obj.masternodeOutpoint ); - if (!(s.GetType() & SER_GETHASH)) { + if (!std::is_same_v) { READWRITE(LIMITED_VECTOR(obj.vchSig, MAX_SIGNATURE_SIZE)); } } diff --git a/src/governance/object.cpp b/src/governance/object.cpp index 6e7f161d55f2..ef4154a91b88 100644 --- a/src/governance/object.cpp +++ b/src/governance/object.cpp @@ -526,7 +526,7 @@ uint256 CGovernanceObject::GetHash() const uint256 CGovernanceObject::GetDataHash() const { - CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); + HashWriter ss{}; ss << GetDataAsHexString(); return ss.GetHash(); @@ -534,7 +534,7 @@ uint256 CGovernanceObject::GetDataHash() const uint256 CGovernanceObject::GetSignatureHash() const { - return SerializeHash(*this); + return SerializeSigHash(m_obj); } void CGovernanceObject::SetMasternodeOutpoint(const COutPoint& outpoint) diff --git a/src/governance/vote.cpp b/src/governance/vote.cpp index 2b5265c62d69..c5d296cf0d3a 100644 --- a/src/governance/vote.cpp +++ b/src/governance/vote.cpp @@ -146,7 +146,7 @@ void CGovernanceVote::UpdateHash() const { // Note: doesn't match serialization - CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); + HashWriter ss{}; ss << masternodeOutpoint << uint8_t{} << 0xffffffff; // adding dummy values here to match old hashing format ss << nParentHash; ss << nVoteSignal; diff --git a/src/governance/vote.h b/src/governance/vote.h index 36df8a199fed..d65a85374fab 100644 --- a/src/governance/vote.h +++ b/src/governance/vote.h @@ -182,7 +182,7 @@ class CGovernanceVote uint256 GetHash() const; uint256 GetSignatureHash() const { - return SerializeHash(*this); + return SerializeSigHash(*this); } std::string ToString(const CDeterministicMNList& tip_mn_list) const; @@ -190,7 +190,7 @@ class CGovernanceVote SERIALIZE_METHODS(CGovernanceVote, obj) { READWRITE(obj.masternodeOutpoint, obj.nParentHash, obj.nVoteOutcome, obj.nVoteSignal, obj.nTime); - if (!(s.GetType() & SER_GETHASH)) { + if (!std::is_same_v) { // Network reads: cap the signature vector before allocation and require // one of the two legitimate encodings. Other paths (disk, hash, write) // keep the unbounded default. diff --git a/src/hash.h b/src/hash.h index b7bd4ad2ea68..acb696f1ead1 100644 --- a/src/hash.h +++ b/src/hash.h @@ -233,6 +233,27 @@ uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL return ss.GetHash(); } +/** A writer that computes the hash a signed object's signature commits to: the object's serializer leaves the signature out. */ +class SigHashWriter : public CHashWriter +{ +public: + SigHashWriter() : CHashWriter{SER_GETHASH, PROTOCOL_VERSION} {} + + template + SigHashWriter& operator<<(const T& obj) + { + ::Serialize(*this, obj); + return *this; + } +}; + +/** Compute the 256-bit hash of a signed object's serialization without its signature. */ +template +uint256 SerializeSigHash(const T& obj) +{ + return (SigHashWriter{} << obj).GetHash(); +} + /** Single-SHA256 a 32-byte input (represented as uint256). */ [[nodiscard]] uint256 SHA256Uint256(const uint256& input); diff --git a/src/index/blockfilterindex.cpp b/src/index/blockfilterindex.cpp index d2b03a992734..d41b8fe21799 100644 --- a/src/index/blockfilterindex.cpp +++ b/src/index/blockfilterindex.cpp @@ -4,6 +4,7 @@ #include +#include #include #include #include diff --git a/src/index/txindex.cpp b/src/index/txindex.cpp index 67caf35574d1..e6b7c6358fae 100644 --- a/src/index/txindex.cpp +++ b/src/index/txindex.cpp @@ -4,6 +4,7 @@ #include +#include #include #include #include diff --git a/src/init.cpp b/src/init.cpp index 4c4892f7054b..e6c3d0c56dda 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/src/instantsend/lock.cpp b/src/instantsend/lock.cpp index 8fdd4586c3ea..fd8c4bd2f851 100644 --- a/src/instantsend/lock.cpp +++ b/src/instantsend/lock.cpp @@ -17,7 +17,7 @@ static constexpr std::string_view ISLOCK_REQUESTID_PREFIX{"islock"}; namespace instantsend { uint256 InstantSendLock::GetRequestId() const { - CHashWriter hw(SER_GETHASH, 0); + HashWriter hw{}; hw << ISLOCK_REQUESTID_PREFIX; hw << inputs; return hw.GetHash(); diff --git a/src/llmq/commitment.cpp b/src/llmq/commitment.cpp index 038bb62c2c5d..060538659440 100644 --- a/src/llmq/commitment.cpp +++ b/src/llmq/commitment.cpp @@ -303,7 +303,7 @@ uint256 BuildCommitmentHash(Consensus::LLMQType llmqType, const uint256& blockHa const std::vector& validMembers, const CBLSPublicKey& pubKey, const uint256& vvecHash) { - CHashWriter hw(SER_GETHASH, 0); + HashWriter hw{}; hw << llmqType; hw << blockHash; hw << DYNBITSET(validMembers); diff --git a/src/llmq/dkgmessages.h b/src/llmq/dkgmessages.h index 7080779abf2f..bcd8b19305a7 100644 --- a/src/llmq/dkgmessages.h +++ b/src/llmq/dkgmessages.h @@ -68,7 +68,7 @@ class CDKGContribution [[nodiscard]] uint256 GetSignHash() const { - CHashWriter hw(SER_GETHASH, 0); + HashWriter hw{}; SerializeWithoutSig(hw); hw << CBLSSignature(); return hw.GetHash(); diff --git a/src/llmq/dkgsessionmgr.cpp b/src/llmq/dkgsessionmgr.cpp index 77f81eab13fa..b7225d162c4d 100644 --- a/src/llmq/dkgsessionmgr.cpp +++ b/src/llmq/dkgsessionmgr.cpp @@ -159,7 +159,7 @@ bool CDKGSessionManager::GetVerifiedContributions(Consensus::LLMQType llmqType, ContributionsCacheKey cacheKey = {llmqType, pQuorumBaseBlockIndex->GetBlockHash(), proTxHash}; auto it = contributionsCache.find(cacheKey); if (it == contributionsCache.end()) { - CDataStream s(SER_DISK, CLIENT_VERSION); + DataStream s{}; if (!db->ReadDataStream(std::make_tuple(DB_VVEC, llmqType, pQuorumBaseBlockIndex->GetBlockHash(), proTxHash), s)) { LogPrint(BCLog::LLMQ, "%s -- this node does not have vvec for llmq=%d block=%s protx=%s\n", __func__, std23::to_underlying(llmqType), pQuorumBaseBlockIndex->GetBlockHash().ToString(), diff --git a/src/llmq/net_dkg.cpp b/src/llmq/net_dkg.cpp index d320c234af90..34b279b8f18c 100644 --- a/src/llmq/net_dkg.cpp +++ b/src/llmq/net_dkg.cpp @@ -371,7 +371,7 @@ void EnqueueOwn(CDKGPendingMessages& pending, const uint256& own_protx, const Me CDataStream ds(SER_NETWORK, PROTOCOL_VERSION); ds << msg; auto pm = std::make_shared(std::move(ds)); - CHashWriter hw(SER_GETHASH, 0); + HashWriter hw{}; hw.write(AsWritableBytes(Span{*pm})); pending.PushPendingMessage(/*from=*/-1, own_protx, std::move(pm), hw.GetHash()); } @@ -626,7 +626,7 @@ void NetDKG::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStre Assume(inv_type != 0); // guarded by the early-return above auto pm = std::make_shared(std::move(vRecv)); - CHashWriter hw(SER_GETHASH, 0); + HashWriter hw{}; hw.write(AsWritableBytes(Span{*pm})); const uint256 hash = hw.GetHash(); diff --git a/src/llmq/quorumproofs.cpp b/src/llmq/quorumproofs.cpp index e23a31160fe5..60e6bfe7d206 100644 --- a/src/llmq/quorumproofs.cpp +++ b/src/llmq/quorumproofs.cpp @@ -308,7 +308,7 @@ bool ProofCertificate::Verify(const CFinalCommitment& signer, uint32_t minimum, SignHash hash{kind, signer.quorumHash, chainlock::GenSigRequestId(height), header.GetHash()}; // Bind every input to Basic BLS verification, including the public key and // signature themselves. A quorum hash or signed message alone is insufficient. - CHashWriter writer(SER_GETHASH, 0); + HashWriter writer{}; writer << hash.Get(); signer.quorumPublicKey.Serialize(writer, false); signature.Serialize(writer, false); @@ -572,7 +572,7 @@ std::optional QuorumProofBuilder::DetermineChainlockSigningCom if (!start) return std::nullopt; // This hash commits to the entire selection history, including its branch. // The type and request height fix the remaining signing-selection inputs. - const auto key = (CHashWriter(SER_GETHASH, 0) << start->GetBlockHash() << params->type << height).GetHash(); + const auto key = (HashWriter{} << start->GetBlockHash() << params->type << height).GetHash(); // Two levels: every candidate height needs an entry, but thousands of heights // share a few dozen commitments. Heights map to a commitment's content hash, // which cannot alias across branches, and each commitment is stored once. @@ -607,7 +607,7 @@ static const CBlockIndex* MinedCommitmentBlock(const CQuorumBlockProcessor& proc const node::BlockManager& blocks, Consensus::LLMQType kind, const uint256& quorum) { - const auto key = (CHashWriter(SER_GETHASH, 0) << kind << quorum).GetHash(); + const auto key = (HashWriter{} << kind << quorum).GetHash(); static ProofCache cache; uint256 mined_hash; LOCK(cs_main); @@ -632,7 +632,7 @@ static const CBlockIndex* MinedCommitmentBlock(const CQuorumBlockProcessor& proc * commitments, each carrying BLS points that are costly to decode). */ static ProofTransaction MiningTransaction(const node::BlockManager& blocks, const CBlockIndex* mined, Consensus::LLMQType kind, const uint256& quorum) { - const auto key = (CHashWriter(SER_GETHASH, 0) << mined->GetBlockHash() << kind << quorum).GetHash(); + const auto key = (HashWriter{} << mined->GetBlockHash() << kind << quorum).GetHash(); static ProofCache cache; ProofTransaction cached; if (cache.Get(key, cached)) return cached; diff --git a/src/llmq/quorums.cpp b/src/llmq/quorums.cpp index 3a0d466fa699..1c7eb75aa7e9 100644 --- a/src/llmq/quorums.cpp +++ b/src/llmq/quorums.cpp @@ -19,7 +19,7 @@ const std::string DB_QUORUM_QUORUM_VVEC = "q_Qqvvec"; uint256 MakeQuorumKey(const CQuorum& q) { - CHashWriter hw(SER_NETWORK, 0); + HashWriter hw{}; hw << q.params.type; hw << q.qc->quorumHash; for (const auto& dmn : q.members) { @@ -212,7 +212,7 @@ void CQuorum::WriteContributions(CDBWrapper& db) const bool CQuorum::ReadContributions(const CDBWrapper& db) { uint256 dbKey = MakeQuorumKey(*this); - CDataStream s(SER_DISK, CLIENT_VERSION); + DataStream s{}; if (!db.ReadDataStream(std::make_pair(DB_QUORUM_QUORUM_VVEC, dbKey), s)) { return false; diff --git a/src/llmq/quorumsman.cpp b/src/llmq/quorumsman.cpp index 48a8fd5bbcdf..3c804a470e88 100644 --- a/src/llmq/quorumsman.cpp +++ b/src/llmq/quorumsman.cpp @@ -643,7 +643,7 @@ void CQuorumManager::MigrateOldQuorumDB(CEvoDB& evoDb) const int count{0}; while (pcursor->Valid()) { decltype(start) k; - CDataStream s(SER_DISK, CLIENT_VERSION); + DataStream s{}; CBLSSecretKey sk; if (!pcursor->GetKey(k) || std::get<0>(k) != prefix) { @@ -736,7 +736,7 @@ static std::optional SelectSigningCandidate(const Consensus::LLMQParams& std::vector> scores; scores.reserve(candidates.size()); for (const auto i : util::irange(candidates.size())) { - CHashWriter h(SER_NETWORK, 0); + HashWriter h{}; h << llmq_params.type; h << SigningCandidateCommitment(candidates[i]).quorumHash; h << selectionHash; diff --git a/src/llmq/signhash.cpp b/src/llmq/signhash.cpp index 7b1a01c3f4dc..3b8c63d337c1 100644 --- a/src/llmq/signhash.cpp +++ b/src/llmq/signhash.cpp @@ -13,7 +13,7 @@ namespace llmq { SignHash::SignHash(Consensus::LLMQType llmqType, const uint256& quorumHash, const uint256& id, const uint256& msgHash) { - CHashWriter h(SER_GETHASH, 0); + HashWriter h{}; h << llmqType; h << quorumHash; h << id; diff --git a/src/llmq/signing.cpp b/src/llmq/signing.cpp index f374d28963cf..d4587e61e206 100644 --- a/src/llmq/signing.cpp +++ b/src/llmq/signing.cpp @@ -96,7 +96,7 @@ bool CRecoveredSigsDb::ReadRecoveredSig(Consensus::LLMQType llmqType, const uint { auto k = std::make_tuple(std::string("rs_r"), llmqType, id); - CDataStream ds(SER_DISK, CLIENT_VERSION); + DataStream ds{}; if (!db->ReadDataStream(k, ds)) { return false; } @@ -239,7 +239,7 @@ struct RecoveredSigMarker { std::optional ReadRecoveredSigMarker(const CDBWrapper& db, const std::string& prefix, const uint256& hash) { - CDataStream value{SER_DISK, CLIENT_VERSION}; + DataStream value{}; if (!db.ReadDataStream(std::make_pair(prefix, hash), value)) return std::nullopt; RecoveredSigMarker marker; try { diff --git a/src/masternode/meta.cpp b/src/masternode/meta.cpp index c995ac8e718f..3d01678428c0 100644 --- a/src/masternode/meta.cpp +++ b/src/masternode/meta.cpp @@ -257,4 +257,4 @@ std::string MasternodeMetaStore::ToString() const metaInfos.size(), nDsqCount, m_used_masternodes.size()); } -uint256 PlatformBanMessage::GetHash() const { return ::SerializeHash(*this); } +uint256 PlatformBanMessage::GetHash() const { return ::SerializeSigHash(*this); } diff --git a/src/masternode/meta.h b/src/masternode/meta.h index 3301e4740299..9f4fd0b152af 100644 --- a/src/masternode/meta.h +++ b/src/masternode/meta.h @@ -177,7 +177,7 @@ class PlatformBanMessage SERIALIZE_METHODS(PlatformBanMessage, obj) { READWRITE(obj.m_protx_hash, obj.m_requested_height, obj.m_quorum_hash); - if (!(s.GetType() & SER_GETHASH)) { + if (!std::is_same_v) { READWRITE(CBLSSignatureVersionWrapper(const_cast(obj.m_signature), false)); } } diff --git a/src/messagesigner.cpp b/src/messagesigner.cpp index f30ea055784e..70c5eaf5b892 100644 --- a/src/messagesigner.cpp +++ b/src/messagesigner.cpp @@ -24,7 +24,7 @@ bool CMessageSigner::GetKeysFromSecret(const std::string& strSecret, CKey& keyRe bool CMessageSigner::SignMessage(const std::string& strMessage, std::vector& vchSigRet, const CKey& key) { - CHashWriter ss(SER_GETHASH, 0); + HashWriter ss{}; ss << MESSAGE_MAGIC; ss << strMessage; @@ -38,7 +38,7 @@ bool CMessageSigner::VerifyMessage(const CPubKey& pubkey, const std::vector& vchSig, const std::string& strMessage, std::string& strErrorRet) { - CHashWriter ss(SER_GETHASH, 0); + HashWriter ss{}; ss << MESSAGE_MAGIC; ss << strMessage; diff --git a/src/primitives/block.h b/src/primitives/block.h index 8789a21cbe37..486f855e6204 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -245,6 +245,15 @@ class CBlock : public CBlockHeader */ struct CBlockLocator { + /** Historically CBlockLocator's version field has been written to network + * streams as the negotiated protocol version and to disk streams as the + * client version, but the value has never been used. + * + * Hard-code to the highest protocol version ever written to a network stream. + * SerParams can be used if the field requires any meaning in the future, + **/ + static constexpr int DUMMY_VERSION = 70242; + std::vector vHave; CBlockLocator() {} @@ -253,9 +262,8 @@ struct CBlockLocator SERIALIZE_METHODS(CBlockLocator, obj) { - int nVersion = s.GetVersion(); - if (!(s.GetType() & SER_GETHASH)) - READWRITE(nVersion); + int nVersion = DUMMY_VERSION; + READWRITE(nVersion); READWRITE(obj.vHave); } diff --git a/src/qt/sharedmndialogs.cpp b/src/qt/sharedmndialogs.cpp index afd83188146a..d2d0aee841e2 100644 --- a/src/qt/sharedmndialogs.cpp +++ b/src/qt/sharedmndialogs.cpp @@ -303,8 +303,7 @@ bool ComputeSharedSignHash(SharedSigCollector::Kind kind, const QString& pro_tx_ error = QCoreApplication::translate("SharedSigCollector", "The transaction updates a different masternode."); return false; } - // SER_GETHASH serialization excludes the signature vector - hash = ::SerializeHash(*opt_ptx); + hash = ::SerializeSigHash(*opt_ptx); return true; } diff --git a/src/spork.cpp b/src/spork.cpp index 8357933d4e08..fa082b1ecb6e 100644 --- a/src/spork.cpp +++ b/src/spork.cpp @@ -267,7 +267,7 @@ uint256 CSporkMessage::GetHash() const uint256 CSporkMessage::GetSignatureHash() const { - CHashWriter s(SER_GETHASH, 0); + HashWriter s{}; s << nSporkID; s << nValue; s << nTimeSigned; diff --git a/src/test/evo_deterministicmns_tests.cpp b/src/test/evo_deterministicmns_tests.cpp index 90c6c6644744..acc8043a25cd 100644 --- a/src/test/evo_deterministicmns_tests.cpp +++ b/src/test/evo_deterministicmns_tests.cpp @@ -115,7 +115,7 @@ static CMutableTransaction CreateProUpServTx(const ChainstateManager& chainman, const auto spent = FundTransaction(chainman, tx, utxos, GetScriptForDestination(PKHash(coinbaseKey.GetPubKey())), 1 * COIN); tx.vout.back().nValue -= fee; proTx.inputsHash = CalcTxInputsHash(CTransaction(tx)); - proTx.sig = operatorKey.Sign(::SerializeHash(proTx), bls::bls_legacy_scheme); + proTx.sig = operatorKey.Sign(::SerializeSigHash(proTx), bls::bls_legacy_scheme); SetTxPayload(tx, proTx); SignTransaction(tx, spent, coinbaseKey); @@ -141,7 +141,7 @@ static CMutableTransaction CreateProUpRegTx(const ChainstateManager& chainman, S // never notice, because block creation does not check relay fees. tx.vout.back().nValue -= fee; proTx.inputsHash = CalcTxInputsHash(CTransaction(tx)); - CHashSigner::SignHash(::SerializeHash(proTx), mnKey, proTx.vchSig); + CHashSigner::SignHash(::SerializeSigHash(proTx), mnKey, proTx.vchSig); SetTxPayload(tx, proTx); SignTransaction(tx, spent, coinbaseKey); @@ -161,7 +161,7 @@ static CMutableTransaction CreateProUpRevTx(const ChainstateManager& chainman, S const auto spent = FundTransaction(chainman, tx, utxos, GetScriptForDestination(PKHash(coinbaseKey.GetPubKey())), 1 * COIN); tx.vout.back().nValue -= fee; proTx.inputsHash = CalcTxInputsHash(CTransaction(tx)); - proTx.sig = operatorKey.Sign(::SerializeHash(proTx), bls::bls_legacy_scheme); + proTx.sig = operatorKey.Sign(::SerializeSigHash(proTx), bls::bls_legacy_scheme); SetTxPayload(tx, proTx); SignTransaction(tx, spent, coinbaseKey); @@ -472,7 +472,7 @@ void FuncProUpRegTxVersionHandlingBeforeV24(TestChainSetup& setup) const auto spent_upreg3 = FundTransaction(chainman, tx_upreg3, utxos, GetScriptForDestination(PKHash(setup.coinbaseKey.GetPubKey())), 1 * COIN); proTxLegacy.inputsHash = CalcTxInputsHash(CTransaction(tx_upreg3)); - CHashSigner::SignHash(::SerializeHash(proTxLegacy), owner_key, proTxLegacy.vchSig); + CHashSigner::SignHash(::SerializeSigHash(proTxLegacy), owner_key, proTxLegacy.vchSig); SetTxPayload(tx_upreg3, proTxLegacy); SignTransaction(tx_upreg3, spent_upreg3, setup.coinbaseKey); @@ -538,7 +538,7 @@ void FuncProUpRegTxV3OnLegacyValid(TestChainSetup& setup) const auto spent = FundTransaction(chainman, tx, utxos, GetScriptForDestination(PKHash(setup.coinbaseKey.GetPubKey())), 1 * COIN); proTx.inputsHash = CalcTxInputsHash(CTransaction(tx)); - CHashSigner::SignHash(::SerializeHash(proTx), owner_key, proTx.vchSig); + CHashSigner::SignHash(::SerializeSigHash(proTx), owner_key, proTx.vchSig); SetTxPayload(tx, proTx); SignTransaction(tx, spent, setup.coinbaseKey); @@ -738,7 +738,7 @@ void FuncMNPaymentMultiplicityV24Boundary(TestChainSetup& setup) const auto spent_ups = FundTransaction(chainman, tx_ups, utxos, GetScriptForDestination(PKHash(setup.coinbaseKey.GetPubKey())), 1 * COIN); pro_ups.inputsHash = CalcTxInputsHash(CTransaction(tx_ups)); - pro_ups.sig = operator_key.Sign(::SerializeHash(pro_ups), bls::bls_legacy_scheme); + pro_ups.sig = operator_key.Sign(::SerializeSigHash(pro_ups), bls::bls_legacy_scheme); SetTxPayload(tx_ups, pro_ups); SignTransaction(tx_ups, spent_ups, setup.coinbaseKey); setup.CreateAndProcessBlock({tx_ups}, coinbase_pk); @@ -1177,7 +1177,7 @@ void FuncProUpServInvalidNType(TestChainSetup& setup) BOOST_REQUIRE(tx.vout[0].nValue > 10000); tx.vout[0].nValue -= 10000; proTx.inputsHash = CalcTxInputsHash(CTransaction(tx)); - proTx.sig = operatorKey.Sign(::SerializeHash(proTx), bls::bls_legacy_scheme); + proTx.sig = operatorKey.Sign(::SerializeSigHash(proTx), bls::bls_legacy_scheme); SetTxPayload(tx, proTx); SignTransaction(tx, spent, setup.coinbaseKey); return tx; @@ -1380,7 +1380,7 @@ void FuncTestMempoolProTxKeyChangedConflictChain(TestChainSetup& setup) payload.proTxHash = proTxHash; BOOST_REQUIRE_EQUAL(payload.netInfo->AddEntry(NetInfoPurpose::CORE_P2P, "1.1.1.1:3"), NetInfoStatus::Success); payload.inputsHash = CalcTxInputsHash(CTransaction(tx_child)); - payload.sig = operatorKey.Sign(::SerializeHash(payload), bls::bls_legacy_scheme); + payload.sig = operatorKey.Sign(::SerializeSigHash(payload), bls::bls_legacy_scheme); SetTxPayload(tx_child, payload); // Grind the child's output value until the parent's txid sorts before the child's: the @@ -2698,7 +2698,7 @@ void FuncMigrationRejectedWhenKeySquatted(TestChainV24SignalBeforeV19Setup& setu const auto spent = FundTransaction(chainman, tx, utxos, GetScriptForDestination(PKHash(setup.coinbaseKey.GetPubKey())), 1 * COIN); ups.inputsHash = CalcTxInputsHash(CTransaction(tx)); - ups.sig = operator_key.Sign(::SerializeHash(ups), bls::bls_legacy_scheme); + ups.sig = operator_key.Sign(::SerializeSigHash(ups), bls::bls_legacy_scheme); SetTxPayload(tx, ups); SignTransaction(tx, spent, setup.coinbaseKey); TxValidationState st; @@ -2722,7 +2722,7 @@ void FuncMigrationRejectedWhenKeySquatted(TestChainV24SignalBeforeV19Setup& setu const auto spent = FundTransaction(chainman, tx, utxos, GetScriptForDestination(PKHash(setup.coinbaseKey.GetPubKey())), 1 * COIN); upreg.inputsHash = CalcTxInputsHash(CTransaction(tx)); - CHashSigner::SignHash(::SerializeHash(upreg), owner_key_a, upreg.vchSig); + CHashSigner::SignHash(::SerializeSigHash(upreg), owner_key_a, upreg.vchSig); SetTxPayload(tx, upreg); SignTransaction(tx, spent, setup.coinbaseKey); TxValidationState st; @@ -2996,7 +2996,7 @@ static CMutableTransaction CreateExtAddrProUpRegTx(TestChainV24SignalBeforeV19Se const auto spent = FundTransaction(setup.chainman, tx, setup.utxos, GetScriptForDestination(PKHash(setup.coinbaseKey.GetPubKey())), 1 * COIN); proTx.inputsHash = CalcTxInputsHash(CTransaction(tx)); - CHashSigner::SignHash(::SerializeHash(proTx), owner_key, proTx.vchSig); + CHashSigner::SignHash(::SerializeSigHash(proTx), owner_key, proTx.vchSig); SetTxPayload(tx, proTx); SignTransaction(tx, spent, setup.coinbaseKey); return tx; @@ -3028,7 +3028,7 @@ static CMutableTransaction CreateEvoProUpServTx(TestChainV24SignalBeforeV19Setup const auto spent = FundTransaction(setup.chainman, tx, setup.utxos, GetScriptForDestination(PKHash(setup.coinbaseKey.GetPubKey())), 1 * COIN); proTx.inputsHash = CalcTxInputsHash(CTransaction(tx)); - proTx.sig = operator_key.Sign(::SerializeHash(proTx), /*specificLegacyScheme=*/false); + proTx.sig = operator_key.Sign(::SerializeSigHash(proTx), /*specificLegacyScheme=*/false); SetTxPayload(tx, proTx); SignTransaction(tx, spent, setup.coinbaseKey); return tx; @@ -4019,7 +4019,7 @@ void FuncPreV24BehaviourUnchanged(TestChainSetup& setup) const auto spent = FundTransaction(chainman, tx_upreg, utxos, GetScriptForDestination(PKHash(setup.coinbaseKey.GetPubKey())), 1 * COIN); pro_upreg.inputsHash = CalcTxInputsHash(CTransaction(tx_upreg)); - CHashSigner::SignHash(::SerializeHash(pro_upreg), owner_key, pro_upreg.vchSig); + CHashSigner::SignHash(::SerializeSigHash(pro_upreg), owner_key, pro_upreg.vchSig); SetTxPayload(tx_upreg, pro_upreg); SignTransaction(tx_upreg, spent, setup.coinbaseKey); { diff --git a/src/test/evo_islock_tests.cpp b/src/test/evo_islock_tests.cpp index 43e5d9c99c29..46feef9b922d 100644 --- a/src/test/evo_islock_tests.cpp +++ b/src/test/evo_islock_tests.cpp @@ -217,7 +217,7 @@ BOOST_FIXTURE_TEST_CASE(cached_recovered_sig_does_not_authenticate_other_lock, N uint256 CalculateRequestId(const std::vector& inputs) { - CHashWriter hw(SER_GETHASH, 0); + HashWriter hw{}; hw << std::string_view("islock"); hw << inputs; return hw.GetHash(); diff --git a/src/test/evo_netinfo_tests.cpp b/src/test/evo_netinfo_tests.cpp index 04c6fa39cfe0..288dfaef60a4 100644 --- a/src/test/evo_netinfo_tests.cpp +++ b/src/test/evo_netinfo_tests.cpp @@ -671,7 +671,7 @@ BOOST_AUTO_TEST_CASE(netinfo_retvals) bool CheckIfSerSame(const CService& lhs, const MnNetInfo& rhs) { - CHashWriter ss_lhs(SER_GETHASH, 0), ss_rhs(SER_GETHASH, 0); + HashWriter ss_lhs{}, ss_rhs{}; ss_lhs << CNetAddr::V1(lhs); ss_rhs << rhs; return ss_lhs.GetSHA256() == ss_rhs.GetSHA256(); diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp index 761718c720fd..d3d0bb176cee 100644 --- a/src/test/sighash_tests.cpp +++ b/src/test/sighash_tests.cpp @@ -76,7 +76,7 @@ uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, un } // Serialize and hash - CHashWriter ss(SER_GETHASH, 0); + HashWriter ss{}; ss << txTmp << nHashType; return ss.GetHash(); } diff --git a/src/validation.cpp b/src/validation.cpp index bd394b24d84a..3a34f9547844 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include