Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2020-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_UTIL_HASH_TYPE_H6#define BITCOIN_UTIL_HASH_TYPE_H8template <typename HashType>9class BaseHash10{11protected:12HashType m_hash;14public:15BaseHash() : m_hash() {}16explicit BaseHash(const HashType& in) : m_hash(in) {}18unsigned char* begin()19{20return m_hash.begin();21}23const unsigned char* begin() const24{25return m_hash.begin();26}28unsigned char* end()29{30return m_hash.end();31}33const unsigned char* end() const34{35return m_hash.end();36}38operator std::vector<unsigned char>() const39{40return std::vector<unsigned char>{m_hash.begin(), m_hash.end()};41}43std::string ToString() const44{45return m_hash.ToString();46}48bool operator==(const BaseHash<HashType>& other) const noexcept49{50return m_hash == other.m_hash;51}53bool operator<(const BaseHash<HashType>& other) const noexcept54{55return m_hash < other.m_hash;56}58size_t size() const59{60return m_hash.size();61}63unsigned char* data() { return m_hash.data(); }64const unsigned char* data() const { return m_hash.data(); }65};67#endif // BITCOIN_UTIL_HASH_TYPE_H