Bitcoin Core  27.99.0
P2P Digital Currency
Classes | Public Types | Public Slots | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Slots | Private Member Functions | Private Attributes | List of all members
RPCConsole Class Reference

Local Bitcoin RPC console. More...

#include <rpcconsole.h>

Inheritance diagram for RPCConsole:
[legend]
Collaboration diagram for RPCConsole:
[legend]

Classes

struct  TranslatedStrings
 

Public Types

enum  MessageClass {
  MC_ERROR , MC_DEBUG , CMD_REQUEST , CMD_REPLY ,
  CMD_ERROR
}
 
enum class  TabTypes { INFO , CONSOLE , GRAPH , PEERS }
 

Public Slots

void clear (bool keep_prompt=false)
 
void fontBigger ()
 
void fontSmaller ()
 
void setFontSize (int newSize)
 
void message (int category, const QString &msg)
 Append the message to the message widget. More...
 
void message (int category, const QString &message, bool html)
 
void setNumConnections (int count)
 Set number of connections shown in the UI. More...
 
void setNetworkActive (bool networkActive)
 Set network state shown in the UI. More...
 
void setNumBlocks (int count, const QDateTime &blockDate, double nVerificationProgress, SyncType synctype)
 Set number of blocks and last block date shown in the UI. More...
 
void setMempoolSize (long numberOfTxs, size_t dynUsage)
 Set size (number of transactions and memory usage) of the mempool in the UI. More...
 
void browseHistory (int offset)
 Go forward or back in history. More...
 
void scrollToEnd ()
 Scroll console view to end. More...
 
void disconnectSelectedNode ()
 Disconnect a selected node on the Peers tab. More...
 
void banSelectedNode (int bantime)
 Ban a selected node on the Peers tab. More...
 
void unbanSelectedNode ()
 Unban a selected node on the Bans tab. More...
 
void setTabFocus (enum TabTypes tabType)
 set which tab has the focus (is visible) More...
 

Public Member Functions

 RPCConsole (interfaces::Node &node, const PlatformStyle *platformStyle, QWidget *parent)
 
 ~RPCConsole ()
 
void setClientModel (ClientModel *model=nullptr, int bestblock_height=0, int64_t bestblock_date=0, double verification_progress=0.0)
 
std::vector< TabTypestabs () const
 
QString tabTitle (TabTypes tab_type) const
 
QKeySequence tabShortcut (TabTypes tab_type) const
 

Static Public Member Functions

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). More...
 
static bool RPCExecuteCommandLine (interfaces::Node &node, std::string &strResult, const std::string &strCommand, std::string *const pstrFilteredOut=nullptr, const WalletModel *wallet_model=nullptr)
 

Protected Member Functions

virtual bool eventFilter (QObject *obj, QEvent *event) override
 
void keyPressEvent (QKeyEvent *) override
 
void changeEvent (QEvent *e) override
 

Private Types

enum  ColumnWidths {
  ADDRESS_COLUMN_WIDTH = 200 , SUBVERSION_COLUMN_WIDTH = 150 , PING_COLUMN_WIDTH = 80 , BANSUBNET_COLUMN_WIDTH = 200 ,
  BANTIME_COLUMN_WIDTH = 250
}
 

Private Slots

void on_lineEdit_returnPressed ()
 
void on_tabWidget_currentChanged (int index)
 
void on_openDebugLogfileButton_clicked ()
 open the debug.log from the current datadir More...
 
void on_sldGraphRange_valueChanged (int value)
 change the time range of the network traffic graph More...
 
void updateTrafficStats (quint64 totalBytesIn, quint64 totalBytesOut)
 update traffic statistics More...
 
void resizeEvent (QResizeEvent *event) override
 
void showEvent (QShowEvent *event) override
 
void hideEvent (QHideEvent *event) override
 
void showPeersTableContextMenu (const QPoint &point)
 Show custom context menu on Peers tab. More...
 
void showBanTableContextMenu (const QPoint &point)
 Show custom context menu on Bans tab. More...
 
void showOrHideBanTableIfRequired ()
 Hides ban table if no bans are present. More...
 
void clearSelectedNode ()
 clear the selected node More...
 
void updateDetailWidget ()
 show detailed information on ui about selected node More...
 
void updateAlerts (const QString &warnings)
 

Private Member Functions

void startExecutor ()
 
void setTrafficGraphRange (int mins)
 
void updateNetworkState ()
 Update UI with latest network info from model. More...
 
QString TimeDurationField (std::chrono::seconds time_now, std::chrono::seconds time_at_event) const
 Helper for the output of a time duration field. More...
 
void updateWindowTitle ()
 

Private Attributes

struct RPCConsole::TranslatedStrings ts
 
