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) 2014-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#include <qt/networkstyle.h>7#include <qt/guiconstants.h>9#include <tinyformat.h>10#include <util/chaintype.h>12#include <QApplication>14static const struct {15const ChainType networkId;16const char *appName;17const int iconColorHueShift;18const int iconColorSaturationReduction;19} network_styles[] = {20{ChainType::MAIN, QAPP_APP_NAME_DEFAULT, 0, 0},21{ChainType::TESTNET, QAPP_APP_NAME_TESTNET, 70, 30},22{ChainType::TESTNET4, QAPP_APP_NAME_TESTNET4, 70, 30},23{ChainType::SIGNET, QAPP_APP_NAME_SIGNET, 35, 15},24{ChainType::REGTEST, QAPP_APP_NAME_REGTEST, 160, 30},25};27// titleAddText needs to be const char* for tr()28NetworkStyle::NetworkStyle(const QString &_appName, const int iconColorHueShift, const int iconColorSaturationReduction, const char *_titleAddText):29appName(_appName),30titleAddText(qApp->translate("SplashScreen", _titleAddText))31{32// load pixmap33QPixmap pixmap(":/icons/bitcoin");35if(iconColorHueShift != 0 && iconColorSaturationReduction != 0)36{37// generate QImage from QPixmap38QImage img = pixmap.toImage();40int h,s,l,a;42// traverse though lines43for(int y=0;y<img.height();y++)44{45QRgb *scL = reinterpret_cast< QRgb *>( img.scanLine( y ) );47// loop through pixels48for(int x=0;x<img.width();x++)49{50// preserve alpha because QColor::getHsl doesn't return the alpha value51a = qAlpha(scL[x]);52QColor col(scL[x]);54// get hue value55col.getHsl(&h,&s,&l);57// rotate color on RGB color circle58// 70° should end up with the typical "testnet" green59h+=iconColorHueShift;61// change saturation value62if(s>iconColorSaturationReduction)63{64s -= iconColorSaturationReduction;65}66col.setHsl(h,s,l,a);68// set the pixel69scL[x] = col.rgba();70}71}73//convert back to QPixmap74pixmap.convertFromImage(img);75}77appIcon = QIcon(pixmap);78trayAndWindowIcon = QIcon(pixmap.scaled(QSize(256,256)));79}81const NetworkStyle* NetworkStyle::instantiate(const ChainType networkId)82{83std::string titleAddText = networkId == ChainType::MAIN ? "" : strprintf("[%s]", ChainTypeToString(networkId));84for (const auto& network_style : network_styles) {85if (networkId == network_style.networkId) {86return new NetworkStyle(87network_style.appName,88network_style.iconColorHueShift,89network_style.iconColorSaturationReduction,90titleAddText.c_str());91}92}93return nullptr;94}
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.