Inside Bitcoin
Opening the selected file…
Inside Bitcoin
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) 2009-2010 Satoshi Nakamoto2// Copyright (c) 2009-present The Bitcoin Core developers3// Distributed under the MIT software license, see the accompanying4// file COPYING or http://www.opensource.org/licenses/mit-license.php.6#ifndef BITCOIN_SCRIPT_VERIFY_FLAGS_H7#define BITCOIN_SCRIPT_VERIFY_FLAGS_H9#include <compare>10#include <cstdint>12enum class script_verify_flag_name : uint8_t;14class script_verify_flags15{16public:17using value_type = uint64_t;19consteval script_verify_flags() = default;21// also allow construction with hard-coded 0 (but not other integers)22consteval explicit(false) script_verify_flags(value_type f) : m_value{f} { if (f != 0) throw 0; }24// implicit construction from a hard-coded SCRIPT_VERIFY_* constant is also okay25constexpr explicit(false) script_verify_flags(script_verify_flag_name f) : m_value{value_type{1} << static_cast<uint8_t>(f)} { }27// rule of 528constexpr script_verify_flags(const script_verify_flags&) = default;29constexpr script_verify_flags(script_verify_flags&&) = default;30constexpr script_verify_flags& operator=(const script_verify_flags&) = default;31constexpr script_verify_flags& operator=(script_verify_flags&&) = default;32constexpr ~script_verify_flags() = default;34// integer conversion needs to be very explicit35static constexpr script_verify_flags from_int(value_type f) { script_verify_flags r; r.m_value = f; return r; }36constexpr value_type as_int() const { return m_value; }38// bitwise operations39constexpr script_verify_flags operator~() const { return from_int(~m_value); }40friend constexpr script_verify_flags operator|(script_verify_flags a, script_verify_flags b) { return from_int(a.m_value | b.m_value); }41friend constexpr script_verify_flags operator&(script_verify_flags a, script_verify_flags b) { return from_int(a.m_value & b.m_value); }43// in-place bitwise operations44constexpr script_verify_flags& operator|=(script_verify_flags vf) { m_value |= vf.m_value; return *this; }45constexpr script_verify_flags& operator&=(script_verify_flags vf) { m_value &= vf.m_value; return *this; }47// tests48constexpr explicit operator bool() const { return m_value != 0; }49constexpr bool operator==(script_verify_flags other) const { return m_value == other.m_value; }51/** Compare two script_verify_flags. <, >, <=, and >= are auto-generated from this. */52friend constexpr std::strong_ordering operator<=>(const script_verify_flags& a, const script_verify_flags& b) noexcept53{54return a.m_value <=> b.m_value;55}57private:58value_type m_value{0}; // default value is SCRIPT_VERIFY_NONE59};61inline constexpr script_verify_flags operator~(script_verify_flag_name f)62{63return ~script_verify_flags{f};64}66inline constexpr script_verify_flags operator|(script_verify_flag_name f1, script_verify_flag_name f2)67{68return script_verify_flags{f1} | f2;69}71#endif // BITCOIN_SCRIPT_VERIFY_FLAGS_H