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) 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#include <bitcoin-build-config.h> // IWYU pragma: keep8#include <node/warnings.h>10#include <common/system.h>11#include <node/interface_ui.h>12#include <sync.h>13#include <univalue.h>14#include <util/translation.h>16#include <utility>17#include <vector>19namespace node {20Warnings::Warnings()21{22// Pre-release build warning23if (!CLIENT_VERSION_IS_RELEASE) {24m_warnings.insert(25{Warning::PRE_RELEASE_TEST_BUILD,26_("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications")});27}28}29bool Warnings::Set(warning_type id, bilingual_str message)30{31const auto& [_, inserted]{WITH_LOCK(m_mutex, return m_warnings.insert({id, std::move(message)}))};32if (inserted) uiInterface.NotifyAlertChanged();33return inserted;34}36bool Warnings::Unset(warning_type id)37{38auto success{WITH_LOCK(m_mutex, return m_warnings.erase(id))};39if (success) uiInterface.NotifyAlertChanged();40return success;41}43std::vector<bilingual_str> Warnings::GetMessages() const44{45LOCK(m_mutex);46std::vector<bilingual_str> messages;47messages.reserve(m_warnings.size());48for (const auto& [id, msg] : m_warnings) {49messages.push_back(msg);50}51return messages;52}54UniValue GetWarningsForRpc(const Warnings& warnings, bool use_deprecated)55{56if (use_deprecated) {57const auto all_messages{warnings.GetMessages()};58return all_messages.empty() ? "" : all_messages.back().original;59}61UniValue messages{UniValue::VARR};62for (auto&& message : warnings.GetMessages()) {63messages.push_back(std::move(message.original));64}65return messages;66}67} // namespace node