Bitcoin Core 22.99.0
P2P Digital Currency
paymentserver.h
Go to the documentation of this file.
1// Copyright (c) 2011-2020 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_QT_PAYMENTSERVER_H
6#define BITCOIN_QT_PAYMENTSERVER_H
7
8// This class handles payment requests from clicking on
9// bitcoin: URIs
10//
11// This is somewhat tricky, because we have to deal with
12// the situation where the user clicks on a link during
13// startup/initialization, when the splash-screen is up
14// 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 URIs
20// received at or during startup in a list.
21//
22// When startup is finished and the main window is
23// shown, a signal is sent to slot uiReady(), which
24// emits a receivedURI() signal for any payment
25// requests that happened during startup.
26//
27// After startup, receivedURI() happens as usual.
28//
29// This class has one more feature: a static
30// method that finds URIs passed in the command line
31// and, if a server is running in another process,
32// sends them to the server.
33//
34
35#if defined(HAVE_CONFIG_H)
37#endif
38
40
41#include <QObject>
42#include <QString>
43
44class OptionsModel;
45
46namespace interfaces {
47class Node;
48} // namespace interfaces
49
50QT_BEGIN_NAMESPACE
51class QApplication;
52class QByteArray;
53class QLocalServer;
54class QUrl;
55QT_END_NAMESPACE
56
57class PaymentServer : public QObject
58{
59 Q_OBJECT
60
61public:
62 // Parse URIs on command line
63 // Returns false on error
64 static void ipcParseCommandLine(int argc, char *argv[]);
65
66 // Returns true if there were URIs on the command line
67 // which were successfully sent to an already-running
68 // process.
69 // Note: if a payment request is given, SelectParams(MAIN/TESTNET)
70 // will be called so we startup in the right mode.
71 static bool ipcSendCommandLine();
72
73 // parent should be QApplication object
74 explicit PaymentServer(QObject* parent, bool startLocalServer = true);
76
77 // OptionsModel is used for getting proxy settings and display unit
79
80Q_SIGNALS:
81 // Fired when a valid payment request is received
83
84 // Fired when a message should be reported to the user
85 void message(const QString &title, const QString &message, unsigned int style);
86
87public Q_SLOTS:
88 // Signal this when the main window's UI is ready
89 // to display payment requests to the user
90 void uiReady();
91
92 // Handle an incoming URI, URI with local file scheme or file
93 void handleURIOrFile(const QString& s);
94
95private Q_SLOTS:
97
98protected:
99 // Constructor registers this on the parent QApplication to
100 // receive QEvent::FileOpen and QEvent:Drop events
101 bool eventFilter(QObject *object, QEvent *event) override;
102
103private:
104 bool saveURIs; // true during startup
105 QLocalServer* uriServer;
107};
108
109#endif // BITCOIN_QT_PAYMENTSERVER_H
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:39
static bool ipcSendCommandLine()
void setOptionsModel(OptionsModel *optionsModel)
PaymentServer(QObject *parent, bool startLocalServer=true)
void message(const QString &title, const QString &message, unsigned int style)
void handleURIConnection()
static void ipcParseCommandLine(int argc, char *argv[])
QLocalServer * uriServer
void receivedPaymentRequest(SendCoinsRecipient)
bool eventFilter(QObject *object, QEvent *event) override
void handleURIOrFile(const QString &s)
OptionsModel * optionsModel