Bitcoin ABC 0.32.4
P2P Digital Currency
rpcconsole.h
Go to the documentation of this file.
1// Copyright (c) 2011-2019 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#if defined(HAVE_CONFIG_H)
9#include <config/bitcoin-config.h>
10#endif
11
12#include <qt/clientmodel.h>
13#include <qt/guiutil.h>
14#include <qt/peertablemodel.h>
15
16#include <net.h>
17
18#include <QCompleter>
19#include <QThread>
20#include <QWidget>
21
22class PlatformStyle;
23class RPCExecutor;
25class WalletModel;
26
27namespace interfaces {
28class Node;
29}
30
31namespace Ui {
32class RPCConsole;
33}
34
35QT_BEGIN_NAMESPACE
36class QMenu;
37class QItemSelection;
38QT_END_NAMESPACE
39
41class RPCConsole : public QWidget {
42 Q_OBJECT
43
44public:
46 const PlatformStyle *platformStyle, QWidget *parent);
48
49 static bool
50 RPCParseCommandLine(interfaces::Node *node, std::string &strResult,
51 const std::string &strCommand, bool fExecute,
52 std::string *const pstrFilteredOut = nullptr,
53 const WalletModel *wallet_model = nullptr);
54 static bool
56 const std::string &strCommand,
57 std::string *const pstrFilteredOut = nullptr,
58 const WalletModel *wallet_model = nullptr) {
59 return RPCParseCommandLine(&node, strResult, strCommand, true,
60 pstrFilteredOut, wallet_model);
61 }
62
63 void setClientModel(ClientModel *model = nullptr, int bestblock_height = 0,
64 int64_t bestblock_date = 0,
65 double verification_progress = 0.0);
66
67#ifdef ENABLE_WALLET
68 void addWallet(WalletModel *const walletModel);
69 void removeWallet(WalletModel *const walletModel);
70#endif // ENABLE_WALLET
71
73
74 enum class TabTypes { INFO, CONSOLE, GRAPH, PEERS };
75
76 std::vector<TabTypes> tabs() const {
79 }
80
81 QString tabTitle(TabTypes tab_type) const;
82 QKeySequence tabShortcut(TabTypes tab_type) const;
83
84protected:
85 virtual bool eventFilter(QObject *obj, QEvent *event) override;
86 void keyPressEvent(QKeyEvent *) override;
87
88private Q_SLOTS:
90 void on_tabWidget_currentChanged(int index);
94 void on_sldGraphRange_valueChanged(int value);
96 void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut);
97 void resizeEvent(QResizeEvent *event) override;
98 void showEvent(QShowEvent *event) override;
99 void hideEvent(QHideEvent *event) override;
101 void showPeersTableContextMenu(const QPoint &point);
103 void showBanTableContextMenu(const QPoint &point);
107 void clearSelectedNode();
109 void updateDetailWidget();
110
111public Q_SLOTS:
112 void clear(bool clearHistory = true);
113 void fontBigger();
114 void fontSmaller();
115 void setFontSize(int newSize);
117 void message(int category, const QString &msg) {
118 message(category, msg, false);
119 }
120 void message(int category, const QString &message, bool html);
122 void setNumConnections(int count);
124 void setNetworkActive(bool networkActive);
126 void setNumBlocks(int count, const QDateTime &blockDate,
127 double nVerificationProgress, SyncType synctype);
130 void setMempoolSize(long numberOfTxs, size_t dynUsage);
132 void browseHistory(int offset);
134 void scrollToEnd();
138 void peerLayoutChanged();
142 void banSelectedNode(int bantime);
144 void unbanSelectedNode();
146 void setTabFocus(enum TabTypes tabType);
147
148private:
149 void startExecutor();
150 void setTrafficGraphRange(int mins);
151
158
159 };
160
162 Ui::RPCConsole *const ui;
164 QStringList history;
165 int historyPtr = 0;
167 QList<NodeId> cachedNodeids;
170 QMenu *peersTableContextMenu = nullptr;
171 QMenu *banTableContextMenu = nullptr;
173 QCompleter *autoCompleter = nullptr;
174 QThread thread;
177
179 void updateNetworkState();
180
185 QString TimeDurationField(std::chrono::seconds time_now,
186 std::chrono::seconds time_at_event) const {
187 return time_at_event.count()
188 ? GUIUtil::formatDurationStr(time_now - time_at_event)
189 : tr("Never");
190 }
191
192private Q_SLOTS:
193 void updateAlerts(const QString &warnings);
194};
195
196#endif // BITCOIN_QT_RPCCONSOLE_H
Model for Bitcoin network client.
Definition: clientmodel.h:43
Local Bitcoin RPC console.
Definition: rpcconsole.h:41
QMenu * peersTableContextMenu
Definition: rpcconsole.h:170
RPCConsole(interfaces::Node &node, const PlatformStyle *platformStyle, QWidget *parent)
Definition: rpcconsole.cpp:513
std::vector< TabTypes > tabs() const
Definition: rpcconsole.h:76
void browseHistory(int offset)
Go forward or back in history.
void fontSmaller()
Definition: rpcconsole.cpp:878
RPCTimerInterface * rpcTimerInterface
Definition: rpcconsole.h:169
QString TimeDurationField(std::chrono::seconds time_now, std::chrono::seconds time_at_event) const
Helper for the output of a time duration field.
Definition: rpcconsole.h:185
void on_lineEdit_returnPressed()
QStringList history
Definition: rpcconsole.h:164
void message(int category, const QString &msg)
Append the message to the message widget.
Definition: rpcconsole.h:117
void setFontSize(int newSize)
Definition: rpcconsole.cpp:882
void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
update traffic statistics
void setTrafficGraphRange(int mins)
static bool RPCParseCommandLine(interfaces::Node *node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string *const pstrFilteredOut=nullptr, const WalletModel *wallet_model=nullptr)
Split shell command line into a list of arguments and optionally execute the command(s).
Definition: rpcconsole.cpp:149
const PlatformStyle *const platformStyle
Definition: rpcconsole.h:168
void updateDetailWidget()
show detailed information on ui about selected node
void showEvent(QShowEvent *event) override
void resizeEvent(QResizeEvent *event) override
static bool RPCExecuteCommandLine(interfaces::Node &node, std::string &strResult, const std::string &strCommand, std::string *const pstrFilteredOut=nullptr, const WalletModel *wallet_model=nullptr)
Definition: rpcconsole.h:55
QString tabTitle(TabTypes tab_type) const
void updateNetworkState()
Update UI with latest network info from model.
Definition: rpcconsole.cpp:995
void disconnectSelectedNode()
Disconnect a selected node on the Peers tab.
@ BANTIME_COLUMN_WIDTH
Definition: rpcconsole.h:157
@ ADDRESS_COLUMN_WIDTH
Definition: rpcconsole.h:153
@ SUBVERSION_COLUMN_WIDTH
Definition: rpcconsole.h:154
@ PING_COLUMN_WIDTH
Definition: rpcconsole.h:155
@ BANSUBNET_COLUMN_WIDTH
Definition: rpcconsole.h:156
QCompleter * autoCompleter
Definition: rpcconsole.h:173
void setMempoolSize(long numberOfTxs, size_t dynUsage)
Set size (number of transactions and memory usage) of the mempool in the UI.
void clear(bool clearHistory=true)
Definition: rpcconsole.cpp:912
void hideEvent(QHideEvent *event) override
QKeySequence tabShortcut(TabTypes tab_type) const
void showPeersTableContextMenu(const QPoint &point)
Show custom context menu on Peers tab.
QList< NodeId > cachedNodeids
Definition: rpcconsole.h:167
interfaces::Node & m_node
Definition: rpcconsole.h:161
void unbanSelectedNode()
Unban a selected node on the Bans tab.
void updateAlerts(const QString &warnings)
void clearSelectedNode()
clear the selected node
void on_sldGraphRange_valueChanged(int value)
change the time range of the network traffic graph
int consoleFontSize
Definition: rpcconsole.h:172
void setNumConnections(int count)
Set number of connections shown in the UI.
void setNumBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, SyncType synctype)
Set number of blocks and last block date shown in the UI.
ClientModel * clientModel
Definition: rpcconsole.h:163
void banSelectedNode(int bantime)
Ban a selected node on the Peers tab.
int historyPtr
Definition: rpcconsole.h:165
void scrollToEnd()
Scroll console view to end.
void keyPressEvent(QKeyEvent *) override
Definition: rpcconsole.cpp:971
void on_tabWidget_currentChanged(int index)
Ui::RPCConsole *const ui
Definition: rpcconsole.h:162
void startExecutor()
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
void fontBigger()
Definition: rpcconsole.cpp:874
QString cmdBeforeBrowsing
Definition: rpcconsole.h:166
virtual bool eventFilter(QObject *obj, QEvent *event) override
Definition: rpcconsole.cpp:602
void on_openDebugLogfileButton_clicked()
open the debug.log from the current datadir
void showBanTableContextMenu(const QPoint &point)
Show custom context menu on Bans tab.
void peerLayoutAboutToChange()
Handle selection caching before update.
void setClientModel(ClientModel *model=nullptr, int bestblock_height=0, int64_t bestblock_date=0, double verification_progress=0.0)
Definition: rpcconsole.cpp:654
void setTabFocus(enum TabTypes tabType)
set which tab has the focus (is visible)
WalletModel * m_last_wallet_model
Definition: rpcconsole.h:176
void showOrHideBanTableIfRequired()
Hides ban table if no bans are present.
RPCExecutor * m_executor
Definition: rpcconsole.h:175
QMenu * banTableContextMenu
Definition: rpcconsole.h:171
QThread thread
Definition: rpcconsole.h:174
void peerLayoutChanged()
Handle updated peer information.
RPC timer "driver".
Definition: server.h:100
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:47
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:59
SyncType
Definition: clientmodel.h:40
QString formatDurationStr(std::chrono::seconds dur)
Convert seconds into a QString with days, hours, mins, secs.
Definition: guiutil.cpp:817
Definition: init.h:31
static int count
Definition: tests.c:31