Changeset View
Changeset View
Standalone View
Standalone View
src/qt/paymentserver.h
Show All 22 Lines | |||||
// | // | ||||
// After startup, receivedURI() happens as usual. | // After startup, receivedURI() happens as usual. | ||||
// | // | ||||
// This class has one more feature: a static method that finds URIs passed in | // This class has one more feature: a static method that finds URIs passed in | ||||
// the command line and, if a server is running in another process, sends them | // the command line and, if a server is running in another process, sends them | ||||
// to the server. | // to the server. | ||||
// | // | ||||
#if defined(HAVE_CONFIG_H) | |||||
#include <config/bitcoin-config.h> | |||||
#endif | |||||
#ifdef ENABLE_BIP70 | |||||
#include <qt/paymentrequestplus.h> | #include <qt/paymentrequestplus.h> | ||||
#endif | |||||
#include <qt/walletmodel.h> | #include <qt/walletmodel.h> | ||||
#include <QObject> | #include <QObject> | ||||
#include <QString> | #include <QString> | ||||
class OptionsModel; | class OptionsModel; | ||||
QT_BEGIN_NAMESPACE | QT_BEGIN_NAMESPACE | ||||
Show All 26 Lines | public: | ||||
// parent should be QApplication object | // parent should be QApplication object | ||||
explicit PaymentServer(QObject *parent, bool startLocalServer = true); | explicit PaymentServer(QObject *parent, bool startLocalServer = true); | ||||
~PaymentServer(); | ~PaymentServer(); | ||||
// OptionsModel is used for getting proxy settings and display unit | // OptionsModel is used for getting proxy settings and display unit | ||||
void setOptionsModel(OptionsModel *optionsModel); | void setOptionsModel(OptionsModel *optionsModel); | ||||
#ifdef ENABLE_BIP70 | |||||
// Load root certificate authorities. Pass nullptr (default) to read from | // Load root certificate authorities. Pass nullptr (default) to read from | ||||
// the file specified in the -rootcertificates setting, or, if that's not | // the file specified in the -rootcertificates setting, or, if that's not | ||||
// set, to use the system default root certificates. If you pass in a store, | // set, to use the system default root certificates. If you pass in a store, | ||||
// you should not X509_STORE_free it: it will be freed either at exit or | // you should not X509_STORE_free it: it will be freed either at exit or | ||||
// when another set of CAs are loaded. | // when another set of CAs are loaded. | ||||
static void LoadRootCAs(X509_STORE *store = nullptr); | static void LoadRootCAs(X509_STORE *store = nullptr); | ||||
// Return certificate store | // Return certificate store | ||||
static X509_STORE *getCertStore(); | static X509_STORE *getCertStore(); | ||||
// Verify that the payment request network matches the client network | // Verify that the payment request network matches the client network | ||||
static bool verifyNetwork(interfaces::Node &node, | static bool verifyNetwork(interfaces::Node &node, | ||||
const payments::PaymentDetails &requestDetails); | const payments::PaymentDetails &requestDetails); | ||||
// Verify if the payment request is expired | // Verify if the payment request is expired | ||||
static bool verifyExpired(const payments::PaymentDetails &requestDetails); | static bool verifyExpired(const payments::PaymentDetails &requestDetails); | ||||
// Verify the payment request size is valid as per BIP70 | // Verify the payment request size is valid as per BIP70 | ||||
static bool verifySize(qint64 requestSize); | static bool verifySize(qint64 requestSize); | ||||
// Verify the payment request amount is valid | // Verify the payment request amount is valid | ||||
static bool verifyAmount(const Amount requestAmount); | static bool verifyAmount(const Amount requestAmount); | ||||
#endif | |||||
Q_SIGNALS: | Q_SIGNALS: | ||||
// Fired when a valid payment request is received | // Fired when a valid payment request is received | ||||
void receivedPaymentRequest(SendCoinsRecipient); | void receivedPaymentRequest(SendCoinsRecipient); | ||||
// Fired when a message should be reported to the user | // Fired when a message should be reported to the user | ||||
void message(const QString &title, const QString &message, | void message(const QString &title, const QString &message, | ||||
unsigned int style); | unsigned int style); | ||||
#ifdef ENABLE_BIP70 | |||||
// Fired when a valid PaymentACK is received | // Fired when a valid PaymentACK is received | ||||
void receivedPaymentACK(const QString &paymentACKMsg); | void receivedPaymentACK(const QString &paymentACKMsg); | ||||
#endif | |||||
public Q_SLOTS: | public Q_SLOTS: | ||||
// Signal this when the main window's UI is ready to display payment | // Signal this when the main window's UI is ready to display payment | ||||
// requests to the user | // requests to the user | ||||
void uiReady(); | void uiReady(); | ||||
// Handle an incoming URI, URI with local file scheme or file | // Handle an incoming URI, URI with local file scheme or file | ||||
void handleURIOrFile(const QString &s); | void handleURIOrFile(const QString &s); | ||||
#ifdef ENABLE_BIP70 | |||||
// Submit Payment message to a merchant, get back PaymentACK: | // Submit Payment message to a merchant, get back PaymentACK: | ||||
void fetchPaymentACK(WalletModel *walletModel, | void fetchPaymentACK(WalletModel *walletModel, | ||||
const SendCoinsRecipient &recipient, | const SendCoinsRecipient &recipient, | ||||
QByteArray transaction); | QByteArray transaction); | ||||
#endif | |||||
private Q_SLOTS: | private Q_SLOTS: | ||||
void handleURIConnection(); | void handleURIConnection(); | ||||
#ifdef ENABLE_BIP70 | |||||
void netRequestFinished(QNetworkReply *); | void netRequestFinished(QNetworkReply *); | ||||
void reportSslErrors(QNetworkReply *, const QList<QSslError> &); | void reportSslErrors(QNetworkReply *, const QList<QSslError> &); | ||||
void handlePaymentACK(const QString &paymentACKMsg); | void handlePaymentACK(const QString &paymentACKMsg); | ||||
#endif | |||||
protected: | protected: | ||||
// Constructor registers this on the parent QApplication to receive | // Constructor registers this on the parent QApplication to receive | ||||
// QEvent::FileOpen and QEvent:Drop events | // QEvent::FileOpen and QEvent:Drop events | ||||
bool eventFilter(QObject *object, QEvent *event) override; | bool eventFilter(QObject *object, QEvent *event) override; | ||||
private: | private: | ||||
// true during startup | // true during startup | ||||
bool saveURIs; | bool saveURIs; | ||||
QLocalServer *uriServer; | QLocalServer *uriServer; | ||||
OptionsModel *optionsModel; | OptionsModel *optionsModel; | ||||
bool handleURI(const CChainParams ¶ms, const QString &s); | bool handleURI(const CChainParams ¶ms, const QString &s); | ||||
#ifdef ENABLE_BIP70 | |||||
static bool readPaymentRequestFromFile(const QString &filename, | static bool readPaymentRequestFromFile(const QString &filename, | ||||
PaymentRequestPlus &request); | PaymentRequestPlus &request); | ||||
bool processPaymentRequest(const PaymentRequestPlus &request, | bool processPaymentRequest(const PaymentRequestPlus &request, | ||||
SendCoinsRecipient &recipient); | SendCoinsRecipient &recipient); | ||||
void fetchRequest(const QUrl &url); | void fetchRequest(const QUrl &url); | ||||
// Setup networking | // Setup networking | ||||
void initNetManager(); | void initNetManager(); | ||||
// Used to fetch payment requests | // Used to fetch payment requests | ||||
QNetworkAccessManager *netManager; | QNetworkAccessManager *netManager; | ||||
#endif | |||||
}; | }; | ||||
#endif // BITCOIN_QT_PAYMENTSERVER_H | #endif // BITCOIN_QT_PAYMENTSERVER_H |