Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

Local Bitcoin RPC console. More...

#include <rpcconsole.h>

+ Inheritance diagram for RPCConsole:
+ Collaboration diagram for RPCConsole:

Public Types

enum  MessageClass {
  MC_ERROR, MC_DEBUG, CMD_REQUEST, CMD_REPLY,
  CMD_ERROR
}
 
enum  TabTypes {
  TAB_INFO = 0, TAB_CONSOLE = 1, TAB_GRAPH = 2, TAB_PEERS = 3,
  TAB_REPAIR = 4
}
 

Public Slots

void clear (bool clearHistory=true)
 
void fontBigger ()
 
void fontSmaller ()
 
void setFontSize (int newSize)
 
void walletSalvage ()
 Wallet repair options. More...
 
void walletRescan ()
 Restart wallet with "-rescan". More...
 
void walletZaptxes1 ()
 Restart wallet with "-zapwallettxes=1". More...
 
void walletZaptxes2 ()
 Restart wallet with "-zapwallettxes=2". More...
 
void walletUpgrade ()
 Restart wallet with "-upgradewallet". More...
 
void walletReindex ()
 Restart wallet with "-reindex". More...
 
void message (int category, const QString &message, bool html=false)
 Append the message to the message widget. More...
 
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 updateMasternodeCount ()
 Update number of masternodes shown in the UI. More...
 
void setNumBlocks (int count, const QDateTime &blockDate, const QString &blockHash, double nVerificationProgress, bool headers)
 Set number of blocks, last block date and last block hash 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 setInstantSendLockCount (size_t count)
 Set number of InstantSend locks. More...
 
void browseHistory (int offset)
 Go forward or back in history. More...
 
void scrollToEnd ()
 Scroll console view to end. More...
 
void peerSelected (const QItemSelection &selected, const QItemSelection &deselected)
 Handle selection of peer in peers list. More...
 
void peerLayoutAboutToChange ()
 Handle selection caching before update. More...
 
void peerLayoutChanged ()
 Handle updated peer information. 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...
 

Signals

void stopExecutor ()
 
void cmdRequest (const QString &command)
 
void handleRestart (QStringList args)
 Get restart command-line parameters and handle restart. More...
 

Public Member Functions

 RPCConsole (QWidget *parent)
 
 ~RPCConsole ()
 
void setClientModel (ClientModel *model)
 

Static Public Member Functions

static bool RPCParseCommandLine (std::string &strResult, const std::string &strCommand, bool fExecute, std::string *const pstrFilteredOut=nullptr)
 Split shell command line into a list of arguments and optionally execute the command(s). More...
 
static bool RPCExecuteCommandLine (std::string &strResult, const std::string &strCommand, std::string *const pstrFilteredOut=nullptr)
 

Protected Member Functions

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

Private Types

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

Private Slots

void showPage (int index)
 custom tab buttons clicked More...
 
void on_lineEdit_returnPressed ()
 
void on_stackedWidgetRPC_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 resizeEvent (QResizeEvent *event)
 
void showEvent (QShowEvent *event)
 
void hideEvent (QHideEvent *event)
 
void changeEvent (QEvent *e)
 
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...
 

Private Member Functions

void startExecutor ()
 
void setTrafficGraphRange (TrafficGraphData::GraphRange range)
 
void buildParameterlist (QString arg)
 Build parameter list for restart. More...
 
void updateNodeDetail (const CNodeCombinedStats *stats)
 show detailed information on ui about selected node More...
 
void setButtonIcons ()
 Set required icons for buttons inside the dialog. More...
 
void updateNetworkState ()
 Update UI with latest network info from model. More...
 

Private Attributes

Ui::RPCConsole * ui
 
QButtonGroup pageButtons
 
ClientModelclientModel
 
QStringList history
 
int historyPtr
 
QString cmdBeforeBrowsing
 
QList< NodeIdcachedNodeids
 
RPCTimerInterfacerpcTimerInterface
 
QMenu * peersTableContextMenu
 