interfaces::Nodem_node
 
Ui::RPCConsole *const ui
 
ClientModelclientModel = nullptr
 
QStringList history
 
int historyPtr = 0
 
QString cmdBeforeBrowsing
 
QList< NodeIdcachedNodeids
 
const PlatformStyle *const platformStyle
 
RPCTimerInterfacerpcTimerInterface = nullptr
 
QMenu * peersTableContextMenu = nullptr
 
QMenu * banTableContextMenu = nullptr
 
int consoleFontSize = 0
 
QCompleter * autoCompleter = nullptr
 
QThread thread
 
RPCExecutorm_executor {nullptr}
 
WalletModelm_last_wallet_model {nullptr}
 
bool m_is_executing {false}
 
QByteArray m_peer_widget_header_state
 
QByteArray m_banlist_widget_header_state
 

Detailed Description

Local Bitcoin RPC console.

Definition at line 43 of file rpcconsole.h.

Member Enumeration Documentation

◆ ColumnWidths

Enumerator
ADDRESS_COLUMN_WIDTH 
SUBVERSION_COLUMN_WIDTH 
PING_COLUMN_WIDTH 
BANSUBNET_COLUMN_WIDTH 
BANTIME_COLUMN_WIDTH 

Definition at line 153 of file rpcconsole.h.

◆ MessageClass

Enumerator
MC_ERROR 
MC_DEBUG 
CMD_REQUEST 
CMD_REPLY 
CMD_ERROR 

Definition at line 63 of file rpcconsole.h.

◆ TabTypes

enum RPCConsole::TabTypes
strong
Enumerator
INFO 
CONSOLE 
GRAPH 
PEERS 

Definition at line 71 of file rpcconsole.h.

Constructor & Destructor Documentation

◆ RPCConsole()

RPCConsole::RPCConsole ( interfaces::Node node,
const PlatformStyle platformStyle,
QWidget *  parent 
)
explicit

Definition at line 467 of file rpcconsole.cpp.

Here is the call graph for this function:

◆ ~RPCConsole()

RPCConsole::~RPCConsole ( )

Definition at line 588 of file rpcconsole.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ banSelectedNode

void RPCConsole::banSelectedNode ( int  bantime)
slot

Ban a selected node on the Peers tab.

Definition at line 1315 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browseHistory

void RPCConsole::browseHistory ( int  offset)
slot

Go forward or back in history.

Definition at line 1086 of file rpcconsole.cpp.

Here is the caller graph for this function:

◆ changeEvent()

void RPCConsole::changeEvent ( QEvent *  e)
overrideprotected

Definition at line 932 of file rpcconsole.cpp.

Here is the call graph for this function:

◆ clear

void RPCConsole::clear ( bool  keep_prompt = false)
slot

Definition at line 866 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearSelectedNode

void RPCConsole::clearSelectedNode ( )
privateslot

clear the selected node

Definition at line 1349 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disconnectSelectedNode

void RPCConsole::disconnectSelectedNode ( )
slot

Disconnect a selected node on the Peers tab.

Definition at line 1301 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventFilter()

bool RPCConsole::eventFilter ( QObject *  obj,
QEvent *  event 
)
overrideprotectedvirtual

Definition at line 611 of file rpcconsole.cpp.

Here is the call graph for this function:

◆ fontBigger

void RPCConsole::fontBigger ( )
slot

Definition at line 831 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fontSmaller

void RPCConsole::fontSmaller ( )
slot

Definition at line 836 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hideEvent

void RPCConsole::hideEvent ( QHideEvent *  event)
overrideprivateslot

Definition at line 1271 of file rpcconsole.cpp.

Here is the call graph for this function:

◆ keyPressEvent()

void RPCConsole::keyPressEvent ( QKeyEvent *  event)
overrideprotected

Definition at line 925 of file rpcconsole.cpp.

Here is the call graph for this function:

◆ message [1/2]

void RPCConsole::message ( int  category,
const QString &  message,
bool  html 
)
slot

Definition at line 951 of file rpcconsole.cpp.

Here is the call graph for this function:

◆ message [2/2]

void RPCConsole::message ( int  category,
const QString &  msg 
)
inlineslot

Append the message to the message widget.

Definition at line 117 of file rpcconsole.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_lineEdit_returnPressed

void RPCConsole::on_lineEdit_returnPressed ( )
privateslot

Definition at line 1013 of file rpcconsole.cpp.

Here is the call graph for this function:

◆ on_openDebugLogfileButton_clicked

void RPCConsole::on_openDebugLogfileButton_clicked ( )
privateslot

open the debug.log from the current datadir

Definition at line 1139 of file rpcconsole.cpp.

