5#if defined(HAVE_CONFIG_H)
6#include <config/bitcoin-config.h>
11#include <chainparams.h>
18#include <qt/forms/ui_debugwindow.h>
38#include <QKeySequence>
58 {
"cmd-reply",
":/icons/tx_output"},
59 {
"cmd-error",
":/icons/tx_output"},
60 {
"misc",
":/icons/tx_inout"},
66const QStringList historyFilter = QStringList() <<
"importprivkey"
69 <<
"signmessagewithprivkey"
70 <<
"signrawtransactionwithkey"
72 <<
"walletpassphrasechange"
87 void reply(
int category,
const QString &command);
100 timer.setSingleShot(
true);
101 connect(&
timer, &QTimer::timeout, [
this] {
func(); });
114 const char *
Name()
override {
return "Qt"; }
116 int64_t millis)
override {
121#include <qt/rpcconsole.moc>
150 std::string &strResult,
151 const std::string &strCommand,
153 std::string *
const pstrFilteredOut,
155 std::vector<std::vector<std::string>> stack;
156 stack.push_back(std::vector<std::string>());
160 STATE_EATING_SPACES_IN_ARG,
161 STATE_EATING_SPACES_IN_BRACKETS,
166 STATE_ESCAPE_DOUBLEQUOTED,
167 STATE_COMMAND_EXECUTED,
168 STATE_COMMAND_EXECUTED_INNER
169 } state = STATE_EATING_SPACES;
172 unsigned nDepthInsideSensitive = 0;
173 size_t filter_begin_pos = 0, chpos;
174 std::vector<std::pair<size_t, size_t>> filter_ranges;
176 auto add_to_current_stack = [&](
const std::string &strArg) {
177 if (stack.back().empty() && (!nDepthInsideSensitive) &&
178 historyFilter.contains(QString::fromStdString(strArg),
179 Qt::CaseInsensitive)) {
180 nDepthInsideSensitive = 1;
181 filter_begin_pos = chpos;
185 stack.
push_back(std::vector<std::string>());
187 stack.back().push_back(strArg);
190 auto close_out_params = [&]() {
191 if (nDepthInsideSensitive) {
192 if (!--nDepthInsideSensitive) {
194 filter_ranges.push_back(
195 std::make_pair(filter_begin_pos, chpos));
196 filter_begin_pos = 0;
202 std::string strCommandTerminated = strCommand;
203 if (strCommandTerminated.back() !=
'\n') {
204 strCommandTerminated +=
"\n";
206 for (chpos = 0; chpos < strCommandTerminated.size(); ++chpos) {
207 char ch = strCommandTerminated[chpos];
209 case STATE_COMMAND_EXECUTED_INNER:
210 case STATE_COMMAND_EXECUTED: {
211 bool breakParsing =
true;
215 state = STATE_COMMAND_EXECUTED_INNER;
218 if (state == STATE_COMMAND_EXECUTED_INNER) {
225 if (curarg.size() && fExecute) {
230 for (
char argch : curarg) {
232 throw std::runtime_error(
233 "Invalid result query");
237 lastResult[LocaleIndependentAtoi<int>(
243 throw std::runtime_error(
244 "Invalid result query");
246 lastResult = subelement;
249 state = STATE_COMMAND_EXECUTED;
254 breakParsing =
false;
262 if (lastResult.
isStr()) {
265 curarg = lastResult.
write(2);
272 add_to_current_stack(curarg);
279 state = STATE_EATING_SPACES;
288 case STATE_EATING_SPACES_IN_ARG:
289 case STATE_EATING_SPACES_IN_BRACKETS:
290 case STATE_EATING_SPACES:
293 state = STATE_DOUBLEQUOTED;
296 state = STATE_SINGLEQUOTED;
299 state = STATE_ESCAPE_OUTER;
304 if (state == STATE_EATING_SPACES_IN_ARG) {
305 throw std::runtime_error(
"Invalid Syntax");
307 if (state == STATE_ARGUMENT) {
308 if (ch ==
'(' && stack.size() &&
309 stack.back().size() > 0) {
310 if (nDepthInsideSensitive) {
311 ++nDepthInsideSensitive;
313 stack.push_back(std::vector<std::string>());
319 throw std::runtime_error(
"Invalid Syntax");
322 add_to_current_stack(curarg);
324 state = STATE_EATING_SPACES_IN_BRACKETS;
326 if ((ch ==
')' || ch ==
'\n') && stack.size() > 0) {
333 std::vector<std::string>(
334 stack.back().begin() + 1,
335 stack.back().end()));
336 std::string method = stack.back()[0];
341 QByteArray encodedName =
342 QUrl::toPercentEncoding(
345 std::string(encodedName.constData(),
346 encodedName.length());
351 lastResult =
node->executeRpc(
355 state = STATE_COMMAND_EXECUTED;
362 if (state == STATE_EATING_SPACES_IN_ARG &&
363 curarg.empty() && ch ==
',') {
364 throw std::runtime_error(
"Invalid Syntax");
365 }
else if (state == STATE_ARGUMENT) {
367 add_to_current_stack(curarg);
370 if ((state == STATE_EATING_SPACES_IN_BRACKETS ||
371 state == STATE_ARGUMENT) &&
373 state = STATE_EATING_SPACES_IN_ARG;
376 state = STATE_EATING_SPACES;
380 state = STATE_ARGUMENT;
383 case STATE_SINGLEQUOTED:
386 state = STATE_ARGUMENT;
392 case STATE_DOUBLEQUOTED:
395 state = STATE_ARGUMENT;
398 state = STATE_ESCAPE_DOUBLEQUOTED;
404 case STATE_ESCAPE_OUTER:
406 state = STATE_ARGUMENT;
408 case STATE_ESCAPE_DOUBLEQUOTED:
409 if (ch !=
'"' && ch !=
'\\') {
414 state = STATE_DOUBLEQUOTED;
418 if (pstrFilteredOut) {
419 if (STATE_COMMAND_EXECUTED == state) {
423 *pstrFilteredOut = strCommand;
424 for (
auto i = filter_ranges.rbegin(); i != filter_ranges.rend(); ++i) {
425 pstrFilteredOut->replace(i->first, i->second - i->first,
"(…)");
431 case STATE_COMMAND_EXECUTED:
432 if (lastResult.
isStr()) {
433 strResult = lastResult.
get_str();
435 strResult = lastResult.
write(2);
439 case STATE_EATING_SPACES:
450 std::string executableCommand = command.toStdString() +
"\n";
454 if (executableCommand ==
"help-console\n") {
458 "This console accepts RPC commands using the standard "
460 " example: getblockhash 0\n\n"
462 "This console can also accept RPC commands using "
463 "parenthesized syntax.\n"
464 " example: getblockhash(0)\n\n"
466 "Commands may be nested when specified with the "
467 "parenthesized syntax.\n"
468 " example: getblock(getblockhash(0) 1)\n\n"
470 "A space or a comma can be used to delimit arguments "
471 "for either syntax.\n"
472 " example: getblockhash 0\n"
473 " getblockhash,0\n\n"
475 "Named results can be queried with a non-quoted key "
476 "string in brackets.\n"
477 " example: getblock(getblockhash(0) true)[tx]\n\n"
479 "Results without keys can be queried using an integer "
482 "getblock(getblockhash(0),true)[tx][0]\n\n")));
486 m_node, result, executableCommand,
nullptr, wallet_model)) {
488 QString(
"Parse error: unbalanced ' or \""));
499 QString::fromStdString(message) +
" (code " +
500 QString::number(code) +
")");
501 }
catch (
const std::runtime_error &) {
505 QString::fromStdString(objError.
write()));
507 }
catch (
const std::exception &e) {
509 QString(
"Error: ") + QString::fromStdString(e.what()));
516 platformStyle(_platformStyle) {
519 if (!restoreGeometry(
520 settings.value(
"RPCConsoleWindowGeometry").toByteArray())) {
522 move(QGuiApplication::primaryScreen()->availableGeometry().center() -
523 frameGeometry().center());
526 QChar nonbreaking_hyphen(8209);
527 const QString hb_list{
"<ul><li>\"" + tr(
"To") +
"\" – " +
528 tr(
"we selected the peer for high bandwidth relay") +
529 "</li><li>\"" + tr(
"From") +
"\" – " +
530 tr(
"the peer selected us for high bandwidth relay") +
531 "</li><li>\"" + tr(
"No") +
"\" – " +
532 tr(
"no high bandwidth relay selected") +
534 ui->peerHighBandwidthLabel->setToolTip(
535 ui->peerHighBandwidthLabel->toolTip().arg(hb_list));
536 ui->dataDir->setToolTip(
537 ui->dataDir->toolTip().arg(QString(nonbreaking_hyphen) +
"datadir"));
538 ui->blocksDir->setToolTip(
ui->blocksDir->toolTip().arg(
539 QString(nonbreaking_hyphen) +
"blocksdir"));
540 ui->openDebugLogfileButton->setToolTip(
541 ui->openDebugLogfileButton->toolTip().arg(PACKAGE_NAME));
544 ui->openDebugLogfileButton->setIcon(
548 ui->fontBiggerButton->setIcon(
550 ui->fontSmallerButton->setIcon(
554 ui->lineEdit->installEventFilter(
this);
555 ui->lineEdit->setMaxLength(16 * 1024 * 1024);
556 ui->messagesWidget->installEventFilter(
this);
559 connect(
ui->fontBiggerButton, &QPushButton::clicked,
this,
561 connect(
ui->fontSmallerButton, &QPushButton::clicked,
this,
563 connect(
ui->btnClearTrafficGraph, &QPushButton::clicked,
ui->trafficGraph,
567 ui->WalletSelector->setVisible(
false);
568 ui->WalletSelectorLabel->setVisible(
false);
572 ui->berkeleyDBVersion->setText(
575 ui->label_berkeleyDBVersion->hide();
576 ui->berkeleyDBVersion->hide();
596 settings.setValue(
"RPCConsoleWindowGeometry", saveGeometry());
604 if (event->type() == QEvent::KeyPress) {
605 QKeyEvent *keyevt =
static_cast<QKeyEvent *
>(event);
606 int key = keyevt->key();
607 Qt::KeyboardModifiers mod = keyevt->modifiers();
610 if (obj ==
ui->lineEdit) {
616 if (obj ==
ui->lineEdit) {
622 case Qt::Key_PageDown:
623 if (obj ==
ui->lineEdit) {
624 QApplication::sendEvent(
ui->messagesWidget, keyevt);
632 QApplication::sendEvent(
ui->lineEdit, keyevt);
640 if (obj ==
ui->messagesWidget &&
641 ((!mod && !keyevt->text().isEmpty() &&
642 key != Qt::Key_Tab) ||
643 ((mod & Qt::ControlModifier) && key == Qt::Key_V) ||
644 ((mod & Qt::ShiftModifier) && key == Qt::Key_Insert))) {
645 ui->lineEdit->setFocus();
646 QApplication::sendEvent(
ui->lineEdit, keyevt);
651 return QWidget::eventFilter(obj, event);
655 int64_t bestblock_date,
656 double verification_progress) {
659 bool wallet_enabled{
false};
663 if (model && !wallet_enabled) {
670 ui->trafficGraph->setClientModel(model);
679 QDateTime::fromSecsSinceEpoch(bestblock_date),
698 ui->peerWidget->verticalHeader()->hide();
699 ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
700 ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
701 ui->peerWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
702 ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu);
708 ui->peerWidget->horizontalHeader()->setStretchLastSection(
true);
711 QAction *disconnectAction =
new QAction(tr(
"&Disconnect"),
this);
712 QAction *banAction1h =
713 new QAction(tr(
"Ban for") +
" " + tr(
"1 &hour"),
this);
714 QAction *banAction24h =
715 new QAction(tr(
"Ban for") +
" " + tr(
"1 &day"),
this);
716 QAction *banAction7d =
717 new QAction(tr(
"Ban for") +
" " + tr(
"1 &week"),
this);
718 QAction *banAction365d =
719 new QAction(tr(
"Ban for") +
" " + tr(
"1 &year"),
this);
729 connect(banAction1h, &QAction::triggered,
731 connect(banAction24h, &QAction::triggered,
733 connect(banAction7d, &QAction::triggered,
735 connect(banAction365d, &QAction::triggered,
739 connect(
ui->peerWidget, &QTableView::customContextMenuRequested,
this,
741 connect(disconnectAction, &QAction::triggered,
this,
746 connect(
ui->peerWidget->selectionModel(),
747 &QItemSelectionModel::selectionChanged,
this,
755 &PeerTableModel::layoutAboutToBeChanged,
this,
760 ui->banlistWidget->verticalHeader()->hide();
761 ui->banlistWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
762 ui->banlistWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
763 ui->banlistWidget->setSelectionMode(QAbstractItemView::SingleSelection);
764 ui->banlistWidget->setContextMenuPolicy(Qt::CustomContextMenu);
769 ui->banlistWidget->horizontalHeader()->setStretchLastSection(
true);
772 QAction *unbanAction =
new QAction(tr(
"&Unban"),
this);
779 connect(
ui->banlistWidget, &QTableView::customContextMenuRequested,
781 connect(unbanAction, &QAction::triggered,
this,
786 connect(
ui->banlistWidget, &QTableView::clicked,
this,
800 ui->networkName->setText(
801 QString::fromStdString(
Params().GetChainTypeString()));
804 QStringList wordList;
806 for (
size_t i = 0; i < commandList.size(); ++i) {
807 wordList << commandList[i].c_str();
808 wordList << (
"help " + commandList[i]).c_str();
811 wordList <<
"help-console";
814 autoCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel);
817 ui->lineEdit->setEnabled(
true);
832void RPCConsole::addWallet(
WalletModel *
const walletModel) {
836 QVariant::fromValue(walletModel));
837 if (
ui->WalletSelector->count() == 2 && !isVisible()) {
840 ui->WalletSelector->setCurrentIndex(1);
842 if (
ui->WalletSelector->count() > 2) {
843 ui->WalletSelector->setVisible(
true);
844 ui->WalletSelectorLabel->setVisible(
true);
848void RPCConsole::removeWallet(
WalletModel *
const walletModel) {
849 ui->WalletSelector->removeItem(
850 ui->WalletSelector->findData(QVariant::fromValue(walletModel)));
851 if (
ui->WalletSelector->count() == 2) {
852 ui->WalletSelector->setVisible(
false);
853 ui->WalletSelectorLabel->setVisible(
false);
861 return "cmd-request";
891 QString str =
ui->messagesWidget->toHtml();
895 QString(
"font-size:%1pt").arg(newSize));
903 float oldPosFactor = 1.0 /
904 ui->messagesWidget->verticalScrollBar()->maximum() *
905 ui->messagesWidget->verticalScrollBar()->value();
907 ui->messagesWidget->setHtml(str);
908 ui->messagesWidget->verticalScrollBar()->setValue(
909 oldPosFactor *
ui->messagesWidget->verticalScrollBar()->maximum());
913 ui->messagesWidget->clear();
918 ui->lineEdit->clear();
919 ui->lineEdit->setFocus();
925 ui->messagesWidget->document()->addResource(
929 Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
934 ui->messagesWidget->document()->setDefaultStyleSheet(
936 "td.time { color: #808080; font-size: %2; padding-top: 3px; } "
937 "td.message { font-family: %1; font-size: %2; "
938 "white-space:pre-wrap; } "
939 "td.cmd-request { color: #006060; } "
940 "td.cmd-error { color: red; } "
941 ".secwarning { color: red; }"
942 "b { color: #006060; } ")
946 QString clsKey =
"(⌘)-L";
948 QString clsKey =
"Ctrl-L";
952 (tr(
"Welcome to the %1 RPC console.").arg(PACKAGE_NAME) +
"<br>" +
953 tr(
"Use up and down arrows to navigate history, and "
954 "%1 to clear screen.")
955 .arg(
"<b>" + clsKey +
"</b>") +
957 tr(
"Type %1 for an overview of available commands.")
958 .arg(
"<b>help</b>") +
960 tr(
"For more information on using this console type %1.")
961 .arg(
"<b>help-console</b>") +
962 "<br><span class=\"secwarning\"><br>" +
963 tr(
"WARNING: Scammers have been active, telling users to type "
964 "commands here, stealing their wallet contents. Do not use "
965 "this console without fully understanding the ramifications "
972 if (windowType() != Qt::Widget && event->key() == Qt::Key_Escape) {
978 QTime time = QTime::currentTime();
979 QString timeString = time.toString();
981 out +=
"<table><tr><td class=\"time\" width=\"65\">" + timeString +
"</td>";
982 out +=
"<td class=\"icon\" width=\"32\"><img src=\"" +
985 "\" valign=\"middle\">";
991 out +=
"</td></tr></table>";
992 ui->messagesWidget->append(out);
1000 QString connections =
1002 connections += tr(
"In:") +
" " +
1006 connections += tr(
"Out:") +
" " +
1012 connections +=
" (" + tr(
"Network activity disabled") +
")";
1015 ui->numberOfConnections->setText(connections);
1031 double nVerificationProgress,
SyncType synctype) {
1033 ui->numberOfBlocks->setText(QString::number(
count));
1034 ui->lastBlockTime->setText(blockDate.toString());
1039 ui->mempoolNumberTxs->setText(QString::number(numberOfTxs));
1041 if (dynUsage < 1000000) {
1042 ui->mempoolSize->setText(QString::number(dynUsage / 1000.0,
'f', 2) +
1045 ui->mempoolSize->setText(QString::number(dynUsage / 1000000.0,
'f', 2) +
1051 QString cmd =
ui->lineEdit->text();
1053 if (!cmd.isEmpty()) {
1054 std::string strFilteredCmd;
1061 throw std::runtime_error(
"Invalid command line");
1063 }
catch (
const std::exception &e) {
1064 QMessageBox::critical(
this,
"Error",
1065 QString(
"Error: ") +
1066 QString::fromStdString(e.what()));
1070 ui->lineEdit->clear();
1076 wallet_model =
ui->WalletSelector->currentData().value<
WalletModel *>();
1081 .arg(wallet_model->getWalletName()));
1084 tr(
"Executing command without any wallet"));
1093 QMetaObject::invokeMethod(
m_executor, [
this, cmd, wallet_model] {
1097 cmd = QString::fromStdString(strFilteredCmd);
1134 ui->lineEdit->setText(cmd);
1143 static_cast<void (
RPCConsole::*)(
int,
const QString &)
>(
1147 connect(&
thread, &QThread::finished,
m_executor, &RPCExecutor::deleteLater);
1157 if (
ui->tabWidget->widget(index) ==
ui->tab_console) {
1158 ui->lineEdit->setFocus();
1167 QScrollBar *scrollbar =
ui->messagesWidget->verticalScrollBar();
1168 scrollbar->setValue(scrollbar->maximum());
1172 const int multiplier = 5;
1173 int mins = value * multiplier;
1178 ui->trafficGraph->setGraphRangeMins(mins);
1179 ui->lblGraphRange->setText(
1184 quint64 totalBytesOut) {
1190 QModelIndexList selected =
1191 ui->peerWidget->selectionModel()->selectedIndexes();
1193 for (
int i = 0; i < selected.size(); i++) {
1196 selected.at(i).row());
1206 bool fUnselect =
false;
1207 bool fReselect =
false;
1215 int selectedRow = -1;
1216 QModelIndexList selectedModelIndex =
1217 ui->peerWidget->selectionModel()->selectedIndexes();
1218 if (!selectedModelIndex.isEmpty()) {
1219 selectedRow = selectedModelIndex.first().row();
1227 if (detailNodeRow < 0) {
1231 if (detailNodeRow != selectedRow) {
1238 if (fUnselect && selectedRow >= 0) {
1244 ui->peerWidget->selectRow(
1254 QModelIndexList selected_rows;
1255 auto selection_model =
ui->peerWidget->selectionModel();
1256 if (selection_model) {
1257 selected_rows = selection_model->selectedRows();
1260 selected_rows.size() != 1) {
1261 ui->detailWidget->hide();
1262 ui->peerHeading->setText(
1263 tr(
"Select a peer to view detailed information."));
1268 selected_rows.first().row());
1270 QString peerAddrDetails(
1275 peerAddrDetails +=
"<br />" + tr(
"via %1").arg(QString::fromStdString(
1278 ui->peerHeading->setText(peerAddrDetails);
1279 QString bip152_hb_settings;
1281 bip152_hb_settings +=
"To";
1284 bip152_hb_settings += (bip152_hb_settings ==
"" ?
"From" :
"/From");
1286 if (bip152_hb_settings ==
"") {
1287 bip152_hb_settings =
"No";
1289 ui->peerHighBandwidth->setText(bip152_hb_settings);
1290 const auto time_now{GetTime<std::chrono::seconds>()};
1291 ui->peerConnTime->setText(
1293 ui->peerLastBlock->setText(
1295 ui->peerLastTx->setText(
1297 ui->peerLastSend->setText(
1299 ui->peerLastRecv->setText(
1301 ui->peerBytesSent->setText(
1303 ui->peerBytesRecv->setText(
1305 ui->peerPingTime->setText(
1307 ui->peerMinPing->setText(
1309 ui->timeoffset->setText(
1312 ui->peerSubversion->setText(
1316 ui->peerNetwork->setText(
1319 ui->peerPermissions->setText(tr(
"N/A"));
1321 QStringList permissions;
1322 for (
const auto &permission :
1324 permissions.append(QString::fromStdString(permission));
1326 ui->peerPermissions->setText(permissions.join(
" & "));
1328 ui->peerMappedAS->setText(
1336 ui->peerServices->setText(
1340 ui->peerSyncHeight->setText(
1343 ui->peerSyncHeight->setText(tr(
"Unknown"));
1348 ui->peerCommonHeight->setText(
1351 ui->peerCommonHeight->setText(tr(
"Unknown"));
1354 ui->peerHeight->setText(
1356 ui->peerPingWait->setText(
1362 ui->detailWidget->show();
1366 QWidget::resizeEvent(event);
1370 QWidget::showEvent(event);
1381 QWidget::hideEvent(event);
1392 QModelIndex index =
ui->peerWidget->indexAt(point);
1393 if (index.isValid()) {
1399 QModelIndex index =
ui->banlistWidget->indexAt(point);
1400 if (index.isValid()) {
1407 QList<QModelIndex> nodes =
1409 for (
int i = 0; i < nodes.count(); i++) {
1411 NodeId id = nodes.at(i).data().toLongLong();
1425 QList<QModelIndex> nodes =
1427 for (
int i = 0; i < nodes.count(); i++) {
1429 NodeId id = nodes.at(i).data().toLongLong();
1434 if (detailNodeRow < 0) {
1456 QList<QModelIndex> nodes =
1458 for (
int i = 0; i < nodes.count(); i++) {
1460 QString strNode = nodes.at(i).data().toString();
1471 ui->peerWidget->selectionModel()->clearSelection();
1482 ui->banlistWidget->setVisible(visible);
1483 ui->banHeading->setVisible(visible);
1487 ui->tabWidget->setCurrentIndex(
int(tabType));
1491 return ui->tabWidget->tabText(
int(tab_type));
1497 return QKeySequence(tr(
"Ctrl+I"));
1499 return QKeySequence(tr(
"Ctrl+T"));
1501 return QKeySequence(tr(
"Ctrl+N"));
1503 return QKeySequence(tr(
"Ctrl+P"));
1510 this->
ui->label_alerts->setVisible(!warnings.isEmpty());
1511 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)
~QtRPCTimerBase()=default
const char * Name() override
Implementation name.
RPCTimerBase * NewTimer(std::function< void()> &func, int64_t millis) override
Factory function for timers.
~QtRPCTimerInterface()=default
Local Bitcoin RPC console.
QMenu * peersTableContextMenu
RPCConsole(interfaces::Node &node, const PlatformStyle *platformStyle, QWidget *parent)
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
virtual bool eventFilter(QObject *obj, QEvent *event) override
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)
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