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) 2011-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_QT_PAYMENTSERVER_H6#define BITCOIN_QT_PAYMENTSERVER_H8// This class handles payment requests from clicking on9// bitcoin: URIs10//11// This is somewhat tricky, because we have to deal with12// the situation where the user clicks on a link during13// startup/initialization, when the splash-screen is up14// but the main window (and the Send Coins tab) is not.15//16// So, the strategy is:17//18// Create the server, and register the event handler,19// when the application is created. Save any URIs20// received at or during startup in a list.21//22// When startup is finished and the main window is23// shown, a signal is sent to slot uiReady(), which24// emits a receivedURI() signal for any payment25// requests that happened during startup.26//27// After startup, receivedURI() happens as usual.28//29// This class has one more feature: a static30// method that finds URIs passed in the command line31// and, if a server is running in another process,32// sends them to the server.33//35#include <qt/sendcoinsrecipient.h>37#include <QObject>38#include <QString>40class OptionsModel;42namespace interfaces {43class Node;44} // namespace interfaces46QT_BEGIN_NAMESPACE47class QApplication;48class QByteArray;49class QLocalServer;50class QUrl;51QT_END_NAMESPACE53extern const QString BITCOIN_IPC_PREFIX;55class PaymentServer : public QObject56{57Q_OBJECT59public:60// Parse URIs on command line61// Returns false on error62static void ipcParseCommandLine(int argc, char *argv[]);64// Returns true if there were URIs on the command line65// which were successfully sent to an already-running66// process.67// Note: if a payment request is given, SelectParams(MAIN/TESTNET)68// will be called so we startup in the right mode.69static bool ipcSendCommandLine();71// parent should be QApplication object72explicit PaymentServer(QObject* parent, bool startLocalServer = true);73~PaymentServer();75// OptionsModel is used for getting proxy settings and display unit76void setOptionsModel(OptionsModel *optionsModel);78Q_SIGNALS:79// Fired when a valid payment request is received80void receivedPaymentRequest(SendCoinsRecipient);82// Fired when a message should be reported to the user83void message(const QString &title, const QString &message, unsigned int style);85public Q_SLOTS:86// Signal this when the main window's UI is ready87// to display payment requests to the user88void uiReady();90// Handle an incoming URI, URI with local file scheme or file91void handleURIOrFile(const QString& s);93private Q_SLOTS:94void handleURIConnection();96protected:97// Constructor registers this on the parent QApplication to98// receive QEvent::FileOpen and QEvent:Drop events99bool eventFilter(QObject *object, QEvent *event) override;101private:102bool saveURIs{true}; // true during startup103QLocalServer* uriServer{nullptr};104OptionsModel* optionsModel{nullptr};105};107#endif // BITCOIN_QT_PAYMENTSERVER_H
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.