5 #include <bitcoin-build-config.h> 8 #include <qt/forms/ui_debugwindow.h> 10 #include <chainparams.h> 21 #endif // ENABLE_WALLET 26 #include <util/time.h> 31 #include <QAbstractButton> 32 #include <QAbstractItemModel> 36 #include <QKeySequence> 37 #include <QLatin1String> 40 #include <QMessageBox> 45 #include <QStringList> 46 #include <QStyledItemDelegate> 64 {
"cmd-request",
":/icons/tx_input"},
65 {
"cmd-reply",
":/icons/tx_output"},
66 {
"cmd-error",
":/icons/tx_output"},
67 {
"misc",
":/icons/tx_inout"},
74 const QStringList historyFilter = QStringList()
76 <<
"createwalletdescriptor" 78 <<
"signmessagewithprivkey" 79 <<
"signrawtransactionwithkey" 81 <<
"walletpassphrasechange" 109 : QStyledItemDelegate(parent) {}
111 QString
displayText(
const QVariant& value,
const QLocale& locale)
const override 115 return value.toString() + QLatin1String(
" ");
119 #include <qt/rpcconsole.moc> 143 std::vector< std::vector<std::string> > stack;
144 stack.emplace_back();
149 STATE_EATING_SPACES_IN_ARG,
150 STATE_EATING_SPACES_IN_BRACKETS,
155 STATE_ESCAPE_DOUBLEQUOTED,
156 STATE_COMMAND_EXECUTED,
157 STATE_COMMAND_EXECUTED_INNER
158 } state = STATE_EATING_SPACES;
161 unsigned nDepthInsideSensitive = 0;
162 size_t filter_begin_pos = 0, chpos;
163 std::vector<std::pair<size_t, size_t>> filter_ranges;
165 auto add_to_current_stack = [&](
const std::string& strArg) {
166 if (stack.back().empty() && (!nDepthInsideSensitive) && historyFilter.contains(QString::fromStdString(strArg), Qt::CaseInsensitive)) {
167 nDepthInsideSensitive = 1;
168 filter_begin_pos = chpos;
172 stack.emplace_back();
177 auto close_out_params = [&]() {
178 if (nDepthInsideSensitive) {
179 if (!--nDepthInsideSensitive) {
181 filter_ranges.emplace_back(filter_begin_pos, chpos);
182 filter_begin_pos = 0;
188 std::string strCommandTerminated = strCommand;
189 if (strCommandTerminated.back() !=
'\n')
190 strCommandTerminated +=
"\n";
191 for (chpos = 0; chpos < strCommandTerminated.size(); ++chpos)
193 char ch = strCommandTerminated[chpos];
196 case STATE_COMMAND_EXECUTED_INNER:
197 case STATE_COMMAND_EXECUTED:
199 bool breakParsing =
true;
202 case '[': curarg.clear(); state = STATE_COMMAND_EXECUTED_INNER;
break;
204 if (state == STATE_COMMAND_EXECUTED_INNER)
212 if (curarg.size() && fExecute)
218 const auto parsed{ToIntegral<size_t>(curarg)};
220 throw std::runtime_error(
"Invalid result query");
222 subelement = lastResult[parsed.value()];
227 throw std::runtime_error(
"Invalid result query");
228 lastResult = subelement;
231 state = STATE_COMMAND_EXECUTED;
235 breakParsing =
false;
241 if (lastResult.
isStr())
244 curarg = lastResult.
write(2);
250 add_to_current_stack(curarg);
256 state = STATE_EATING_SPACES;
263 case STATE_EATING_SPACES_IN_ARG:
264 case STATE_EATING_SPACES_IN_BRACKETS:
265 case STATE_EATING_SPACES:
268 case '"': state = STATE_DOUBLEQUOTED;
break;
269 case '\'': state = STATE_SINGLEQUOTED;
break;
270 case '\\': state = STATE_ESCAPE_OUTER;
break;
271 case '(':
case ')':
case '\n':
272 if (state == STATE_EATING_SPACES_IN_ARG)
273 throw std::runtime_error(
"Invalid Syntax");
274 if (state == STATE_ARGUMENT)
276 if (ch ==
'(' && stack.size() && stack.back().size() > 0)
278 if (nDepthInsideSensitive) {
279 ++nDepthInsideSensitive;
281 stack.emplace_back();
286 throw std::runtime_error(
"Invalid Syntax");
288 add_to_current_stack(curarg);
290 state = STATE_EATING_SPACES_IN_BRACKETS;
292 if ((ch ==
')' || ch ==
'\n') && stack.size() > 0)
297 UniValue params =
RPCConvertValues(stack.back()[0], std::vector<std::string>(stack.back().begin() + 1, stack.back().end()));
298 std::string method = stack.back()[0];
300 if (!wallet_name.isEmpty()) {
301 QByteArray encodedName = QUrl::toPercentEncoding(wallet_name);
302 uri =
"/wallet/"+std::string(encodedName.constData(), encodedName.length());
305 lastResult =
node->executeRpc(method, params, uri);
308 state = STATE_COMMAND_EXECUTED;
312 case ' ':
case ',':
case '\t':
313 if(state == STATE_EATING_SPACES_IN_ARG && curarg.empty() && ch ==
',')
314 throw std::runtime_error(
"Invalid Syntax");
316 else if(state == STATE_ARGUMENT)
318 add_to_current_stack(curarg);
321 if ((state == STATE_EATING_SPACES_IN_BRACKETS || state == STATE_ARGUMENT) && ch ==
',')
323 state = STATE_EATING_SPACES_IN_ARG;
326 state = STATE_EATING_SPACES;
328 default: curarg += ch; state = STATE_ARGUMENT;
331 case STATE_SINGLEQUOTED:
334 case '\'': state = STATE_ARGUMENT;
break;
335 default: curarg += ch;
338 case STATE_DOUBLEQUOTED:
341 case '"': state = STATE_ARGUMENT;
break;
342 case '\\': state = STATE_ESCAPE_DOUBLEQUOTED;
break;
343 default: curarg += ch;
346 case STATE_ESCAPE_OUTER:
347 curarg += ch; state = STATE_ARGUMENT;
349 case STATE_ESCAPE_DOUBLEQUOTED:
350 if(ch !=
'"' && ch !=
'\\') curarg +=
'\\';
351 curarg += ch; state = STATE_DOUBLEQUOTED;
355 if (pstrFilteredOut) {
356 if (STATE_COMMAND_EXECUTED == state) {
360 *pstrFilteredOut = strCommand;
361 for (
auto i = filter_ranges.rbegin(); i != filter_ranges.rend(); ++i) {
362 pstrFilteredOut->replace(i->first, i->second - i->first,
"(…)");
367 case STATE_COMMAND_EXECUTED:
368 if (lastResult.
isStr())
369 strResult = lastResult.
get_str();
371 strResult = lastResult.
write(2);
374 case STATE_EATING_SPACES:
386 std::string executableCommand =
command.toStdString() +
"\n";
389 if(executableCommand ==
"help-console\n") {
391 "This console accepts RPC commands using the standard syntax.\n" 392 " example: getblockhash 0\n\n" 394 "This console can also accept RPC commands using the parenthesized syntax.\n" 395 " example: getblockhash(0)\n\n" 397 "Commands may be nested when specified with the parenthesized syntax.\n" 398 " example: getblock(getblockhash(0) 1)\n\n" 400 "A space or a comma can be used to delimit arguments for either syntax.\n" 401 " example: getblockhash 0\n" 402 " getblockhash,0\n\n" 404 "Named results can be queried with a non-quoted key string in brackets using the parenthesized syntax.\n" 405 " example: getblock(getblockhash(0) 1)[tx]\n\n" 407 "Results without keys can be queried with an integer in brackets using the parenthesized syntax.\n" 408 " example: getblock(getblockhash(0),1)[tx][0]\n\n")));
426 catch (
const std::runtime_error&)
431 catch (
const std::exception& e)
441 platformStyle(_platformStyle)
448 if (!restoreGeometry(settings.value(
"RPCConsoleWindowGeometry").toByteArray())) {
450 move(QGuiApplication::primaryScreen()->availableGeometry().center() - frameGeometry().center());
452 ui->splitter->restoreState(settings.value(
"RPCConsoleWindowPeersTabSplitterSizes").toByteArray());
454 #endif // ENABLE_WALLET 457 ui->splitter->restoreState(settings.value(
"RPCConsoleWidgetPeersTabSplitterSizes").toByteArray());
463 constexpr QChar nonbreaking_hyphen(8209);
466 tr(
"Inbound: initiated by peer"),
470 tr(
"Outbound Full Relay: default"),
473 tr(
"Outbound Block Relay: does not relay transactions or addresses"),
478 tr(
"Outbound Manual: added using RPC %1 or %2/%3 configuration options")
480 .arg(QString(nonbreaking_hyphen) +
"addnode")
481 .arg(QString(nonbreaking_hyphen) +
"connect"),
484 tr(
"Outbound Feeler: short-lived, for testing addresses"),
487 tr(
"Outbound Address Fetch: short-lived, for soliciting addresses"),
490 tr(
"Private broadcast: short-lived, for broadcasting privacy-sensitive transactions")};
491 const QString connection_types_list{
"<ul><li>" +
Join(
CONNECTION_TYPE_DOC, QString(
"</li><li>")) +
"</li></ul>"};
492 ui->peerConnectionTypeLabel->setToolTip(
ui->peerConnectionTypeLabel->toolTip().arg(connection_types_list));
495 tr(
"detecting: peer could be v1 or v2"),
497 tr(
"v1: unencrypted, plaintext transport protocol"),
499 tr(
"v2: BIP324 encrypted transport protocol")};
500 const QString transport_types_list{
"<ul><li>" +
Join(
TRANSPORT_TYPE_DOC, QString(
"</li><li>")) +
"</li></ul>"};
501 ui->peerTransportTypeLabel->setToolTip(
ui->peerTransportTypeLabel->toolTip().arg(transport_types_list));
502 const QString hb_list{
"<ul><li>\"" 503 +
ts.
to +
"\" – " + tr(
"we selected the peer for high bandwidth relay") +
"</li><li>\"" 504 +
ts.
from +
"\" – " + tr(
"the peer selected us for high bandwidth relay") +
"</li><li>\"" 505 +
ts.
no +
"\" – " + tr(
"no high bandwidth relay selected") +
"</li></ul>"};
506 ui->peerHighBandwidthLabel->setToolTip(
ui->peerHighBandwidthLabel->toolTip().arg(hb_list));
507 ui->dataDir->setToolTip(
ui->dataDir->toolTip().arg(QString(nonbreaking_hyphen) +
"datadir"));
508 ui->blocksDir->setToolTip(
ui->blocksDir->toolTip().arg(QString(nonbreaking_hyphen) +
"blocksdir"));
509 ui->openDebugLogfileButton->setToolTip(
ui->openDebugLogfileButton->toolTip().arg(CLIENT_NAME));
518 ui->fontBiggerButton->setShortcut(tr(
"Ctrl++"));
524 ui->fontSmallerButton->setShortcut(tr(
"Ctrl+-"));
531 ui->lineEdit->installEventFilter(
this);
532 ui->lineEdit->setMaxLength(16 * 1024 * 1024);
533 ui->messagesWidget->installEventFilter(
this);
536 connect(
ui->clearButton, &QAbstractButton::clicked, [
this] { clear(); });
542 ui->WalletSelector->setVisible(
false);
543 ui->WalletSelectorLabel->setVisible(
false);
562 settings.setValue(
"RPCConsoleWindowGeometry", saveGeometry());
563 settings.setValue(
"RPCConsoleWindowPeersTabSplitterSizes",
ui->splitter->saveState());
565 #endif // ENABLE_WALLET 568 settings.setValue(
"RPCConsoleWidgetPeersTabSplitterSizes",
ui->splitter->saveState());
579 if(event->type() == QEvent::KeyPress)
581 QKeyEvent *keyevt =
static_cast<QKeyEvent*
>(event);
582 int key = keyevt->key();
583 Qt::KeyboardModifiers mod = keyevt->modifiers();
586 case Qt::Key_Up:
if(obj ==
ui->lineEdit) {
browseHistory(-1);
return true; }
break;
587 case Qt::Key_Down:
if(obj ==
ui->lineEdit) {
browseHistory(1);
return true; }
break;
589 case Qt::Key_PageDown:
590 if (obj ==
ui->lineEdit) {
591 QApplication::sendEvent(
ui->messagesWidget, keyevt);
599 QApplication::sendEvent(
ui->lineEdit, keyevt);
607 if(obj ==
ui->messagesWidget && (
608 (!mod && !keyevt->text().isEmpty() && key != Qt::Key_Tab) ||
609 ((mod & Qt::ControlModifier) && key == Qt::Key_V) ||
610 ((mod & Qt::ShiftModifier) && key == Qt::Key_Insert)))
612 ui->lineEdit->setFocus();
613 QApplication::sendEvent(
ui->lineEdit, keyevt);
618 return QWidget::eventFilter(obj, event);
625 bool wallet_enabled{
false};
628 #endif // ENABLE_WALLET 629 if (model && !wallet_enabled) {
635 ui->trafficGraph->setClientModel(model);
655 ui->peerWidget->verticalHeader()->hide();
656 ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
657 ui->peerWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
658 ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu);
665 ui->peerWidget->horizontalHeader()->setSectionResizeMode(
PeerTableModel::Age, QHeaderView::ResizeToContents);
666 ui->peerWidget->horizontalHeader()->setStretchLastSection(
true);
689 ui->banlistWidget->verticalHeader()->hide();
690 ui->banlistWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
691 ui->banlistWidget->setSelectionMode(QAbstractItemView::SingleSelection);
692 ui->banlistWidget->setContextMenuPolicy(Qt::CustomContextMenu);
699 ui->banlistWidget->horizontalHeader()->setStretchLastSection(
true);
725 ui->networkName->setText(QString::fromStdString(
Params().GetChainTypeString()));
728 QStringList wordList;
730 for (
size_t i = 0; i < commandList.size(); ++i)
732 wordList << commandList[i].c_str();
733 wordList << (
"help " + commandList[i]).c_str();
736 wordList <<
"help-console";
739 autoCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel);
742 ui->lineEdit->setEnabled(
true);
756 void RPCConsole::addWallet(
WalletModel *
const walletModel)
759 ui->WalletSelector->addItem(walletModel->
getDisplayName(), QVariant::fromValue(walletModel));
760 if (
ui->WalletSelector->count() == 2) {
762 ui->WalletSelector->setCurrentIndex(1);
764 if (
ui->WalletSelector->count() > 2) {
765 ui->WalletSelector->setVisible(
true);
766 ui->WalletSelectorLabel->setVisible(
true);
770 void RPCConsole::removeWallet(
WalletModel *
const walletModel)
772 ui->WalletSelector->removeItem(
ui->WalletSelector->findData(QVariant::fromValue(walletModel)));
773 if (
ui->WalletSelector->count() == 2) {
774 ui->WalletSelector->setVisible(
false);
775 ui->WalletSelectorLabel->setVisible(
false);
779 void RPCConsole::setCurrentWallet(
WalletModel*
const wallet_model)
781 QVariant
data = QVariant::fromValue(wallet_model);
782 ui->WalletSelector->setCurrentIndex(
ui->WalletSelector->findData(
data));
793 default:
return "misc";
816 QString str =
ui->messagesWidget->toHtml();
819 str.replace(QString(
"font-size:%1pt").arg(
consoleFontSize), QString(
"font-size:%1pt").arg(newSize));
826 float oldPosFactor = 1.0 /
ui->messagesWidget->verticalScrollBar()->maximum() *
ui->messagesWidget->verticalScrollBar()->value();
828 ui->messagesWidget->setHtml(str);
829 ui->messagesWidget->verticalScrollBar()->setValue(oldPosFactor *
ui->messagesWidget->verticalScrollBar()->maximum());
834 ui->messagesWidget->clear();
835 if (!keep_prompt)
ui->lineEdit->clear();
836 ui->lineEdit->setFocus();
842 ui->messagesWidget->document()->addResource(
843 QTextDocument::ImageResource,
854 ui->messagesWidget->document()->setDefaultStyleSheet(
857 "td.time { color: #808080; font-size: %2; padding-top: 3px; } " 858 "td.message { font-family: %1; font-size: %2; white-space:pre-wrap; } " 859 "td.cmd-request { color: #006060; } " 860 "td.cmd-error { color: red; } " 861 ".secwarning { color: red; }" 862 "b { color: #006060; } " 866 static const QString welcome_message =
870 tr(
"Welcome to the %1 RPC console.\n" 871 "Use up and down arrows to navigate history, and %2 to clear screen.\n" 872 "Use %3 and %4 to increase or decrease the font size.\n" 873 "Type %5 for an overview of available commands.\n" 874 "For more information on using this console, type %6.\n" 876 "%7WARNING: Scammers have been active, telling users to type" 877 " commands here, stealing their wallet contents. Do not use this console" 878 " without fully understanding the ramifications of a command.%8")
880 "<b>" +
ui->clearButton->shortcut().toString(QKeySequence::NativeText) +
"</b>",
881 "<b>" +
ui->fontBiggerButton->shortcut().toString(QKeySequence::NativeText) +
"</b>",
882 "<b>" +
ui->fontSmallerButton->shortcut().toString(QKeySequence::NativeText) +
"</b>",
884 "<b>help-console</b>",
885 "<span class=\"secwarning\">",
900 if (e->type() == QEvent::PaletteChange) {
907 ui->messagesWidget->document()->addResource(
908 QTextDocument::ImageResource,
914 QWidget::changeEvent(e);
919 QTime time = QTime::currentTime();
920 QString timeString = time.toString();
922 out +=
"<table><tr><td class=\"time\" width=\"65\">" + timeString +
"</td>";
923 out +=
"<td class=\"icon\" width=\"32\"><img src=\"" +
categoryClass(category) +
"\"></td>";
924 out +=
"<td class=\"message " +
categoryClass(category) +
"\" valign=\"middle\">";
929 out +=
"</td></tr></table>";
930 ui->messagesWidget->append(
out);
941 connections +=
" (" + tr(
"Network activity disabled") +
")";
944 ui->numberOfConnections->setText(connections);
946 QString local_addresses;
948 for (
const auto& [addr, info] : hosts) {
949 local_addresses += QString::fromStdString(addr.ToStringAddr());
950 if (!addr.IsI2P()) local_addresses +=
":" + QString::number(info.nPort);
951 local_addresses +=
", ";
953 local_addresses.chop(2);
954 if (local_addresses.isEmpty()) local_addresses = tr(
"None");
956 ui->localAddresses->setText(local_addresses);
975 ui->numberOfBlocks->setText(QString::number(
count));
976 ui->lastBlockTime->setText(blockDate.toString());
982 ui->mempoolNumberTxs->setText(QString::number(numberOfTxs));
984 const auto cur_usage_str = dynUsage < 1000000 ?
985 QObject::tr(
"%1 kB").arg(dynUsage / 1000.0, 0,
'f', 2) :
986 QObject::tr(
"%1 MB").arg(dynUsage / 1000000.0, 0,
'f', 2);
987 const auto max_usage_str = QObject::tr(
"%1 MB").arg(maxUsage / 1000000.0, 0,
'f', 2);
989 ui->mempoolSize->setText(cur_usage_str +
" / " + max_usage_str);
994 QString
cmd =
ui->lineEdit->text().trimmed();
1000 std::string strFilteredCmd;
1005 throw std::runtime_error(
"Invalid command line");
1007 }
catch (
const std::exception& e) {
1008 QMessageBox::critical(
this,
"Error", QString(
"Error: ") + QString::fromStdString(e.what()));
1013 if (
cmd == QLatin1String(
"stop")) {
1023 ui->lineEdit->clear();
1025 QString in_use_wallet_name;
1026 #ifdef ENABLE_WALLET 1028 in_use_wallet_name = wallet_model ? wallet_model->
getWalletName() : QString();
1037 #endif // ENABLE_WALLET 1044 QMetaObject::invokeMethod(
m_executor, [
this,
cmd, in_use_wallet_name] {
1048 cmd = QString::fromStdString(strFilteredCmd);
1083 ui->lineEdit->setText(
cmd);
1094 ui->messagesWidget->undo();
1101 connect(&
thread, &QThread::finished,
m_executor, &RPCExecutor::deleteLater);
1113 if (
ui->tabWidget->widget(index) ==
ui->tab_console) {
1114 ui->lineEdit->setFocus();
1125 QScrollBar *scrollbar =
ui->messagesWidget->verticalScrollBar();
1126 scrollbar->setValue(scrollbar->maximum());
1131 const int multiplier = 5;
1132 int mins = value * multiplier;
1138 ui->trafficGraph->setGraphRange(std::chrono::minutes{mins});
1152 ui->peersTabRightPanel->hide();
1153 ui->peerHeading->setText(tr(
"Select a peer to view detailed information."));
1158 QString peerAddrDetails(QString::fromStdString(stats->nodeStats.m_addr_name) +
" ");
1159 peerAddrDetails += tr(
"(peer: %1)").arg(QString::number(stats->nodeStats.nodeid));
1160 if (!stats->nodeStats.addrLocal.empty())
1161 peerAddrDetails +=
"<br />" + tr(
"via %1").arg(QString::fromStdString(stats->nodeStats.addrLocal));
1162 ui->peerHeading->setText(peerAddrDetails);
1163 QString bip152_hb_settings;
1164 if (stats->nodeStats.m_bip152_highbandwidth_to) bip152_hb_settings =
ts.
to;
1165 if (stats->nodeStats.m_bip152_highbandwidth_from) bip152_hb_settings += (bip152_hb_settings.isEmpty() ?
ts.
from : QLatin1Char(
'/') +
ts.
from);
1166 if (bip152_hb_settings.isEmpty()) bip152_hb_settings =
ts.
no;
1167 ui->peerHighBandwidth->setText(bip152_hb_settings);
1168 const auto time_now{GetTime<std::chrono::seconds>()};
1170 ui->peerLastBlock->setText(
TimeDurationField(time_now, stats->nodeStats.m_last_block_time));
1178 ui->peerVersion->setText(stats->nodeStats.nVersion ? QString::number(stats->nodeStats.nVersion) :
ts.
na);
1179 ui->peerSubversion->setText(!stats->nodeStats.cleanSubVer.empty() ? QString::fromStdString(stats->nodeStats.cleanSubVer) :
ts.
na);
1181 ui->peerTransportType->setText(QString::fromStdString(
TransportTypeAsString(stats->nodeStats.m_transport_type)));
1183 ui->peerSessionIdLabel->setVisible(
true);
1184 ui->peerSessionId->setVisible(
true);
1185 ui->peerSessionId->setText(QString::fromStdString(stats->nodeStats.m_session_id));
1187 ui->peerSessionIdLabel->setVisible(
false);
1188 ui->peerSessionId->setVisible(
false);
1192 ui->peerPermissions->setText(
ts.
na);
1194 QStringList permissions;
1196 permissions.append(QString::fromStdString(permission));
1198 ui->peerPermissions->setText(permissions.join(
" & "));
1200 ui->peerMappedAS->setText(stats->nodeStats.m_mapped_as != 0 ? QString::number(stats->nodeStats.m_mapped_as) :
ts.
na);
1204 if (stats->fNodeStateStatsAvailable) {
1208 if (stats->nodeStateStats.nSyncHeight > -1) {
1209 ui->peerSyncHeight->setText(QString(
"%1").arg(stats->nodeStateStats.nSyncHeight));
1214 if (stats->nodeStateStats.nCommonHeight > -1) {
1215 ui->peerCommonHeight->setText(QString(
"%1").arg(stats->nodeStateStats.nCommonHeight));
1220 ui->peerAddrRelayEnabled->setText(stats->nodeStateStats.m_addr_relay_enabled ?
ts.
yes :
ts.
no);
1221 ui->peerAddrProcessed->setText(QString::number(stats->nodeStateStats.m_addr_processed));
1222 ui->peerAddrRateLimited->setText(QString::number(stats->nodeStateStats.m_addr_rate_limited));
1223 ui->peerRelayTxes->setText(stats->nodeStateStats.m_relay_txs ?
ts.
yes :
ts.
no);
1227 ui->peersTabRightPanel->show();
1232 QWidget::resizeEvent(event);
1237 QWidget::showEvent(event);
1253 QWidget::hideEvent(event);
1264 QModelIndex index =
ui->peerWidget->indexAt(point);
1265 if (index.isValid())
1271 QModelIndex index =
ui->banlistWidget->indexAt(point);
1272 if (index.isValid())
1280 for(
int i = 0; i < nodes.count(); i++)
1283 NodeId id = nodes.at(i).data().toLongLong();
1299 m_node.
ban(stats->nodeStats.addr, bantime);
1315 bool unbanned{
false};
1316 for (
const auto& node_index : nodes) {
1317 unbanned |= ban_table_model->
unban(node_index);
1320 ban_table_model->refresh();
1326 ui->peerWidget->selectionModel()->clearSelection();
1337 ui->banlistWidget->setVisible(visible);
1338 ui->banHeading->setVisible(visible);
1343 ui->tabWidget->setCurrentIndex(
int(tabType));
1348 return ui->tabWidget->tabText(
int(tab_type));
1365 this->
ui->label_alerts->setVisible(!warnings.isEmpty());
1366 this->
ui->label_alerts->setText(warnings);
1374 const QString chainType = QString::fromStdString(
Params().GetChainTypeString());
1375 const QString title = tr(
"Node window - [%1]").arg(chainType);
1376 this->setWindowTitle(title);
QString formatClientStartupTime() const
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...
void push_back(UniValue val)
QString formatSubVersion() const
Local Bitcoin RPC console.
QString cmdBeforeBrowsing
virtual bool getNetworkActive()=0
Get network active.
static bool isWalletEnabled()
void on_lineEdit_returnPressed()
RPCExecutor(interfaces::Node &node)
static bool RPCParseCommandLine(interfaces::Node *node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string *pstrFilteredOut=nullptr, const QString &wallet_name={})
Split shell command line into a list of arguments and optionally execute the command(s).
QString blocksDir() const
void showPeersTableContextMenu(const QPoint &point)
Show custom context menu on Peers tab.
WalletModel * m_last_wallet_model
void updateDetailWidget()
show detailed information on ui about selected node
void setClientModel(ClientModel *model=nullptr, int bestblock_height=0, int64_t bestblock_date=0, double verification_progress=0.0)
interfaces::Node & m_node
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
void scrollToEnd()
Scroll console view to end.
QString formatBytes(uint64_t bytes)
void networkActiveChanged(bool networkActive)
static QString categoryClass(int category)
void clearSelectedNode()
clear the selected node
const struct @8 ICON_MAPPING[]
RPCConsole(interfaces::Node &node, const PlatformStyle *platformStyle, QWidget *parent)
const std::string & get_str() const
QString HtmlEscape(const QString &str, bool fMultiLine)
QFont fixedPitchFont(bool use_embedded_font)
void changeEvent(QEvent *e) override
PeerTableModel * getPeerTableModel()
void disconnectSelectedNode()
Disconnect a selected node on the Peers tab.
void on_tabWidget_currentChanged(int index)
void ThreadRename(const std::string &)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name...
void numConnectionsChanged(int count)
QString formatDurationStr(std::chrono::seconds dur)
Convert seconds into a QString with days, hours, mins, secs.
virtual bool ban(const CNetAddr &net_addr, int64_t ban_time_offset)=0
Ban node.
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
QString tabTitle(TabTypes tab_type) const
void alertsChanged(const QString &warnings)
void clear(bool keep_prompt=false)
UniValue RPCConvertValues(const std::string &strMethod, const std::vector< std::string > &strParams)
Convert command lines arguments to params object when -named is disabled.
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut)
std::string TransportTypeAsString(TransportProtocolType transport_type)
Convert TransportProtocolType enum to a string value.
const UniValue & find_value(std::string_view key) const
const PlatformStyle *const platformStyle
void reply(int category, const QString &command)
struct RPCConsole::TranslatedStrings ts
QMenu * peersTableContextMenu
QString NetworkToQString(Network net)
Convert enum Network to QString.
void browseHistory(int offset)
Go forward or back in history.
void resizeEvent(QResizeEvent *event) override
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes, size_t mempoolMaxSizeInBytes)
void message(int category, const QString &msg)
Append the message to the message widget.
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
std::map< CNetAddr, LocalServiceInfo > getNetLocalAddresses() const
QByteArray m_banlist_widget_header_state
const int CONSOLE_HISTORY
void handleCloseWindowShortcut(QWidget *w)
void setMempoolSize(long numberOfTxs, size_t dynUsage, size_t maxUsage)
Set size (number of transactions and memory usage) of the mempool in the UI.
void setTabFocus(enum TabTypes tabType)
set which tab has the focus (is visible)
void numBlocksChanged(int count, const QDateTime &blockDate, double nVerificationProgress, SyncType header, SynchronizationState sync_state)
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction)
Convert enum ConnectionType to QString.
BanTableModel * getBanTableModel()
interfaces::Node & node() const
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
virtual bool disconnectByAddress(const CNetAddr &net_addr)=0
Disconnect node by address.
void updateNetworkState()
Update UI with latest network info from model.
QByteArray m_peer_widget_header_state
QString displayText(const QVariant &value, const QLocale &locale) const override
QString getWalletName() const
void on_openDebugLogfileButton_clicked()
open the debug.log from the current datadir
void copyEntryData(const QAbstractItemView *view, int column, int role)
Copy a field of the currently selected entry of a view to the clipboard.
Model for Bitcoin network client.
void unbanSelectedNode()
Unban a selected node on the Bans tab.
ClientModel * clientModel
QMenu * banTableContextMenu
void setTrafficGraphRange(int mins)
QKeySequence tabShortcut(TabTypes tab_type) const
bool IsEscapeOrBack(int key)
void showOrHideBanTableIfRequired()
Hides ban table if no bans are present.
void request(const QString &command, const QString &wallet_name)
const std::vector< std::string > CONNECTION_TYPE_DOC
void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
update traffic statistics
QList< NodeId > cachedNodeids
ChainType GetChainType() const
Return the chain type.
void setFontSize(int newSize)
PeerIdViewDelegate(QObject *parent=nullptr)
void setNumConnections(int count)
Set number of connections shown in the UI.
const CChainParams & Params()
Return the currently selected parameters.
interfaces::Node & m_node
Interface to Bitcoin wallet from Qt view code.
virtual std::vector< std::string > listRpcCommands()=0
List rpc commands.
bool unban(const QModelIndex &index)
QString formatServicesStr(quint64 mask)
Format CNodeStats.nServices bitmask into a user-readable string.
void on_sldGraphRange_valueChanged(int value)
change the time range of the network traffic graph
Qt model providing information about banned peers, similar to the "getpeerinfo" RPC call...
void banSelectedNode(int bantime)
Ban a selected node on the Peers tab.
static bool RPCExecuteCommandLine(interfaces::Node &node, std::string &strResult, const std::string &strCommand, std::string *const pstrFilteredOut=nullptr, const QString &wallet_name={})
void setNumBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, SyncType synctype)
Set number of blocks and last block date shown in the UI.
void updateAlerts(const QString &warnings)
const int INITIAL_TRAFFIC_GRAPH_MINS
QString TimeDurationField(std::chrono::seconds time_now, std::chrono::seconds time_at_event) const
Helper for the output of a time duration field.
const char fontSizeSettingsKey[]
QString getDisplayName() const
const QSize FONT_RANGE(4, 40)
QString formatTimeOffset(int64_t time_offset)
Format a CNodeStateStats.time_offset into a user-readable string.
const std::vector< std::string > TRANSPORT_TYPE_DOC
PeerTableSortProxy * peerTableSortProxy()
virtual bool disconnectById(NodeId id)=0
Disconnect node by id.
void showEvent(QShowEvent *event) override
QCompleter * autoCompleter
auto Join(const C &container, const S &separator, UnaryOp unary_op)
Join all container items.
void AddButtonShortcut(QAbstractButton *button, const QKeySequence &shortcut)
Connects an additional shortcut to a QAbstractButton.
Top-level interface for a bitcoin node (bitcoind process).
void showBanTableContextMenu(const QPoint &point)
Show custom context menu on Bans tab.
void keyPressEvent(QKeyEvent *) override
void hideEvent(QHideEvent *event) override
virtual bool eventFilter(QObject *obj, QEvent *event) override
static std::vector< std::string > ToStrings(NetPermissionFlags flags)
QList< QModelIndex > getEntryData(const QAbstractItemView *view, int column)
Return a field of the currently selected entry as a QString.
QString formatFullVersion() const