Here is the call graph for this function:

◆ on_sldGraphRange_valueChanged

void RPCConsole::on_sldGraphRange_valueChanged ( int  value)
privateslot

change the time range of the network traffic graph

Definition at line 1150 of file rpcconsole.cpp.

Here is the call graph for this function:

◆ on_tabWidget_currentChanged

void RPCConsole::on_tabWidget_currentChanged ( int  index)
privateslot

Definition at line 1132 of file rpcconsole.cpp.

◆ resizeEvent

void RPCConsole::resizeEvent ( QResizeEvent *  event)
overrideprivateslot

Definition at line 1255 of file rpcconsole.cpp.

◆ RPCExecuteCommandLine()

static bool RPCConsole::RPCExecuteCommandLine ( interfaces::Node node,
std::string &  strResult,
const std::string &  strCommand,
std::string *const  pstrFilteredOut = nullptr,
const WalletModel wallet_model = nullptr 
)
inlinestatic

Definition at line 52 of file rpcconsole.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RPCParseCommandLine()

bool RPCConsole::RPCParseCommandLine ( interfaces::Node node,
std::string &  strResult,
const std::string &  strCommand,
bool  fExecute,
std::string *const  pstrFilteredOut = nullptr,
const WalletModel wallet_model = nullptr 
)
static

Split shell command line into a list of arguments and optionally execute the command(s).

Aims to emulate bash and friends.

  • Command nesting is possible with parenthesis; for example: validateaddress(getnewaddress())
  • Arguments are delimited with whitespace or comma
  • Extra whitespace at the beginning and end and between arguments will be ignored
  • Text can be "double" or 'single' quoted
  • The backslash \ is used as escape character
    • Outside quotes, any character can be escaped
    • Within double quotes, only escape " and backslashes before a \c " or another backslash
    • Within single quotes, no escaping is possible and no special interpretation takes place
Parameters
[in]nodeoptional node to execute command on
[out]strResultstringified result from the executed command(chain)
[in]strCommandCommand line to split
[in]fExecuteset true if you want the command to be executed
[out]pstrFilteredOutCommand line, filtered to remove any sensitive data

Definition at line 169 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scrollToEnd

void RPCConsole::scrollToEnd ( )
slot

Scroll console view to end.

Definition at line 1144 of file rpcconsole.cpp.

Here is the caller graph for this function:

◆ setClientModel()

void RPCConsole::setClientModel ( ClientModel model = nullptr,
int  bestblock_height = 0,
int64_t  bestblock_date = 0,
double  verification_progress = 0.0 
)

Definition at line 655 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFontSize

void RPCConsole::setFontSize ( int  newSize)
slot

Definition at line 841 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMempoolSize

void RPCConsole::setMempoolSize ( long  numberOfTxs,
size_t  dynUsage 
)
slot

Set size (number of transactions and memory usage) of the mempool in the UI.

Definition at line 1002 of file rpcconsole.cpp.

Here is the caller graph for this function:

◆ setNetworkActive

void RPCConsole::setNetworkActive ( bool  networkActive)
slot

Set network state shown in the UI.

Definition at line 989 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setNumBlocks

void RPCConsole::setNumBlocks ( int  count,
const QDateTime &  blockDate,
double  nVerificationProgress,
SyncType  synctype 
)
slot

Set number of blocks and last block date shown in the UI.

Definition at line 994 of file rpcconsole.cpp.

Here is the caller graph for this function:

◆ setNumConnections

void RPCConsole::setNumConnections ( int  count)
slot

Set number of connections shown in the UI.

Definition at line 981 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTabFocus

void RPCConsole::setTabFocus ( enum TabTypes  tabType)
slot

set which tab has the focus (is visible)

Definition at line 1366 of file rpcconsole.cpp.

Here is the caller graph for this function:

◆ setTrafficGraphRange()

void RPCConsole::setTrafficGraphRange ( int  mins)
private

Definition at line 1157 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showBanTableContextMenu

void RPCConsole::showBanTableContextMenu ( const QPoint &  point)
privateslot

Show custom context menu on Bans tab.

Definition at line 1294 of file rpcconsole.cpp.

Here is the caller graph for this function:

◆ showEvent

void RPCConsole::showEvent ( QShowEvent *  event)
overrideprivateslot

Definition at line 1260 of file rpcconsole.cpp.

Here is the call graph for this function:

◆ showOrHideBanTableIfRequired

void RPCConsole::showOrHideBanTableIfRequired ( )
privateslot

Hides ban table if no bans are present.

Definition at line 1356 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showPeersTableContextMenu

void RPCConsole::showPeersTableContextMenu ( const QPoint &  point)
privateslot

Show custom context menu on Peers tab.

