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) 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 <noui.h>8#include <node/interface_ui.h>9#include <util/btcsignals.h>10#include <util/log.h>11#include <util/translation.h>13#include <string>15/** Store connections so we can disconnect them when suppressing output */16btcsignals::connection noui_ThreadSafeMessageBoxConn;17btcsignals::connection noui_ThreadSafeQuestionConn;18btcsignals::connection noui_InitMessageConn;20void noui_ThreadSafeMessageBox(const bilingual_str& message, unsigned int style)21{22bool fSecure = style & CClientUIInterface::SECURE;23style &= ~CClientUIInterface::SECURE;25std::string strCaption;26switch (style) {27case CClientUIInterface::MSG_ERROR:28strCaption = "Error: ";29if (!fSecure) LogError("%s\n", message.original);30break;31case CClientUIInterface::MSG_WARNING:32strCaption = "Warning: ";33if (!fSecure) LogWarning("%s\n", message.original);34break;35case CClientUIInterface::MSG_INFORMATION:36strCaption = "Information: ";37if (!fSecure) LogInfo("%s\n", message.original);38break;39default:40if (!fSecure) LogInfo("%s%s\n", strCaption, message.original);41}43tfm::format(std::cerr, "%s%s\n", strCaption, message.original);44}46bool noui_ThreadSafeQuestion(const bilingual_str& /* ignored interactive message */, const std::string& message, unsigned int style)47{48noui_ThreadSafeMessageBox(Untranslated(message), style);49return false; // Answer the question with false in the noui context50}52void noui_InitMessage(const std::string& message)53{54LogInfo("init message: %s", message);55}57void noui_connect()58{59noui_ThreadSafeMessageBoxConn = uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox);60noui_ThreadSafeQuestionConn = uiInterface.ThreadSafeQuestion.connect(noui_ThreadSafeQuestion);61noui_InitMessageConn = uiInterface.InitMessage.connect(noui_InitMessage);62}64void noui_ThreadSafeMessageBoxRedirect(const bilingual_str& message, unsigned int style)65{66LogInfo("%s", message.original);67}69bool noui_ThreadSafeQuestionRedirect(const bilingual_str& /* ignored interactive message */, const std::string& message, unsigned int style)70{71LogInfo("%s", message);72return false;73}75void noui_InitMessageRedirect(const std::string& message)76{77LogInfo("init message: %s", message);78}80void noui_test_redirect()81{82noui_ThreadSafeMessageBoxConn.disconnect();83noui_ThreadSafeQuestionConn.disconnect();84noui_InitMessageConn.disconnect();85noui_ThreadSafeMessageBoxConn = uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBoxRedirect);86noui_ThreadSafeQuestionConn = uiInterface.ThreadSafeQuestion.connect(noui_ThreadSafeQuestionRedirect);87noui_InitMessageConn = uiInterface.InitMessage.connect(noui_InitMessageRedirect);88}90void noui_reconnect()91{92noui_ThreadSafeMessageBoxConn.disconnect();93noui_ThreadSafeQuestionConn.disconnect();94noui_InitMessageConn.disconnect();95noui_connect();96}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.