BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
rpcconsole.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2018 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_RPCCONSOLE_H
6 #define BITCOIN_QT_RPCCONSOLE_H
7 
8 #include <qt/guiutil.h>
9 #include <qt/peertablemodel.h>
10 
11 #include <net.h>
12 
13 #include <QWidget>
14 #include <QCompleter>
15 #include <QThread>
16 
17 class ClientModel;
18 class PlatformStyle;
19 class RPCTimerInterface;
20 class WalletModel;
21 
22 namespace interfaces {
23  class Node;
24 }
25 
26 namespace Ui {
27  class RPCConsole;
28 }
29 
30 QT_BEGIN_NAMESPACE
31 class QMenu;
32 class QItemSelection;
33 QT_END_NAMESPACE
34 
36 class RPCConsole: public QWidget
37 {
38  Q_OBJECT
39 
40 public:
41  explicit RPCConsole(interfaces::Node& node, const PlatformStyle *platformStyle, QWidget *parent);
42  ~RPCConsole();
43 
44  static bool RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = nullptr, const std::string *walletID = nullptr);
45  static bool RPCExecuteCommandLine(interfaces::Node& node, std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = nullptr, const std::string *walletID = nullptr) {
46  return RPCParseCommandLine(&node, strResult, strCommand, true, pstrFilteredOut, walletID);
47  }
48 
49  void setClientModel(ClientModel *model);
50  void addWallet(WalletModel * const walletModel);
51  void removeWallet(WalletModel* const walletModel);
52 
53  enum MessageClass {
59  };
60 
61  enum TabTypes {
62  TAB_INFO = 0,
64  TAB_GRAPH = 2,
66  };
67 
68 protected:
69  virtual bool eventFilter(QObject* obj, QEvent *event);
70  void keyPressEvent(QKeyEvent *);
71 
72 private Q_SLOTS:
74  void on_tabWidget_currentChanged(int index);
78  void on_sldGraphRange_valueChanged(int value);
80  void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut);
81  void resizeEvent(QResizeEvent *event);
82  void showEvent(QShowEvent *event);
83  void hideEvent(QHideEvent *event);
85  void showPeersTableContextMenu(const QPoint& point);
87  void showBanTableContextMenu(const QPoint& point);
91  void clearSelectedNode();
92 
93 public Q_SLOTS:
94  void clear(bool clearHistory = true);
95  void fontBigger();
96  void fontSmaller();
97  void setFontSize(int newSize);
99  void message(int category, const QString &msg) { message(category, msg, false); }
100  void message(int category, const QString &message, bool html);
102  void setNumConnections(int count);
104  void setNetworkActive(bool networkActive);
106  void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers);
108  void setMempoolSize(long numberOfTxs, size_t dynUsage);
110  void browseHistory(int offset);
112  void scrollToEnd();
114  void peerSelected(const QItemSelection &selected, const QItemSelection &deselected);
118  void peerLayoutChanged();
120  void disconnectSelectedNode();
122  void banSelectedNode(int bantime);
124  void unbanSelectedNode();
126  void setTabFocus(enum TabTypes tabType);
127 
128 Q_SIGNALS:
129  // For RPC command executor
130  void stopExecutor();
131  void cmdRequest(const QString &command, const QString &walletID);
132 
133 private:
134  void startExecutor();
135  void setTrafficGraphRange(int mins);
137  void updateNodeDetail(const CNodeCombinedStats *stats);
138 
140  {
146 
147  };
148 
150  Ui::RPCConsole* const ui;
152  QStringList history;
153  int historyPtr = 0;
155  QList<NodeId> cachedNodeids;
158  QMenu *peersTableContextMenu = nullptr;
159  QMenu *banTableContextMenu = nullptr;
161  QCompleter *autoCompleter = nullptr;
162  QThread thread;
164 
166  void updateNetworkState();
167 };
168 
169 #endif // BITCOIN_QT_RPCCONSOLE_H
void addWallet(WalletModel *const walletModel)
QString m_last_wallet_id
Definition: rpcconsole.h:163
Local Bitcoin RPC console.
Definition: rpcconsole.h:36
RPC timer "driver".
Definition: server.h:101
void keyPressEvent(QKeyEvent *)
Definition: rpcconsole.cpp:823
QString cmdBeforeBrowsing
Definition: rpcconsole.h:154
void showEvent(QShowEvent *event)
void on_lineEdit_returnPressed()
Definition: rpcconsole.cpp:891
void showPeersTableContextMenu(const QPoint &point)
Show custom context menu on Peers tab.
QStringList history
Definition: rpcconsole.h:152
interfaces::Node & m_node
Definition: rpcconsole.h:149
QThread thread
Definition: rpcconsole.h:162
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
Definition: rpcconsole.cpp:868
void scrollToEnd()
Scroll console view to end.
void clearSelectedNode()
clear the selected node
RPCConsole(interfaces::Node &node, const PlatformStyle *platformStyle, QWidget *parent)
Definition: rpcconsole.cpp:449
void fontSmaller()
Definition: rpcconsole.cpp:742
void disconnectSelectedNode()
Disconnect a selected node on the Peers tab.
void cmdRequest(const QString &command, const QString &walletID)
void on_tabWidget_currentChanged(int index)
Definition: rpcconsole.cpp:993
void updateNodeDetail(const CNodeCombinedStats *stats)
show detailed information on ui about selected node
void setClientModel(ClientModel *model)
Definition: rpcconsole.cpp:563
void resizeEvent(QResizeEvent *event)
const PlatformStyle *const platformStyle
Definition: rpcconsole.h:156
QMenu * peersTableContextMenu
Definition: rpcconsole.h:158
void browseHistory(int offset)
Go forward or back in history.
Definition: rpcconsole.cpp:950
void message(int category, const QString &msg)
Append the message to the message widget.
Definition: rpcconsole.h:99
void setTabFocus(enum TabTypes tabType)
set which tab has the focus (is visible)
int historyPtr
Definition: rpcconsole.h:153
void peerLayoutChanged()
Handle updated peer information.
RPCTimerInterface * rpcTimerInterface
Definition: rpcconsole.h:157
void updateNetworkState()
Update UI with latest network info from model.
Definition: rpcconsole.cpp:847
static bool RPCParseCommandLine(interfaces::Node *node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string *const pstrFilteredOut=nullptr, const std::string *walletID=nullptr)
Split shell command line into a list of arguments and optionally execute the command(s).
Definition: rpcconsole.cpp:151
void on_openDebugLogfileButton_clicked()
open the debug.log from the current datadir
Model for Bitcoin network client.
Definition: clientmodel.h:44
void unbanSelectedNode()
Unban a selected node on the Bans tab.
void hideEvent(QHideEvent *event)
ClientModel * clientModel
Definition: rpcconsole.h:151
virtual bool eventFilter(QObject *obj, QEvent *event)
Definition: rpcconsole.cpp:518
QMenu * banTableContextMenu
Definition: rpcconsole.h:159
void setTrafficGraphRange(int mins)
void clear(bool clearHistory=true)
Definition: rpcconsole.cpp:772
void showOrHideBanTableIfRequired()
Hides ban table if no bans are present.
void fontBigger()
Definition: rpcconsole.cpp:737
void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
update traffic statistics
QList< NodeId > cachedNodeids
Definition: rpcconsole.h:155
void setMempoolSize(long numberOfTxs, size_t dynUsage)
Set size (number of transactions and memory usage) of the mempool in the UI.
Definition: rpcconsole.cpp:881
void setFontSize(int newSize)
Definition: rpcconsole.cpp:747
void setNumConnections(int count)
Set number of connections shown in the UI.
Definition: rpcconsole.cpp:860
void startExecutor()
Definition: rpcconsole.cpp:971
void peerLayoutAboutToChange()
Handle selection caching before update.
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:125
void on_sldGraphRange_valueChanged(int value)
change the time range of the network traffic graph
void banSelectedNode(int bantime)
Ban a selected node on the Peers tab.
Ui::RPCConsole *const ui
Definition: rpcconsole.h:150
void removeWallet(WalletModel *const walletModel)
int consoleFontSize
Definition: rpcconsole.h:160
void peerSelected(const QItemSelection &selected, const QItemSelection &deselected)
Handle selection of peer in peers list.
static bool RPCExecuteCommandLine(interfaces::Node &node, std::string &strResult, const std::string &strCommand, std::string *const pstrFilteredOut=nullptr, const std::string *walletID=nullptr)
Definition: rpcconsole.h:45
QCompleter * autoCompleter
Definition: rpcconsole.h:161
void stopExecutor()
Top-level interface for a bitcoin node (bsha3d process).
Definition: node.h:35
void setNumBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, bool headers)
Set number of blocks and last block date shown in the UI.
Definition: rpcconsole.cpp:873
void showBanTableContextMenu(const QPoint &point)
Show custom context menu on Bans tab.