#ifndef RPCCLIENT_H #define RPCCLIENT_H #include "precompiled.h" #include "unspentoutput.h" #include "balancestablemodel.h" #include "txtablemodel.h" #include "ui_mainwindow.h" #include "mainwindow.h" using json = nlohmann::json; class RPC { public: RPC(QNetworkAccessManager* restclient, MainWindow* main); ~RPC(); void refresh(); // Refresh all transactions void refreshTxStatus(const QString& newOpid = QString()); // Refresh the status of all pending txs. void refreshAddresses(); // Refresh wallet Z-addrs void sendZTransaction (json params, const std::function& cb); BalancesTableModel* getBalancesModel() { return balancesTableModel; } const QList* getAllZAddresses() { return zaddresses; } const QList* getUTXOs() { return utxos; } const QMap* getAllBalances() { return allBalances; } void reloadConnectionInfo(); void newZaddr (const std::function& cb); void newTaddr (const std::function& cb); private: void doRPC (const json& payload, const std::function& cb); void doSendRPC (const json& payload, const std::function& cb); void refreshBalances(); void refreshTransactions(); void getInfoThenRefresh(); void getBalance(const std::function& cb); void getTransparentUnspent (const std::function& cb); void getZUnspent (const std::function& cb); void getTransactions (const std::function& cb); void getZAddresses (const std::function& cb); void handleConnectionError (const QString& error); void handleTxError (const QString& error); QNetworkAccessManager* restclient; QNetworkRequest request; QList* utxos = nullptr; QMap* allBalances = nullptr; QList* zaddresses = nullptr; QSet watchingOps; TxTableModel* transactionsTableModel = nullptr; BalancesTableModel* balancesTableModel = nullptr; QTimer* timer; QTimer* txTimer; Ui::MainWindow* ui; MainWindow* main; // Current balance in the UI. If this number updates, then refresh the UI QString currentBalance; // First time warning flag for no connection bool firstTime = true; }; #endif // RPCCLIENT_H