QMenu * banTableContextMenu
 
int consoleFontSize
 
QCompleter * autoCompleter
 
QThread thread
 

Detailed Description

Local Bitcoin RPC console.

Definition at line 32 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 47 of file rpcconsole.h.

◆ TabTypes

Enumerator
TAB_INFO 
TAB_CONSOLE 
TAB_GRAPH 
TAB_PEERS 
TAB_REPAIR 

Definition at line 55 of file rpcconsole.h.

Constructor & Destructor Documentation

◆ RPCConsole()

◆ ~RPCConsole()

RPCConsole::~RPCConsole ( )

Definition at line 530 of file rpcconsole.cpp.

References rpcTimerInterface, RPCUnsetTimerInterface(), and ui.

Member Function Documentation

◆ banSelectedNode

◆ browseHistory

void RPCConsole::browseHistory ( int  offset)
slot

Go forward or back in history.

Definition at line 1010 of file rpcconsole.cpp.

References cmdBeforeBrowsing, history, historyPtr, and ui.

Referenced by eventFilter().

◆ buildParameterlist()

void RPCConsole::buildParameterlist ( QString  arg)
private

Build parameter list for restart.

Build command-line parameter list for restart.

Definition at line 805 of file rpcconsole.cpp.

References handleRestart(), REINDEX(), RESCAN(), SALVAGEWALLET(), UPGRADEWALLET(), ZAPTXES1(), and ZAPTXES2().

Referenced by walletReindex(), walletRescan(), walletSalvage(), walletUpgrade(), walletZaptxes1(), and walletZaptxes2().

◆ changeEvent

void RPCConsole::changeEvent ( QEvent *  e)
privateslot

Definition at line 1243 of file rpcconsole.cpp.

References clear(), GUIUtil::dashThemeActive(), setButtonIcons(), and ui.

◆ clear

◆ clearSelectedNode

void RPCConsole::clearSelectedNode ( )
privateslot

clear the selected node

Definition at line 1335 of file rpcconsole.cpp.

References cachedNodeids, and ui.

Referenced by banSelectedNode(), disconnectSelectedNode(), on_stackedWidgetRPC_currentChanged(), peerLayoutChanged(), and setClientModel().

◆ cmdRequest

void RPCConsole::cmdRequest ( const QString &  command)
signal

◆ disconnectSelectedNode

void RPCConsole::disconnectSelectedNode ( )
slot

Disconnect a selected node on the Peers tab.

Definition at line 1269 of file rpcconsole.cpp.

References clearSelectedNode(), g_connman, GUIUtil::getEntryData(), PeerTableModel::NetNodeId, and ui.

Referenced by setClientModel().

◆ eventFilter()

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

Definition at line 539 of file rpcconsole.cpp.

References autoCompleter, browseHistory(), and ui.

◆ fontBigger

void RPCConsole::fontBigger ( )
slot

Definition at line 733 of file rpcconsole.cpp.

References consoleFontSize, and setFontSize().

Referenced by RPCConsole().

◆ fontSmaller

void RPCConsole::fontSmaller ( )
slot

Definition at line 738 of file rpcconsole.cpp.

References consoleFontSize, and setFontSize().

Referenced by RPCConsole().

◆ handleRestart

void RPCConsole::handleRestart ( QStringList  args)
signal

Get restart command-line parameters and handle restart.

Referenced by buildParameterlist().

◆ hideEvent

void RPCConsole::hideEvent ( QHideEvent *  event)
privateslot

◆ keyPressEvent()

void RPCConsole::keyPressEvent ( QKeyEvent *  event)
protected

Definition at line 865 of file rpcconsole.cpp.

◆ message

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

Append the message to the message widget.

Definition at line 873 of file rpcconsole.cpp.

References categoryClass(), GUIUtil::HtmlEscape(), and ui.

Referenced by clear(), on_lineEdit_returnPressed(), and startExecutor().

◆ on_lineEdit_returnPressed

void RPCConsole::on_lineEdit_returnPressed ( )
privateslot

◆ on_openDebugLogfileButton_clicked

void RPCConsole::on_openDebugLogfileButton_clicked ( )
privateslot

open the debug.log from the current datadir

Definition at line 1060 of file rpcconsole.cpp.

References GUIUtil::openDebugLogfile().

◆ on_sldGraphRange_valueChanged

void RPCConsole::on_sldGraphRange_valueChanged ( int  value)
privateslot

change the time range of the network traffic graph

Definition at line 1071 of file rpcconsole.cpp.

References setTrafficGraphRange().

◆ on_stackedWidgetRPC_currentChanged

void RPCConsole::on_stackedWidgetRPC_currentChanged ( int  index)
privateslot

Definition at line 1052 of file rpcconsole.cpp.

References clearSelectedNode(), and ui.

◆ peerLayoutAboutToChange

void RPCConsole::peerLayoutAboutToChange ( )
slot

Handle selection caching before update.

Definition at line 1094 of file rpcconsole.cpp.

References cachedNodeids, clientModel, PeerTableModel::getNodeStats(), ClientModel::getPeerTableModel(), CNodeStats::nodeid, CNodeCombinedStats::nodeStats, and ui.

Referenced by setClientModel().

◆ peerLayoutChanged

void RPCConsole::peerLayoutChanged ( )
slot

◆ peerSelected

void RPCConsole::peerSelected ( const QItemSelection &  selected,
const QItemSelection &  deselected 
)
slot

Handle selection of peer in peers list.

Definition at line 1082 of file rpcconsole.cpp.

References clientModel, PeerTableModel::getNodeStats(), ClientModel::getPeerTableModel(), and updateNodeDetail().

Referenced by setClientModel().

◆ resizeEvent

void RPCConsole::resizeEvent ( QResizeEvent *  event)
privateslot

Definition at line 1216 of file rpcconsole.cpp.

◆ RPCExecuteCommandLine()

static bool RPCConsole::RPCExecuteCommandLine ( std::string &  strResult,
const std::string &  strCommand,
std::string *const  pstrFilteredOut = nullptr 
)
inlinestatic

Definition at line 41 of file rpcconsole.h.

References RPCParseCommandLine().

Referenced by RPCExecutor::request().

◆ RPCParseCommandLine()