Definition at line 1287 of file rpcconsole.cpp.

Here is the caller graph for this function:

◆ startExecutor()

void RPCConsole::startExecutor ( )
private

Definition at line 1107 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tabs()

std::vector<TabTypes> RPCConsole::tabs ( ) const
inline

Definition at line 78 of file rpcconsole.h.

Here is the caller graph for this function:

◆ tabShortcut()

QKeySequence RPCConsole::tabShortcut ( TabTypes  tab_type) const

Definition at line 1376 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tabTitle()

QString RPCConsole::tabTitle ( TabTypes  tab_type) const

Definition at line 1371 of file rpcconsole.cpp.

Here is the caller graph for this function:

◆ TimeDurationField()

QString RPCConsole::TimeDurationField ( std::chrono::seconds  time_now,
std::chrono::seconds  time_at_event 
) const
inlineprivate

Helper for the output of a time duration field.

Inputs are UNIX epoch times.

Definition at line 187 of file rpcconsole.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unbanSelectedNode

void RPCConsole::unbanSelectedNode ( )
slot

Unban a selected node on the Bans tab.

Definition at line 1332 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateAlerts

void RPCConsole::updateAlerts ( const QString &  warnings)
privateslot

Definition at line 1388 of file rpcconsole.cpp.

Here is the caller graph for this function:

◆ updateDetailWidget

void RPCConsole::updateDetailWidget ( )
privateslot

show detailed information on ui about selected node

Definition at line 1169 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateNetworkState()

void RPCConsole::updateNetworkState ( )
private

Update UI with latest network info from model.

Definition at line 967 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateTrafficStats

void RPCConsole::updateTrafficStats ( quint64  totalBytesIn,
quint64  totalBytesOut 
)
privateslot

update traffic statistics

Definition at line 1163 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateWindowTitle()

void RPCConsole::updateWindowTitle ( )
private

Definition at line 1394 of file rpcconsole.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ autoCompleter

QCompleter* RPCConsole::autoCompleter = nullptr
private

Definition at line 175 of file rpcconsole.h.

◆ banTableContextMenu

QMenu* RPCConsole::banTableContextMenu = nullptr
private

Definition at line 173 of file rpcconsole.h.

◆ cachedNodeids

QList<NodeId> RPCConsole::cachedNodeids
private

Definition at line 169 of file rpcconsole.h.

◆ clientModel

ClientModel* RPCConsole::clientModel = nullptr
private

Definition at line 165 of file rpcconsole.h.

◆ cmdBeforeBrowsing

QString RPCConsole::cmdBeforeBrowsing
private

Definition at line 168 of file rpcconsole.h.

◆ consoleFontSize

int RPCConsole::consoleFontSize = 0
private

Definition at line 174 of file rpcconsole.h.

◆ history

QStringList RPCConsole::history
private

Definition at line 166 of file rpcconsole.h.

◆ historyPtr

int RPCConsole::historyPtr = 0
private

Definition at line 167 of file rpcconsole.h.

◆ m_banlist_widget_header_state

QByteArray RPCConsole::m_banlist_widget_header_state
private

Definition at line 181 of file rpcconsole.h.

◆ m_executor

RPCExecutor* RPCConsole::m_executor {nullptr}
private

Definition at line 177 of file rpcconsole.h.

◆ m_is_executing

bool RPCConsole::m_is_executing {false}
private

Definition at line 179 of file rpcconsole.h.

◆ m_last_wallet_model

WalletModel* RPCConsole::m_last_wallet_model {nullptr}
private

Definition at line 178 of file rpcconsole.h.

◆ m_node

interfaces::Node& RPCConsole::m_node
private

Definition at line 163 of file rpcconsole.h.

◆ m_peer_widget_header_state

QByteArray RPCConsole::m_peer_widget_header_state
private

Definition at line 180 of file rpcconsole.h.

◆ peersTableContextMenu

QMenu* RPCConsole::peersTableContextMenu = nullptr
private

Definition at line 172 of file rpcconsole.h.

◆ platformStyle

const PlatformStyle* const RPCConsole::platformStyle
private

Definition at line 170 of file rpcconsole.h.

◆ rpcTimerInterface

RPCTimerInterface* RPCConsole::rpcTimerInterface = nullptr
private

Definition at line 171 of file rpcconsole.h.

◆ thread

QThread RPCConsole::thread
private

Definition at line 176 of file rpcconsole.h.

◆ ts

struct RPCConsole::TranslatedStrings RPCConsole::ts
private

◆ ui

Ui::RPCConsole* const RPCConsole::ui
private

Definition at line 164 of file rpcconsole.h.


The documentation for this class was generated from the following files: