5#if defined(HAVE_CONFIG_H)
6#include <config/bitcoin-config.h>
11#include <chainparams.h>
18#include <qt/forms/ui_debugwindow.h>
55 {
"cmd-reply",
":/icons/tx_output"},
56 {
"cmd-error",
":/icons/tx_output"},
57 {
"misc",
":/icons/tx_inout"},
63const QStringList historyFilter = QStringList() <<
"importprivkey"
66 <<
"signmessagewithprivkey"
67 <<
"signrawtransactionwithkey"
69 <<
"walletpassphrasechange"
84 void reply(
int category,
const QString &command);
97 timer.setSingleShot(
true);
98 connect(&
timer, &QTimer::timeout, [
this] {
func(); });
111 const char *
Name()
override {
return "Qt"; }
113 int64_t millis)
override {
118#include <qt/rpcconsole.moc>
147 std::string &strResult,
148 const std::string &strCommand,
150 std::string *
const pstrFilteredOut,
152 std::vector<std::vector<std::string>> stack;
153 stack.push_back(std::vector<std::string>());
157 STATE_EATING_SPACES_IN_ARG,
158 STATE_EATING_SPACES_IN_BRACKETS,
163 STATE_ESCAPE_DOUBLEQUOTED,
164 STATE_COMMAND_EXECUTED,
165 STATE_COMMAND_EXECUTED_INNER
166 } state = STATE_EATING_SPACES;
169 unsigned nDepthInsideSensitive = 0;
170 size_t filter_begin_pos = 0, chpos;
171 std::vector<std::pair<size_t, size_t>> filter_ranges;
173 auto add_to_current_stack = [&](
const std::string &strArg) {
174 if (stack.back().empty() && (!nDepthInsideSensitive) &&
175 historyFilter.contains(QString::fromStdString(strArg),
176 Qt::CaseInsensitive)) {
177 nDepthInsideSensitive = 1;
178 filter_begin_pos = chpos;
182 stack.
push_back(std::vector<std::string>());
184 stack.back().push_back(strArg);
187 auto close_out_params = [&]() {
188 if (nDepthInsideSensitive) {
189 if (!--nDepthInsideSensitive) {
191 filter_ranges.push_back(
192 std::make_pair(filter_begin_pos, chpos));
193 filter_begin_pos = 0;
199 std::string strCommandTerminated = strCommand;
200 if (strCommandTerminated.back() !=
'\n') {
201 strCommandTerminated +=
"\n";
203 for (chpos = 0; chpos < strCommandTerminated.size(); ++chpos) {
204 char ch = strCommandTerminated[chpos];
206 case STATE_COMMAND_EXECUTED_INNER:
207 case STATE_COMMAND_EXECUTED: {
208 bool breakParsing =
true;
212 state = STATE_COMMAND_EXECUTED_INNER;
215 if (state == STATE_COMMAND_EXECUTED_INNER) {
222 if (curarg.size() && fExecute) {
227 for (
char argch : curarg) {
229 throw std::runtime_error(
230 "Invalid result query");
234 lastResult[
atoi(curarg.c_str())];
239 throw std::runtime_error(
240 "Invalid result query");
242 lastResult = subelement;
245 state = STATE_COMMAND_EXECUTED;
250 breakParsing =
false;
258 if (lastResult.
isStr()) {
261 curarg = lastResult.
write(2);
268 add_to_current_stack(curarg);
275 state = STATE_EATING_SPACES;
284 case STATE_EATING_SPACES_IN_ARG:
285 case STATE_EATING_SPACES_IN_BRACKETS:
286 case STATE_EATING_SPACES:
289 state = STATE_DOUBLEQUOTED;
292 state = STATE_SINGLEQUOTED;
295 state = STATE_ESCAPE_OUTER;
300 if (state == STATE_EATING_SPACES_IN_ARG) {
301 throw std::runtime_error(
"Invalid Syntax");
303 if (state == STATE_ARGUMENT) {
304 if (ch ==
'(' && stack.size() &&
305 stack.back().size() > 0) {
306 if (nDepthInsideSensitive) {
307 ++nDepthInsideSensitive;
309 stack.push_back(std::vector<std::string>());
315 throw std::runtime_error(
"Invalid Syntax");
318 add_to_current_stack(curarg);
320 state = STATE_EATING_SPACES_IN_BRACKETS;
322 if ((ch ==
')' || ch ==
'\n') && stack.size() > 0) {
329 std::vector<std::string>(
330 stack.back().begin() + 1,
331 stack.back().end()));
332 std::string method = stack.back()[0];
337 QByteArray encodedName =
338 QUrl::toPercentEncoding(
341 std::string(encodedName.constData(),
342 encodedName.length());
347 lastResult =
node->executeRpc(
351 state = STATE_COMMAND_EXECUTED;
358 if (state == STATE_EATING_SPACES_IN_ARG &&
359 curarg.empty() && ch ==
',') {
360 throw std::runtime_error(
"Invalid Syntax");
361 }
else if (state == STATE_ARGUMENT) {
363 add_to_current_stack(curarg);
366 if ((state == STATE_EATING_SPACES_IN_BRACKETS ||
367 state == STATE_ARGUMENT) &&
369 state = STATE_EATING_SPACES_IN_ARG;
372 state = STATE_EATING_SPACES;
376 state = STATE_ARGUMENT;
379 case STATE_SINGLEQUOTED:
382 state = STATE_ARGUMENT;
388 case STATE_DOUBLEQUOTED:
391 state = STATE_ARGUMENT;
394 state = STATE_ESCAPE_DOUBLEQUOTED;
400 case STATE_ESCAPE_OUTER:
402 state = STATE_ARGUMENT;
404 case STATE_ESCAPE_DOUBLEQUOTED:
405 if (ch !=
'"' && ch !=
'\\') {
410 state = STATE_DOUBLEQUOTED;
414 if (pstrFilteredOut) {
415 if (STATE_COMMAND_EXECUTED == state) {
419 *pstrFilteredOut = strCommand;
420 for (
auto i = filter_ranges.rbegin(); i != filter_ranges.rend(); ++i) {
421 pstrFilteredOut->replace(i->first, i->second - i->first,
"(…)");
427 case STATE_COMMAND_EXECUTED:
428 if (lastResult.
isStr()) {
429 strResult = lastResult.
get_str();
431 strResult = lastResult.
write(2);
435 case STATE_EATING_SPACES:
446 std::string executableCommand = command.toStdString() +
"\n";
450 if (executableCommand ==
"help-console\n") {
454 "This console accepts RPC commands using the standard "
456 " example: getblockhash 0\n\n"
458 "This console can also accept RPC commands using "
459 "parenthesized syntax.\n"
460 " example: getblockhash(0)\n\n"
462 "Commands may be nested when specified with the "
463 "parenthesized syntax.\n"
464 " example: getblock(getblockhash(0) 1)\n\n"
466 "A space or a comma can be used to delimit arguments "
467 "for either syntax.\n"
468 " example: getblockhash 0\n"
469 " getblockhash,0\n\n"
471 "Named results can be queried with a non-quoted key "
472 "string in brackets.\n"
473 " example: getblock(getblockhash(0) true)[tx]\n\n"
475 "Results without keys can be queried using an integer "
478 "getblock(getblockhash(0),true)[tx][0]\n\n")));
482 m_node, result, executableCommand,
nullptr, wallet_model)) {
484 QString(
"Parse error: unbalanced ' or \""));
495 QString::fromStdString(message) +
" (code " +
496 QString::number(code) +
")");
497 }
catch (
const std::runtime_error &) {
501 QString::fromStdString(objError.
write()));
503 }
catch (
const std::exception &e) {
505 QString(
"Error: ") + QString::fromStdString(e.what()));
512 platformStyle(_platformStyle) {
515 if (!restoreGeometry(
516 settings.value(
"RPCConsoleWindowGeometry").toByteArray())) {
518 move(QGuiApplication::primaryScreen()->availableGeometry().center() -
519 frameGeometry().center());
522 QChar nonbreaking_hyphen(8209);
523 const QString hb_list{
"<ul><li>\"" + tr(
"To") +
"\" – " +
524 tr(
"we selected the peer for high bandwidth relay") +
525 "</li><li>\"" + tr(
"From") +
"\" – " +
526 tr(
"the peer selected us for high bandwidth relay") +
527 "</li><li>\"" + tr(
"No") +
"\" – " +
528 tr(
"no high bandwidth relay selected") +
530 ui->peerHighBandwidthLabel->setToolTip(
531 ui->peerHighBandwidthLabel->toolTip().arg(hb_list));
532 ui->dataDir->setToolTip(
533 ui->dataDir->toolTip().arg(QString(nonbreaking_hyphen) +
"datadir"));
534 ui->blocksDir->setToolTip(
ui->blocksDir->toolTip().arg(
535 QString(nonbreaking_hyphen) +
"blocksdir"));
536 ui->openDebugLogfileButton->setToolTip(
537 ui->openDebugLogfileButton->toolTip().arg(PACKAGE_NAME));
540 ui->openDebugLogfileButton->setIcon(
544 ui->fontBiggerButton->setIcon(
546 ui->fontSmallerButton->setIcon(
550 ui->lineEdit->installEventFilter(
this);
551 ui->lineEdit->setMaxLength(16 * 1024 * 1024);
552 ui->messagesWidget->installEventFilter(
this);
555 connect(
ui->fontBiggerButton, &QPushButton::clicked,
this,
557 connect(
ui->fontSmallerButton, &QPushButton::clicked,
this,
559 connect(
ui->btnClearTrafficGraph, &QPushButton::clicked,
ui->trafficGraph,
563 ui->WalletSelector->setVisible(
false);
564 ui->WalletSelectorLabel->setVisible(
false);
568 ui->berkeleyDBVersion->setText(
571 ui->label_berkeleyDBVersion->hide();
572 ui->berkeleyDBVersion->hide();
592 settings.setValue(
"RPCConsoleWindowGeometry", saveGeometry());
600 if (event->type() == QEvent::KeyPress) {
601 QKeyEvent *keyevt =
static_cast<QKeyEvent *
>(event);
602 int key = keyevt->key();
603 Qt::KeyboardModifiers mod = keyevt->modifiers();
606 if (obj ==
ui->lineEdit) {
612 if (obj ==
ui->lineEdit) {
618 case Qt::Key_PageDown:
619 if (obj ==
ui->lineEdit) {
620 QApplication::postEvent(
ui->messagesWidget,
621 new QKeyEvent(*keyevt));
629 QApplication::postEvent(
ui->lineEdit,
630 new QKeyEvent(*keyevt));
638 if (obj ==
ui->messagesWidget &&
639 ((!mod && !keyevt->text().isEmpty() &&
640 key != Qt::Key_Tab) ||
641 ((mod & Qt::ControlModifier) && key == Qt::Key_V) ||
642 ((mod & Qt::ShiftModifier) && key == Qt::Key_Insert))) {
643 ui->lineEdit->setFocus();
644 QApplication::postEvent(
ui->lineEdit,
645 new QKeyEvent(*keyevt));
650 return QWidget::eventFilter(obj, event);
654 int64_t bestblock_date,
655 double verification_progress) {
658 bool wallet_enabled{
false};
662 if (model && !wallet_enabled) {
669 ui->trafficGraph->setClientModel(model);
677 setNumBlocks(bestblock_height, QDateTime::fromTime_t(bestblock_date),
696 ui->peerWidget->verticalHeader()->hide();
697 ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
698 ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
699 ui->peerWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
700 ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu);
706 ui->peerWidget->horizontalHeader()->setStretchLastSection(
true);
709 QAction *disconnectAction =
new QAction(tr(
"&Disconnect"),
this);
710 QAction *banAction1h =
711 new QAction(tr(
"Ban for") +
" " + tr(
"1 &hour"),
this);
712 QAction *banAction24h =
713 new QAction(tr(
"Ban for") +
" " + tr(
"1 &day"),
this);
714 QAction *banAction7d =
715 new QAction(tr(
"Ban for") +
" " + tr(
"1 &week"),
this);
716 QAction *banAction365d =
717 new QAction(tr(
"Ban for") +
" " + tr(
"1 &year"),
this);
727 connect(banAction1h, &QAction::triggered,
729 connect(banAction24h, &QAction::triggered,
731 connect(banAction7d, &QAction::triggered,
733 connect(banAction365d, &QAction::triggered,
737 connect(
ui->peerWidget, &QTableView::customContextMenuRequested,
this,
739 connect(disconnectAction, &QAction::triggered,
this,
744 connect(
ui->peerWidget->selectionModel(),
745 &QItemSelectionModel::selectionChanged,
this,
753 &PeerTableModel::layoutAboutToBeChanged,
this,
758 ui->banlistWidget->verticalHeader()->hide();
759 ui->banlistWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
760 ui->banlistWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
761 ui->banlistWidget->setSelectionMode(QAbstractItemView::SingleSelection);
762 ui->banlistWidget->setContextMenuPolicy(Qt::CustomContextMenu);
767 ui->banlistWidget->horizontalHeader()->setStretchLastSection(
true);
770 QAction *unbanAction =
new QAction(tr(
"&Unban"),
this);
777 connect(
ui->banlistWidget, &QTableView::customContextMenuRequested,
779 connect(unbanAction, &QAction::triggered,
this,
784 connect(
ui->banlistWidget, &QTableView::clicked,
this,
798 ui->networkName->setText(
799 QString::fromStdString(
Params().NetworkIDString()));
802 QStringList wordList;
804 for (
size_t i = 0; i < commandList.size(); ++i) {
805 wordList << commandList[i].c_str();
806 wordList << (
"help " + commandList[i]).c_str();
809 wordList <<
"help-console";
812 autoCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel);
815 ui->lineEdit->setEnabled(
true);
834 QVariant::fromValue(walletModel));
835 if (
ui->WalletSelector->count() == 2 && !isVisible()) {
838 ui->WalletSelector->setCurrentIndex(1);
840 if (
ui->WalletSelector->count() > 2) {
841 ui->WalletSelector->setVisible(
true);
842 ui->WalletSelectorLabel->setVisible(
true);
847 ui->WalletSelector->removeItem(
848 ui->WalletSelector->findData(QVariant::fromValue(walletModel)));
849 if (
ui->WalletSelector->count() == 2) {
850 ui->WalletSelector->setVisible(
false);
851 ui->WalletSelectorLabel->setVisible(
false);
859 return "cmd-request";
889 QString str =
ui->messagesWidget->toHtml();
893 QString(
"font-size:%1pt").arg(newSize));
901 float oldPosFactor = 1.0 /
902 ui->messagesWidget->verticalScrollBar()->maximum() *
903 ui->messagesWidget->verticalScrollBar()->value();
905 ui->messagesWidget->setHtml(str);
906 ui->messagesWidget->verticalScrollBar()->setValue(
907 oldPosFactor *
ui->messagesWidget->verticalScrollBar()->maximum());
911 ui->messagesWidget->clear();
916 ui->lineEdit->clear();
917 ui->lineEdit->setFocus();
923 ui->messagesWidget->document()->addResource(
927 Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
932 ui->messagesWidget->document()->setDefaultStyleSheet(
934 "td.time { color: #808080; font-size: %2; padding-top: 3px; } "
935 "td.message { font-family: %1; font-size: %2; "
936 "white-space:pre-wrap; } "
937 "td.cmd-request { color: #006060; } "
938 "td.cmd-error { color: red; } "
939 ".secwarning { color: red; }"
940 "b { color: #006060; } ")
944 QString clsKey =
"(⌘)-L";
946 QString clsKey =
"Ctrl-L";
950 (tr(
"Welcome to the %1 RPC console.").arg(PACKAGE_NAME) +
"<br>" +
951 tr(
"Use up and down arrows to navigate history, and "
952 "%1 to clear screen.")
953 .arg(
"<b>" + clsKey +
"</b>") +
955 tr(
"Type %1 for an overview of available commands.")
956 .arg(
"<b>help</b>") +
958 tr(
"For more information on using this console type %1.")
959 .arg(
"<b>help-console</b>") +
960 "<br><span class=\"secwarning\"><br>" +
961 tr(
"WARNING: Scammers have been active, telling users to type "
962 "commands here, stealing their wallet contents. Do not use "
963 "this console without fully understanding the ramifications "
970 if (windowType() != Qt::Widget && event->key() == Qt::Key_Escape) {
976 QTime time = QTime::currentTime();
977 QString timeString = time.toString();
979 out +=
"<table><tr><td class=\"time\" width=\"65\">" + timeString +
"</td>";
980 out +=
"<td class=\"icon\" width=\"32\"><img src=\"" +
983 "\" valign=\"middle\">";
989 out +=
"</td></tr></table>";
990 ui->messagesWidget->append(out);
994 QString connections =
996 connections += tr(
"In:") +
" " +
1000 connections += tr(
"Out:") +
" " +
1006 connections +=
" (" + tr(
"Network activity disabled") +
")";
1009 ui->numberOfConnections->setText(connections);
1025 double nVerificationProgress,
SyncType synctype) {
1027 ui->numberOfBlocks->setText(QString::number(
count));
1028 ui->lastBlockTime->setText(blockDate.toString());
1033 ui->mempoolNumberTxs->setText(QString::number(numberOfTxs));
1035 if (dynUsage < 1000000) {
1036 ui->mempoolSize->setText(QString::number(dynUsage / 1000.0,
'f', 2) +
1039 ui->mempoolSize->setText(QString::number(dynUsage / 1000000.0,
'f', 2) +
1045 QString cmd =
ui->lineEdit->text();
1047 if (!cmd.isEmpty()) {
1048 std::string strFilteredCmd;
1055 throw std::runtime_error(
"Invalid command line");
1057 }
catch (
const std::exception &e) {
1058 QMessageBox::critical(
this,
"Error",
1059 QString(
"Error: ") +
1060 QString::fromStdString(e.what()));
1064 ui->lineEdit->clear();
1078 tr(
"Executing command without any wallet"));
1087 cmd = QString::fromStdString(strFilteredCmd);
1124 ui->lineEdit->setText(cmd);
1129 executor->moveToThread(&
thread);
1133 static_cast<void (
RPCConsole::*)(
int,
const QString &)
>(
1140 connect(&
thread, &QThread::finished, executor, &RPCExecutor::deleteLater);
1145 QTimer::singleShot(0, executor,
1150 if (
ui->tabWidget->widget(index) ==
ui->tab_console) {
1151 ui->lineEdit->setFocus();
1160 QScrollBar *scrollbar =
ui->messagesWidget->verticalScrollBar();
1161 scrollbar->setValue(scrollbar->maximum());
1165 const int multiplier = 5;
1166 int mins = value * multiplier;
1171 ui->trafficGraph->setGraphRangeMins(mins);
1172 ui->lblGraphRange->setText(
1177 quint64 totalBytesOut) {
1183 QModelIndexList selected =
1184 ui->peerWidget->selectionModel()->selectedIndexes();
1186 for (
int i = 0; i < selected.size(); i++) {
1189 selected.at(i).row());
1199 bool fUnselect =
false;
1200 bool fReselect =
false;
1208 int selectedRow = -1;
1209 QModelIndexList selectedModelIndex =
1210 ui->peerWidget->selectionModel()->selectedIndexes();
1211 if (!selectedModelIndex.isEmpty()) {
1212 selectedRow = selectedModelIndex.first().row();
1220 if (detailNodeRow < 0) {
1224 if (detailNodeRow != selectedRow) {
1231 if (fUnselect && selectedRow >= 0) {
1237 ui->peerWidget->selectRow(
1247 QModelIndexList selected_rows;
1248 auto selection_model =
ui->peerWidget->selectionModel();
1249 if (selection_model) {
1250 selected_rows = selection_model->selectedRows();
1253 selected_rows.size() != 1) {
1254 ui->detailWidget->hide();
1255 ui->peerHeading->setText(
1256 tr(
"Select a peer to view detailed information."));
1261 selected_rows.first().row());
1263 QString peerAddrDetails(
1268 peerAddrDetails +=
"<br />" + tr(
"via %1").arg(QString::fromStdString(
1271 ui->peerHeading->setText(peerAddrDetails);
1272 QString bip152_hb_settings;
1274 bip152_hb_settings +=
"To";
1277 bip152_hb_settings += (bip152_hb_settings ==
"" ?
"From" :
"/From");
1279 if (bip152_hb_settings ==
"") {
1280 bip152_hb_settings =
"No";
1282 ui->peerHighBandwidth->setText(bip152_hb_settings);
1283 const auto time_now{GetTime<std::chrono::seconds>()};
1284 ui->peerConnTime->setText(
1286 ui->peerLastBlock->setText(
1288 ui->peerLastTx->setText(
1290 ui->peerLastSend->setText(
1292 ui->peerLastRecv->setText(
1294 ui->peerBytesSent->setText(
1296 ui->peerBytesRecv->setText(
1298 ui->peerPingTime->setText(
1300 ui->peerMinPing->setText(
1302 ui->timeoffset->setText(
1305 ui->peerSubversion->setText(
1309 ui->peerNetwork->setText(
1312 ui->peerPermissions->setText(tr(
"N/A"));
1314 QStringList permissions;
1315 for (
const auto &permission :
1317 permissions.append(QString::fromStdString(permission));
1319 ui->peerPermissions->setText(permissions.join(
" & "));
1321 ui->peerMappedAS->setText(
1329 ui->peerServices->setText(
1333 ui->peerSyncHeight->setText(
1336 ui->peerSyncHeight->setText(tr(
"Unknown"));
1341 ui->peerCommonHeight->setText(
1344 ui->peerCommonHeight->setText(tr(
"Unknown"));
1347 ui->peerHeight->setText(
1349 ui->peerPingWait->setText(
1355 ui->detailWidget->show();
1359 QWidget::resizeEvent(event);
1363 QWidget::showEvent(event);
1374 QWidget::hideEvent(event);
1385 QModelIndex index =
ui->peerWidget->indexAt(point);
1386 if (index.isValid()) {
1392 QModelIndex index =
ui->banlistWidget->indexAt(point);
1393 if (index.isValid()) {
1400 QList<QModelIndex> nodes =
1402 for (
int i = 0; i < nodes.count(); i++) {
1404 NodeId id = nodes.at(i).data().toLongLong();
1418 QList<QModelIndex> nodes =
1420 for (
int i = 0; i < nodes.count(); i++) {
1422 NodeId id = nodes.at(i).data().toLongLong();
1427 if (detailNodeRow < 0) {
1449 QList<QModelIndex> nodes =
1451 for (
int i = 0; i < nodes.count(); i++) {
1453 QString strNode = nodes.at(i).data().toString();
1464 ui->peerWidget->selectionModel()->clearSelection();
1475 ui->banlistWidget->setVisible(visible);
1476 ui->banHeading->setVisible(visible);
1480 ui->tabWidget->setCurrentIndex(
int(tabType));
1484 return ui->tabWidget->tabText(
int(tab_type));
1490 return QKeySequence(Qt::CTRL + Qt::Key_I);
1492 return QKeySequence(Qt::CTRL + Qt::Key_T);
1494 return QKeySequence(Qt::CTRL + Qt::Key_N);
1496 return QKeySequence(Qt::CTRL + Qt::Key_P);
1503 this->
ui->label_alerts->setVisible(!warnings.isEmpty());
1504 this->
ui->label_alerts->setText(warnings);
std::string BerkeleyDatabaseVersion()
const CChainParams & Params()
Return the currently selected parameters.
Model for Bitcoin network client.
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut)
QString blocksDir() const
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
PeerTableModel * getPeerTableModel()
int getNumConnections(NumConnections flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
void numConnectionsChanged(int count)
QString formatClientStartupTime() const
BanTableModel * getBanTableModel()
void numBlocksChanged(int count, const QDateTime &blockDate, double nVerificationProgress, SyncType header, SynchronizationState sync_state)
void alertsChanged(const QString &warnings)
QString formatFullVersion() const
QString formatSubVersion() const
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes)
void networkActiveChanged(bool networkActive)
interfaces::Node & node() const
static std::vector< std::string > ToStrings(NetPermissionFlags flags)
const CNodeCombinedStats * getNodeStats(int idx)
int getRowByNodeId(NodeId nodeid)
Class for handling RPC timers (used for e.g.
std::function< void()> func
QtRPCTimerBase(std::function< void()> &_func, int64_t millis)
const char * Name() override
Implementation name.
RPCTimerBase * NewTimer(std::function< void()> &func, int64_t millis) override
Factory function for timers.
Local Bitcoin RPC console.
QMenu * peersTableContextMenu
RPCConsole(interfaces::Node &node, const PlatformStyle *platformStyle, QWidget *parent)
void cmdRequest(const QString &command, const WalletModel *wallet_model)
void browseHistory(int offset)
Go forward or back in history.
RPCTimerInterface * rpcTimerInterface
QString TimeDurationField(std::chrono::seconds time_now, std::chrono::seconds time_at_event) const
Helper for the output of a time duration field.
void on_lineEdit_returnPressed()
void message(int category, const QString &msg)
Append the message to the message widget.
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
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)
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.
@ SUBVERSION_COLUMN_WIDTH
QCompleter * autoCompleter
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
interfaces::Node & m_node
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
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
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)
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
QString cmdBeforeBrowsing
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
void showOrHideBanTableIfRequired()
Hides ban table if no bans are present.
QMenu * banTableContextMenu
void peerLayoutChanged()
Handle updated peer information.
void reply(int category, const QString &command)
RPCExecutor(interfaces::Node &node)
interfaces::Node & m_node
void request(const QString &command, const WalletModel *wallet_model)
Opaque base class for timers returned by NewTimerFunc.
void push_back(UniValue val)
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
Interface to Bitcoin wallet from Qt view code.
QString getDisplayName() const
static bool isWalletEnabled()
QString getWalletName() const
Top-level interface for a bitcoin node (bitcoind process).
virtual void rpcSetTimerInterfaceIfUnset(RPCTimerInterface *iface)=0
Set RPC timer interface if unset.
virtual bool disconnectById(NodeId id)=0
Disconnect node by id.
virtual bool ban(const CNetAddr &net_addr, int64_t ban_time_offset)=0
Ban node.
virtual std::vector< std::string > listRpcCommands()=0
List rpc commands.
virtual void rpcUnsetTimerInterface(RPCTimerInterface *iface)=0
Unset RPC timer interface.
virtual bool getNetworkActive()=0
Get network active.
virtual bool unban(const CSubNet &ip)=0
Unban node.
virtual bool disconnectByAddress(const CNetAddr &net_addr)=0
Disconnect node by address.
UniValue RPCConvertValues(const std::string &strMethod, const std::vector< std::string > &strParams)
Convert positional arguments to command-specific RPC representation.
const Config & GetConfig()
QString NetworkToQString(Network net)
Convert enum Network to QString.
QString HtmlEscape(const QString &str, bool fMultiLine)
QList< QModelIndex > getEntryData(const QAbstractItemView *view, int column)
Return a field of the currently selected entry as a QString.
QString formatBytes(uint64_t bytes)
QString formatDurationStr(std::chrono::seconds dur)
Convert seconds into a QString with days, hours, mins, secs.
void handleCloseWindowShortcut(QWidget *w)
QString formatPingTime(std::chrono::microseconds ping_time)
Format a CNodeStats.m_last_ping_time into a user-readable string or display N/A, if 0.
QString formatTimeOffset(int64_t nTimeOffset)
Format a CNodeCombinedStats.nTimeOffset into a user-readable string.
QString formatServicesStr(quint64 mask)
Format CNodeStats.nServices bitmask into a user-readable string.
void ThreadRename(std::string &&)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name.
bool LookupSubNet(const std::string &strSubnet, CSubNet &ret, DNSLookupFn dns_lookup_function)
Parse and resolve a specified subnet string into the appropriate internal representation.
const struct @7 ICON_MAPPING[]
const int INITIAL_TRAFFIC_GRAPH_MINS
const QSize FONT_RANGE(4, 40)
const int CONSOLE_HISTORY
static QString categoryClass(int category)
const char fontSizeSettingsKey[]
constexpr bool IsDigit(char c)
Tests if the given character is a decimal digit.
CNodeStateStats nodeStateStats
bool fNodeStateStatsAvailable
std::chrono::microseconds m_ping_wait
ServiceFlags their_services
std::chrono::microseconds m_last_ping_time
std::chrono::seconds m_last_recv
std::chrono::seconds m_last_send
std::chrono::seconds m_last_tx_time
std::chrono::microseconds m_min_ping_time
std::chrono::seconds m_connected
bool m_bip152_highbandwidth_from
bool m_bip152_highbandwidth_to
std::chrono::seconds m_last_block_time
NetPermissionFlags m_permission_flags
int atoi(const std::string &str)