bool RPCConsole::RPCParseCommandLine ( std::string &  strResult,
const std::string &  strCommand,
bool  fExecute,
std::string *const  pstrFilteredOut = 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
[out]resultstringified 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 147 of file rpcconsole.cpp.

References atoi(), UniValue::clear(), CRPCTable::execute(), find_value(), UniValue::get_str(), GetWallets(), HasWallets(), UniValue::isArray(), UniValue::isObject(), UniValue::isStr(), JSONRPCRequest::params, UniValue::push_back(), RPCConvertValues(), JSONRPCRequest::strMethod, tableRPC, JSONRPCRequest::URI, and UniValue::write().

Referenced by on_lineEdit_returnPressed(), and RPCExecuteCommandLine().

◆ scrollToEnd

void RPCConsole::scrollToEnd ( )
slot

Scroll console view to end.

Definition at line 1065 of file rpcconsole.cpp.

References ui.

Referenced by on_lineEdit_returnPressed().

◆ setButtonIcons()

void RPCConsole::setButtonIcons ( )
private

Set required icons for buttons inside the dialog.

Definition at line 1208 of file rpcconsole.cpp.

References GUIUtil::BLUE, BUTTON_ICONSIZE, GUIUtil::RED, GUIUtil::setIcon(), and ui.

Referenced by changeEvent(), and RPCConsole().

◆ setClientModel()

◆ setFontSize

void RPCConsole::setFontSize ( int  newSize)
slot

Definition at line 743 of file rpcconsole.cpp.

References clear(), consoleFontSize, FONT_RANGE(), fontSizeSettingsKey, and ui.

Referenced by fontBigger(), and fontSmaller().

◆ setInstantSendLockCount

void RPCConsole::setInstantSendLockCount ( size_t  count)
slot

Set number of InstantSend locks.

Definition at line 945 of file rpcconsole.cpp.

References count, and ui.

Referenced by setClientModel().

◆ 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 935 of file rpcconsole.cpp.

References ui.

Referenced by setClientModel().

◆ setNetworkActive

void RPCConsole::setNetworkActive ( bool  networkActive)
slot

Set network state shown in the UI.

Definition at line 909 of file rpcconsole.cpp.

References updateNetworkState().

Referenced by setClientModel().

◆ setNumBlocks

void RPCConsole::setNumBlocks ( int  count,
const QDateTime &  blockDate,
const QString &  blockHash,
double  nVerificationProgress,
bool  headers 
)
slot

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

Definition at line 914 of file rpcconsole.cpp.

References count, and ui.

Referenced by setClientModel().

◆ setNumConnections

void RPCConsole::setNumConnections ( int  count)
slot

Set number of connections shown in the UI.

Definition at line 901 of file rpcconsole.cpp.

References clientModel, and updateNetworkState().

Referenced by setClientModel().

◆ setTabFocus

void RPCConsole::setTabFocus ( enum TabTypes  tabType)
slot

set which tab has the focus (is visible)

Definition at line 1353 of file rpcconsole.cpp.

References showPage().

Referenced by BitcoinGUI::showConsole(), BitcoinGUI::showGraph(), BitcoinGUI::showInfo(), BitcoinGUI::showPeers(), and BitcoinGUI::showRepair().

◆ setTrafficGraphRange()

void RPCConsole::setTrafficGraphRange ( TrafficGraphData::GraphRange  range)
private

◆ showBanTableContextMenu

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

Show custom context menu on Bans tab.

Definition at line 1262 of file rpcconsole.cpp.

References banTableContextMenu, and ui.

Referenced by setClientModel().

◆ showEvent

void RPCConsole::showEvent ( QShowEvent *  event)
privateslot

◆ showOrHideBanTableIfRequired

void RPCConsole::showOrHideBanTableIfRequired ( )
privateslot

Hides ban table if no bans are present.

Definition at line 1343 of file rpcconsole.cpp.

References clientModel, ClientModel::getBanTableModel(), BanTableModel::shouldShow(), and ui.

Referenced by setClientModel().

◆ showPage

void RPCConsole::showPage ( int  index)
privateslot

custom tab buttons clicked

Definition at line 950 of file rpcconsole.cpp.

References GUIUtil::Bold, GUIUtil::Normal, pageButtons, GUIUtil::setFont(), ui, and GUIUtil::updateFonts().

Referenced by RPCConsole(), and setTabFocus().

◆ showPeersTableContextMenu

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

Show custom context menu on Peers tab.

Definition at line 1255 of file rpcconsole.cpp.

References peersTableContextMenu, and ui.

Referenced by setClientModel().

◆ startExecutor()

void RPCConsole::startExecutor ( )
private

Definition at line 1031 of file rpcconsole.cpp.

References cmdRequest(), message(), stopExecutor(), and thread.

Referenced by setClientModel().

◆ stopExecutor

void RPCConsole::stopExecutor ( )
signal

Referenced by setClientModel(), and startExecutor().

◆ unbanSelectedNode

void RPCConsole::unbanSelectedNode ( )
slot

◆ updateMasternodeCount

void RPCConsole::updateMasternodeCount ( )
slot

Update number of masternodes shown in the UI.

Definition at line 923 of file rpcconsole.cpp.

References clientModel, ClientModel::getMasternodeList(), and ui.

Referenced by setClientModel().

◆ updateNetworkState()

void RPCConsole::updateNetworkState ( )
private

Update UI with latest network info from model.

Definition at line 888 of file rpcconsole.cpp.

References clientModel, CONNECTIONS_IN, CONNECTIONS_OUT, ClientModel::getNetworkActive(), ClientModel::getNumConnections(), and ui.

Referenced by setClientModel(), setNetworkActive(), and setNumConnections().

◆ updateNodeDetail()

◆ walletReindex

void RPCConsole::walletReindex ( )
slot

Restart wallet with "-reindex".

Definition at line 799 of file rpcconsole.cpp.

References buildParameterlist(), and REINDEX().

Referenced by RPCConsole().

◆ walletRescan

void RPCConsole::walletRescan ( )
slot

Restart wallet with "-rescan".

Definition at line 775 of file rpcconsole.cpp.

References buildParameterlist(), and RESCAN().

Referenced by RPCConsole().

◆ walletSalvage

void RPCConsole::walletSalvage ( )
slot

Wallet repair options.

Restart wallet with "-salvagewallet".

Definition at line 769 of file rpcconsole.cpp.

References buildParameterlist(), and SALVAGEWALLET().

◆ walletUpgrade

void RPCConsole::walletUpgrade ( )
slot

Restart wallet with "-upgradewallet".

Definition at line 793 of file rpcconsole.cpp.

References buildParameterlist(), and UPGRADEWALLET().

Referenced by RPCConsole().

◆ walletZaptxes1

void RPCConsole::walletZaptxes1 ( )
slot

Restart wallet with "-zapwallettxes=1".

Definition at line 781 of file rpcconsole.cpp.

References buildParameterlist(), and ZAPTXES1().

Referenced by RPCConsole().

◆ walletZaptxes2

void RPCConsole::walletZaptxes2 ( )
slot

Restart wallet with "-zapwallettxes=2".

Definition at line 787 of file rpcconsole.cpp.

References buildParameterlist(), and ZAPTXES2().

Referenced by RPCConsole().

Member Data Documentation

◆ autoCompleter

QCompleter* RPCConsole::autoCompleter
private

Definition at line 174 of file rpcconsole.h.

Referenced by eventFilter(), and setClientModel().

◆ banTableContextMenu

QMenu* RPCConsole::banTableContextMenu
private

Definition at line 172 of file rpcconsole.h.

Referenced by setClientModel(), and showBanTableContextMenu().

◆ cachedNodeids

QList<NodeId> RPCConsole::cachedNodeids
private

Definition at line 169 of file rpcconsole.h.

Referenced by clearSelectedNode(), peerLayoutAboutToChange(), and peerLayoutChanged().

◆ clientModel

◆ cmdBeforeBrowsing

QString RPCConsole::cmdBeforeBrowsing
private

Definition at line 168 of file rpcconsole.h.

Referenced by browseHistory(), and on_lineEdit_returnPressed().

◆ consoleFontSize

int RPCConsole::consoleFontSize
private

Definition at line 173 of file rpcconsole.h.

Referenced by clear(), fontBigger(), fontSmaller(), RPCConsole(), and setFontSize().

◆ history

QStringList RPCConsole::history
private

Definition at line 166 of file rpcconsole.h.

Referenced by browseHistory(), clear(), and on_lineEdit_returnPressed().

◆ historyPtr

int RPCConsole::historyPtr
private

Definition at line 167 of file rpcconsole.h.

Referenced by browseHistory(), clear(), and on_lineEdit_returnPressed().

◆ pageButtons

QButtonGroup RPCConsole::pageButtons
private

Definition at line 164 of file rpcconsole.h.

Referenced by RPCConsole(), and showPage().

◆ peersTableContextMenu

QMenu* RPCConsole::peersTableContextMenu
private

Definition at line 171 of file rpcconsole.h.

Referenced by setClientModel(), and showPeersTableContextMenu().

◆ rpcTimerInterface

RPCTimerInterface* RPCConsole::rpcTimerInterface
private

Definition at line 170 of file rpcconsole.h.

Referenced by RPCConsole(), and ~RPCConsole().

◆ thread

QThread RPCConsole::thread
private

Definition at line 175 of file rpcconsole.h.

Referenced by setClientModel(), and startExecutor().

◆ ui


The documentation for this class was generated from the following files:
Released under the MIT license