Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
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#include <qt/clientmodel.h>
9#include <qt/guiutil.h>
10#include <qt/peertablemodel.h>
11
12#include <net.h>
13
14#include <QCompleter>
15#include <QThread>
16#include <QWidget>
17
18class PlatformStyle;
20class WalletModel;
21
22namespace interfaces {
23class Node;
24}
25
26namespace Ui {
27class RPCConsole;
28}
29
31class QMenu;
32class QItemSelection;
34
36class RPCConsole : public QWidget {
38
39public:
41 const PlatformStyle *platformStyle, QWidget *parent);
43
44 static bool
46 const std::string &strCommand, bool fExecute,
47 std::string *const pstrFilteredOut = nullptr,
48 const WalletModel *wallet_model = nullptr);
49 static bool
51 const std::string &strCommand,
52 std::string *const pstrFilteredOut = nullptr,
53 const WalletModel *wallet_model = nullptr) {
56 }
57
58 void setClientModel(ClientModel *model = nullptr, int bestblock_height = 0,
60 double verification_progress = 0.0);
61 void addWallet(WalletModel *const walletModel);
62 void removeWallet(WalletModel *const walletModel);
63
65
66 enum class TabTypes { INFO, CONSOLE, GRAPH, PEERS };
67
68 std::vector<TabTypes> tabs() const {
71 }
72
75
76protected:
77 virtual bool eventFilter(QObject *obj, QEvent *event) override;
78 void keyPressEvent(QKeyEvent *) override;
79
80private Q_SLOTS:
82 void on_tabWidget_currentChanged(int index);
86 void on_sldGraphRange_valueChanged(int value);
89 void resizeEvent(QResizeEvent *event) override;
90 void showEvent(QShowEvent *event) override;
91 void hideEvent(QHideEvent *event) override;
93 void showPeersTableContextMenu(const QPoint &point);
95 void showBanTableContextMenu(const QPoint &point);
99 void clearSelectedNode();
101 void updateDetailWidget();
102
103public Q_SLOTS:
104 void clear(bool clearHistory = true);
105 void fontBigger();
106 void fontSmaller();
107 void setFontSize(int newSize);
109 void message(int category, const QString &msg) {
110 message(category, msg, false);
111 }
112 void message(int category, const QString &message, bool html);
114 void setNumConnections(int count);
118 void setNumBlocks(int count, const QDateTime &blockDate,
122 void setMempoolSize(long numberOfTxs, size_t dynUsage);
124 void browseHistory(int offset);
126 void scrollToEnd();
130 void peerLayoutChanged();
134 void banSelectedNode(int bantime);
136 void unbanSelectedNode();
138 void setTabFocus(enum TabTypes tabType);
139
141 // For RPC command executor
143
144private:
145 void startExecutor();
146 void setTrafficGraphRange(int mins);
147
156
158 Ui::RPCConsole *const ui;
161 int historyPtr = 0;
172
174 void updateNetworkState();
175
180 QString TimeDurationField(std::chrono::seconds time_now,
181 std::chrono::seconds time_at_event) const {
182 return time_at_event.count()
184 : tr("Never");
185 }
186
187private Q_SLOTS:
188 void updateAlerts(const QString &warnings);
189};
190
191#endif // BITCOIN_QT_RPCCONSOLE_H
Model for Bitcoin network client.
Definition clientmodel.h:43
Local Bitcoin RPC console.
Definition rpcconsole.h:36
QMenu * peersTableContextMenu
Definition rpcconsole.h:166
void cmdRequest(const QString &command, const WalletModel *wallet_model)
std::vector< TabTypes > tabs() const
Definition rpcconsole.h:68
void browseHistory(int offset)
Go forward or back in history.
void fontSmaller()
RPCTimerInterface * rpcTimerInterface
Definition rpcconsole.h:165
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:180
void on_lineEdit_returnPressed()
QStringList history
Definition rpcconsole.h:160
void message(int category, const QString &msg)
Append the message to the message widget.
Definition rpcconsole.h:109
void setFontSize(int newSize)
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).
const PlatformStyle *const platformStyle
Definition rpcconsole.h:164
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:50
QString tabTitle(TabTypes tab_type) const
void updateNetworkState()
Update UI with latest network info from model.
void disconnectSelectedNode()
Disconnect a selected node on the Peers tab.
@ BANTIME_COLUMN_WIDTH
Definition rpcconsole.h:153
@ ADDRESS_COLUMN_WIDTH
Definition rpcconsole.h:149
@ SUBVERSION_COLUMN_WIDTH
Definition rpcconsole.h:150
@ PING_COLUMN_WIDTH
Definition rpcconsole.h:151
@ BANSUBNET_COLUMN_WIDTH
Definition rpcconsole.h:152
QCompleter * autoCompleter
Definition rpcconsole.h:169
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)
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:163
interfaces::Node & m_node
Definition rpcconsole.h:157
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:168
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:159
void banSelectedNode(int bantime)
Ban a selected node on the Peers tab.
void scrollToEnd()
Scroll console view to end.
void keyPressEvent(QKeyEvent *) override
void on_tabWidget_currentChanged(int index)
Ui::RPCConsole *const ui
Definition rpcconsole.h:158
void startExecutor()
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
void fontBigger()
QString cmdBeforeBrowsing
Definition rpcconsole.h:162
void addWallet(WalletModel *const walletModel)
virtual bool eventFilter(QObject *obj, QEvent *event) override
void on_openDebugLogfileButton_clicked()
open the debug.log from the current datadir
void removeWallet(WalletModel *const walletModel)
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)
void setTabFocus(enum TabTypes tabType)
set which tab has the focus (is visible)
WalletModel * m_last_wallet_model
Definition rpcconsole.h:171
void showOrHideBanTableIfRequired()
Hides ban table if no bans are present.
QMenu * banTableContextMenu
Definition rpcconsole.h:167
QThread thread
Definition rpcconsole.h:170
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:58
SyncType
Definition clientmodel.h:40
QString formatDurationStr(std::chrono::seconds dur)
Convert seconds into a QString with days, hours, mins, secs.
Definition guiutil.cpp:811
Definition init.h:28
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
static int count
Definition tests.c:31