5#include <bitcoin-build-config.h>
8#include <qt/forms/ui_debugwindow.h>
10#include <chainparams.h>
31#include <QAbstractButton>
32#include <QAbstractItemModel>
36#include <QKeySequence>
37#include <QLatin1String>
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"},
74const QStringList historyFilter = QStringList()
75 <<
"signmessagewithprivkey"
76 <<
"signrawtransactionwithkey"
78 <<
"walletpassphrasechange"
106 : QStyledItemDelegate(parent) {}
108 QString
displayText(
const QVariant& value,
const QLocale& locale)
const override
112 return value.toString() + QLatin1String(
" ");
116#include <qt/rpcconsole.moc>
140 std::vector< std::vector<std::string> > stack;
141 stack.emplace_back();
146 STATE_EATING_SPACES_IN_ARG,
147 STATE_EATING_SPACES_IN_BRACKETS,
152 STATE_ESCAPE_DOUBLEQUOTED,
153 STATE_COMMAND_EXECUTED,
154 STATE_COMMAND_EXECUTED_INNER
155 } state = STATE_EATING_SPACES;
158 unsigned nDepthInsideSensitive = 0;
159 size_t filter_begin_pos = 0, chpos;
160 std::vector<std::pair<size_t, size_t>> filter_ranges;
162 auto add_to_current_stack = [&](
const std::string& strArg) {
163 if (stack.back().empty() && (!nDepthInsideSensitive) && historyFilter.contains(QString::fromStdString(strArg), Qt::CaseInsensitive)) {
164 nDepthInsideSensitive = 1;
165 filter_begin_pos = chpos;
169 stack.emplace_back();
174 auto close_out_params = [&]() {
175 if (nDepthInsideSensitive) {
176 if (!--nDepthInsideSensitive) {
178 filter_ranges.emplace_back(filter_begin_pos, chpos);
179 filter_begin_pos = 0;
185 std::string strCommandTerminated = strCommand;
186 if (strCommandTerminated.back() !=
'\n')
187 strCommandTerminated +=
"\n";
188 for (chpos = 0; chpos < strCommandTerminated.size(); ++chpos)
190 char ch = strCommandTerminated[chpos];
193 case STATE_COMMAND_EXECUTED_INNER:
194 case STATE_COMMAND_EXECUTED:
196 bool breakParsing =
true;
199 case '[': curarg.clear(); state = STATE_COMMAND_EXECUTED_INNER;
break;
201 if (state == STATE_COMMAND_EXECUTED_INNER)
209 if (curarg.size() && fExecute)
215 const auto parsed{ToIntegral<size_t>(curarg)};
217 throw std::runtime_error(
"Invalid result query");
219 subelement = lastResult[parsed.value()];
224 throw std::runtime_error(
"Invalid result query");
225 lastResult = subelement;
228 state = STATE_COMMAND_EXECUTED;
232 breakParsing =
false;
238 if (lastResult.
isStr())
241 curarg = lastResult.
write(2);
247 add_to_current_stack(curarg);
253 state = STATE_EATING_SPACES;
260 case STATE_EATING_SPACES_IN_ARG:
261 case STATE_EATING_SPACES_IN_BRACKETS:
262 case STATE_EATING_SPACES:
265 case '"': state = STATE_DOUBLEQUOTED;
break;
266 case '\'': state = STATE_SINGLEQUOTED;
break;
267 case '\\': state = STATE_ESCAPE_OUTER;
break;
268 case '(':
case ')':
case '\n':
269 if (state == STATE_EATING_SPACES_IN_ARG)
270 throw std::runtime_error(
"Invalid Syntax");
271 if (state == STATE_ARGUMENT)
273 if (ch ==
'(' && stack.size() && stack.back().size() > 0)
275 if (nDepthInsideSensitive) {
276 ++nDepthInsideSensitive;
278 stack.emplace_back();
283 throw std::runtime_error(
"Invalid Syntax");
285 add_to_current_stack(curarg);
287 state = STATE_EATING_SPACES_IN_BRACKETS;
289 if ((ch ==
')' || ch ==
'\n') && stack.size() > 0)
294 UniValue params =
RPCConvertValues(stack.back()[0], std::vector<std::string>(stack.back().begin() + 1, stack.back().end()));
295 std::string method = stack.back()[0];
297 if (!wallet_name.isEmpty()) {
298 QByteArray encodedName = QUrl::toPercentEncoding(wallet_name);
299 uri =
"/wallet/"+std::string(encodedName.constData(), encodedName.length());
302 lastResult =
node->executeRpc(method, params, uri);
305 state = STATE_COMMAND_EXECUTED;
309 case ' ':
case ',':
case '\t':
310 if(state == STATE_EATING_SPACES_IN_ARG && curarg.empty() && ch ==
',')
311 throw std::runtime_error(
"Invalid Syntax");
313 else if(state == STATE_ARGUMENT)
315 add_to_current_stack(curarg);
318 if ((state == STATE_EATING_SPACES_IN_BRACKETS || state == STATE_ARGUMENT) && ch ==
',')
320 state = STATE_EATING_SPACES_IN_ARG;
323 state = STATE_EATING_SPACES;
325 default: curarg += ch; state = STATE_ARGUMENT;
328 case STATE_SINGLEQUOTED:
331 case '\'': state = STATE_ARGUMENT;
break;
332 default: curarg += ch;
335 case STATE_DOUBLEQUOTED:
338 case '"': state = STATE_ARGUMENT;
break;
339 case '\\': state = STATE_ESCAPE_DOUBLEQUOTED;
break;
340 default: curarg += ch;
343 case STATE_ESCAPE_OUTER:
344 curarg += ch; state = STATE_ARGUMENT;
346 case STATE_ESCAPE_DOUBLEQUOTED:
347 if(ch !=
'"' && ch !=
'\\') curarg +=
'\\';
348 curarg += ch; state = STATE_DOUBLEQUOTED;
352 if (pstrFilteredOut) {
353 if (STATE_COMMAND_EXECUTED == state) {
357 *pstrFilteredOut = strCommand;
358 for (
auto i = filter_ranges.rbegin(); i != filter_ranges.rend(); ++i) {
359 pstrFilteredOut->replace(i->first, i->second - i->first,
"(…)");
364 case STATE_COMMAND_EXECUTED:
365 if (lastResult.
isStr())
366 strResult = lastResult.
get_str();
368 strResult = lastResult.
write(2);
371 case STATE_EATING_SPACES:
383 std::string executableCommand =
command.toStdString() +
"\n";
386 if(executableCommand ==
"help-console\n") {
388 "This console accepts RPC commands using the standard syntax.\n"
389 " example: getblockhash 0\n\n"
391 "This console can also accept RPC commands using the parenthesized syntax.\n"
392 " example: getblockhash(0)\n\n"
394 "Commands may be nested when specified with the parenthesized syntax.\n"
395 " example: getblock(getblockhash(0) 1)\n\n"
397 "A space or a comma can be used to delimit arguments for either syntax.\n"
398 " example: getblockhash 0\n"
399 " getblockhash,0\n\n"
401 "Named results can be queried with a non-quoted key string in brackets using the parenthesized syntax.\n"
402 " example: getblock(getblockhash(0) 1)[tx]\n\n"
404 "Results without keys can be queried with an integer in brackets using the parenthesized syntax.\n"
405 " example: getblock(getblockhash(0),1)[tx][0]\n\n")));
423 catch (
const std::runtime_error&)
428 catch (
const std::exception& e)
438 platformStyle(_platformStyle)
445 if (!restoreGeometry(settings.value(
"RPCConsoleWindowGeometry").toByteArray())) {
447 move(QGuiApplication::primaryScreen()->availableGeometry().center() - frameGeometry().center());
449 ui->splitter->restoreState(settings.value(
"RPCConsoleWindowPeersTabSplitterSizes").toByteArray());
454 ui->splitter->restoreState(settings.value(
"RPCConsoleWidgetPeersTabSplitterSizes").toByteArray());
460 constexpr QChar nonbreaking_hyphen(8209);
463 tr(
"Inbound: initiated by peer"),
467 tr(
"Outbound Full Relay: default"),
470 tr(
"Outbound Block Relay: does not relay transactions or addresses"),
475 tr(
"Outbound Manual: added using RPC %1 or %2/%3 configuration options")
477 .arg(QString(nonbreaking_hyphen) +
"addnode")
478 .arg(QString(nonbreaking_hyphen) +
"connect"),
481 tr(
"Outbound Feeler: short-lived, for testing addresses"),
484 tr(
"Outbound Address Fetch: short-lived, for soliciting addresses")};
485 const QString connection_types_list{
"<ul><li>" +
Join(
CONNECTION_TYPE_DOC, QString(
"</li><li>")) +
"</li></ul>"};
486 ui->peerConnectionTypeLabel->setToolTip(
ui->peerConnectionTypeLabel->toolTip().arg(connection_types_list));
489 tr(
"detecting: peer could be v1 or v2"),
491 tr(
"v1: unencrypted, plaintext transport protocol"),
493 tr(
"v2: BIP324 encrypted transport protocol")};
494 const QString transport_types_list{
"<ul><li>" +
Join(
TRANSPORT_TYPE_DOC, QString(
"</li><li>")) +
"</li></ul>"};
495 ui->peerTransportTypeLabel->setToolTip(
ui->peerTransportTypeLabel->toolTip().arg(transport_types_list));
496 const QString hb_list{
"<ul><li>\""
497 +
ts.
to +
"\" – " + tr(
"we selected the peer for high bandwidth relay") +
"</li><li>\""
498 +
ts.
from +
"\" – " + tr(
"the peer selected us for high bandwidth relay") +
"</li><li>\""
499 +
ts.
no +
"\" – " + tr(
"no high bandwidth relay selected") +
"</li></ul>"};
500 ui->peerHighBandwidthLabel->setToolTip(
ui->peerHighBandwidthLabel->toolTip().arg(hb_list));
501 ui->dataDir->setToolTip(
ui->dataDir->toolTip().arg(QString(nonbreaking_hyphen) +
"datadir"));
502 ui->blocksDir->setToolTip(
ui->blocksDir->toolTip().arg(QString(nonbreaking_hyphen) +
"blocksdir"));
503 ui->openDebugLogfileButton->setToolTip(
ui->openDebugLogfileButton->toolTip().arg(CLIENT_NAME));
512 ui->fontBiggerButton->setShortcut(tr(
"Ctrl++"));
518 ui->fontSmallerButton->setShortcut(tr(
"Ctrl+-"));
525 ui->lineEdit->installEventFilter(
this);
526 ui->lineEdit->setMaxLength(16 * 1024 * 1024);
527 ui->messagesWidget->installEventFilter(
this);
530 connect(
ui->clearButton, &QAbstractButton::clicked, [
this] { clear(); });
536 ui->WalletSelector->setVisible(
false);
537 ui->WalletSelectorLabel->setVisible(
false);
556 settings.setValue(
"RPCConsoleWindowGeometry", saveGeometry());
557 settings.setValue(
"RPCConsoleWindowPeersTabSplitterSizes",
ui->splitter->saveState());
562 settings.setValue(
"RPCConsoleWidgetPeersTabSplitterSizes",
ui->splitter->saveState());
573 if(event->type() == QEvent::KeyPress)
575 QKeyEvent *keyevt =
static_cast<QKeyEvent*
>(event);
576 int key = keyevt->key();
577 Qt::KeyboardModifiers mod = keyevt->modifiers();
580 case Qt::Key_Up:
if(obj ==
ui->lineEdit) {
browseHistory(-1);
return true; }
break;
581 case Qt::Key_Down:
if(obj ==
ui->lineEdit) {
browseHistory(1);
return true; }
break;
583 case Qt::Key_PageDown:
584 if (obj ==
ui->lineEdit) {
585 QApplication::sendEvent(
ui->messagesWidget, keyevt);
593 QApplication::sendEvent(
ui->lineEdit, keyevt);
601 if(obj ==
ui->messagesWidget && (
602 (!mod && !keyevt->text().isEmpty() && key != Qt::Key_Tab) ||
603 ((mod & Qt::ControlModifier) && key == Qt::Key_V) ||
604 ((mod & Qt::ShiftModifier) && key == Qt::Key_Insert)))
606 ui->lineEdit->setFocus();
607 QApplication::sendEvent(
ui->lineEdit, keyevt);
612 return QWidget::eventFilter(obj, event);
619 bool wallet_enabled{
false};
623 if (model && !wallet_enabled) {
629 ui->trafficGraph->setClientModel(model);
649 ui->peerWidget->verticalHeader()->hide();
650 ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
651 ui->peerWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
652 ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu);
659 ui->peerWidget->horizontalHeader()->setSectionResizeMode(
PeerTableModel::Age, QHeaderView::ResizeToContents);
660 ui->peerWidget->horizontalHeader()->setStretchLastSection(
true);
679 connect(model->
getPeerTableModel(), &QAbstractItemModel::dataChanged, [
this] { updateDetailWidget(); });
683 ui->banlistWidget->verticalHeader()->hide();
684 ui->banlistWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
685 ui->banlistWidget->setSelectionMode(QAbstractItemView::SingleSelection);
686 ui->banlistWidget->setContextMenuPolicy(Qt::CustomContextMenu);
693 ui->banlistWidget->horizontalHeader()->setStretchLastSection(
true);
719 ui->networkName->setText(QString::fromStdString(
Params().GetChainTypeString()));
722 QStringList wordList;
724 for (
size_t i = 0; i < commandList.size(); ++i)
726 wordList << commandList[i].c_str();
727 wordList << (
"help " + commandList[i]).c_str();
730 wordList <<
"help-console";
733 autoCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel);
736 ui->lineEdit->setEnabled(
true);
750void RPCConsole::addWallet(
WalletModel *
const walletModel)
753 ui->WalletSelector->addItem(walletModel->
getDisplayName(), QVariant::fromValue(walletModel));
754 if (
ui->WalletSelector->count() == 2) {
756 ui->WalletSelector->setCurrentIndex(1);
758 if (
ui->WalletSelector->count() > 2) {
759 ui->WalletSelector->setVisible(
true);
760 ui->WalletSelectorLabel->setVisible(
true);
764void RPCConsole::removeWallet(
WalletModel *
const walletModel)
766 ui->WalletSelector->removeItem(
ui->WalletSelector->findData(QVariant::fromValue(walletModel)));
767 if (
ui->WalletSelector->count() == 2) {
768 ui->WalletSelector->setVisible(
false);
769 ui->WalletSelectorLabel->setVisible(
false);
773void RPCConsole::setCurrentWallet(
WalletModel*
const wallet_model)
775 QVariant
data = QVariant::fromValue(wallet_model);
776 ui->WalletSelector->setCurrentIndex(
ui->WalletSelector->findData(
data));
787 default:
return "misc";
810 QString str =
ui->messagesWidget->toHtml();
813 str.replace(QString(
"font-size:%1pt").arg(
consoleFontSize), QString(
"font-size:%1pt").arg(newSize));
820 float oldPosFactor = 1.0 /
ui->messagesWidget->verticalScrollBar()->maximum() *
ui->messagesWidget->verticalScrollBar()->value();
822 ui->messagesWidget->setHtml(str);
823 ui->messagesWidget->verticalScrollBar()->setValue(oldPosFactor *
ui->messagesWidget->verticalScrollBar()->maximum());
828 ui->messagesWidget->clear();
829 if (!keep_prompt)
ui->lineEdit->clear();
830 ui->lineEdit->setFocus();
836 ui->messagesWidget->document()->addResource(
837 QTextDocument::ImageResource,
848 ui->messagesWidget->document()->setDefaultStyleSheet(
851 "td.time { color: #808080; font-size: %2; padding-top: 3px; } "
852 "td.message { font-family: %1; font-size: %2; white-space:pre-wrap; } "
853 "td.cmd-request { color: #006060; } "
854 "td.cmd-error { color: red; } "
855 ".secwarning { color: red; }"
856 "b { color: #006060; } "
860 static const QString welcome_message =
864 tr(
"Welcome to the %1 RPC console.\n"
865 "Use up and down arrows to navigate history, and %2 to clear screen.\n"
866 "Use %3 and %4 to increase or decrease the font size.\n"
867 "Type %5 for an overview of available commands.\n"
868 "For more information on using this console, type %6.\n"
870 "%7WARNING: Scammers have been active, telling users to type"
871 " commands here, stealing their wallet contents. Do not use this console"
872 " without fully understanding the ramifications of a command.%8")
874 "<b>" +
ui->clearButton->shortcut().toString(QKeySequence::NativeText) +
"</b>",
875 "<b>" +
ui->fontBiggerButton->shortcut().toString(QKeySequence::NativeText) +
"</b>",
876 "<b>" +
ui->fontSmallerButton->shortcut().toString(QKeySequence::NativeText) +
"</b>",
878 "<b>help-console</b>",
879 "<span class=\"secwarning\">",
894 if (e->type() == QEvent::PaletteChange) {
901 ui->messagesWidget->document()->addResource(
902 QTextDocument::ImageResource,
908 QWidget::changeEvent(e);
913 QTime time = QTime::currentTime();
914 QString timeString = time.toString();
916 out +=
"<table><tr><td class=\"time\" width=\"65\">" + timeString +
"</td>";
917 out +=
"<td class=\"icon\" width=\"32\"><img src=\"" +
categoryClass(category) +
"\"></td>";
918 out +=
"<td class=\"message " +
categoryClass(category) +
"\" valign=\"middle\">";
923 out +=
"</td></tr></table>";
924 ui->messagesWidget->append(
out);
935 connections +=
" (" + tr(
"Network activity disabled") +
")";
938 ui->numberOfConnections->setText(connections);
940 QString local_addresses;
942 for (
const auto& [addr, info] : hosts) {
943 local_addresses += QString::fromStdString(addr.ToStringAddr());
944 if (!addr.IsI2P()) local_addresses +=
":" + QString::number(info.nPort);
945 local_addresses +=
", ";
947 local_addresses.chop(2);
948 if (local_addresses.isEmpty()) local_addresses = tr(
"None");
950 ui->localAddresses->setText(local_addresses);
969 ui->numberOfBlocks->setText(QString::number(
count));
970 ui->lastBlockTime->setText(blockDate.toString());
976 ui->mempoolNumberTxs->setText(QString::number(numberOfTxs));
978 const auto cur_usage_str = dynUsage < 1000000 ?
979 QObject::tr(
"%1 kB").arg(dynUsage / 1000.0, 0,
'f', 2) :
980 QObject::tr(
"%1 MB").arg(dynUsage / 1000000.0, 0,
'f', 2);
981 const auto max_usage_str = QObject::tr(
"%1 MB").arg(maxUsage / 1000000.0, 0,
'f', 2);
983 ui->mempoolSize->setText(cur_usage_str +
" / " + max_usage_str);
988 QString
cmd =
ui->lineEdit->text().trimmed();
994 std::string strFilteredCmd;
999 throw std::runtime_error(
"Invalid command line");
1001 }
catch (
const std::exception& e) {
1002 QMessageBox::critical(
this,
"Error", QString(
"Error: ") + QString::fromStdString(e.what()));
1007 if (
cmd == QLatin1String(
"stop")) {
1017 ui->lineEdit->clear();
1019 QString in_use_wallet_name;
1022 in_use_wallet_name = wallet_model ? wallet_model->
getWalletName() : QString();
1038 QMetaObject::invokeMethod(
m_executor, [
this,
cmd, in_use_wallet_name] {
1042 cmd = QString::fromStdString(strFilteredCmd);
1077 ui->lineEdit->setText(
cmd);
1088 ui->messagesWidget->undo();
1095 connect(&
thread, &QThread::finished,
m_executor, &RPCExecutor::deleteLater);
1107 if (
ui->tabWidget->widget(index) ==
ui->tab_console) {
1108 ui->lineEdit->setFocus();
1119 QScrollBar *scrollbar =
ui->messagesWidget->verticalScrollBar();
1120 scrollbar->setValue(scrollbar->maximum());
1125 const int multiplier = 5;
1126 int mins = value * multiplier;
1132 ui->trafficGraph->setGraphRange(std::chrono::minutes{mins});
1146 ui->peersTabRightPanel->hide();
1147 ui->peerHeading->setText(tr(
"Select a peer to view detailed information."));
1152 QString peerAddrDetails(QString::fromStdString(stats->nodeStats.m_addr_name) +
" ");
1153 peerAddrDetails += tr(
"(peer: %1)").arg(QString::number(stats->nodeStats.nodeid));
1154 if (!stats->nodeStats.addrLocal.empty())
1155 peerAddrDetails +=
"<br />" + tr(
"via %1").arg(QString::fromStdString(stats->nodeStats.addrLocal));
1156 ui->peerHeading->setText(peerAddrDetails);
1157 QString bip152_hb_settings;
1158 if (stats->nodeStats.m_bip152_highbandwidth_to) bip152_hb_settings =
ts.
to;
1159 if (stats->nodeStats.m_bip152_highbandwidth_from) bip152_hb_settings += (bip152_hb_settings.isEmpty() ?
ts.
from : QLatin1Char(
'/') +
ts.
from);
1160 if (bip152_hb_settings.isEmpty()) bip152_hb_settings =
ts.
no;
1161 ui->peerHighBandwidth->setText(bip152_hb_settings);
1162 const auto time_now{GetTime<std::chrono::seconds>()};
1164 ui->peerLastBlock->setText(
TimeDurationField(time_now, stats->nodeStats.m_last_block_time));
1172 if (stats->nodeStats.nVersion) {
1173 ui->peerVersion->setText(QString::number(stats->nodeStats.nVersion));
1175 if (!stats->nodeStats.cleanSubVer.empty()) {
1176 ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));
1179 ui->peerTransportType->setText(QString::fromStdString(
TransportTypeAsString(stats->nodeStats.m_transport_type)));
1181 ui->peerSessionIdLabel->setVisible(
true);
1182 ui->peerSessionId->setVisible(
true);
1183 ui->peerSessionId->setText(QString::fromStdString(stats->nodeStats.m_session_id));
1185 ui->peerSessionIdLabel->setVisible(
false);
1186 ui->peerSessionId->setVisible(
false);
1190 ui->peerPermissions->setText(
ts.
na);
1192 QStringList permissions;
1194 permissions.append(QString::fromStdString(permission));
1196 ui->peerPermissions->setText(permissions.join(
" & "));
1198 ui->peerMappedAS->setText(stats->nodeStats.m_mapped_as != 0 ? QString::number(stats->nodeStats.m_mapped_as) :
ts.
na);
1202 if (stats->fNodeStateStatsAvailable) {
1206 if (stats->nodeStateStats.nSyncHeight > -1) {
1207 ui->peerSyncHeight->setText(QString(
"%1").arg(stats->nodeStateStats.nSyncHeight));
1212 if (stats->nodeStateStats.nCommonHeight > -1) {
1213 ui->peerCommonHeight->setText(QString(
"%1").arg(stats->nodeStateStats.nCommonHeight));
1217 ui->peerHeight->setText(QString::number(stats->nodeStateStats.m_starting_height));
1219 ui->peerAddrRelayEnabled->setText(stats->nodeStateStats.m_addr_relay_enabled ?
ts.
yes :
ts.
no);
1220 ui->peerAddrProcessed->setText(QString::number(stats->nodeStateStats.m_addr_processed));
1221 ui->peerAddrRateLimited->setText(QString::number(stats->nodeStateStats.m_addr_rate_limited));
1222 ui->peerRelayTxes->setText(stats->nodeStateStats.m_relay_txs ?
ts.
yes :
ts.
no);
1226 ui->peersTabRightPanel->show();
1231 QWidget::resizeEvent(event);
1236 QWidget::showEvent(event);
1252 QWidget::hideEvent(event);
1263 QModelIndex index =
ui->peerWidget->indexAt(point);
1264 if (index.isValid())
1270 QModelIndex index =
ui->banlistWidget->indexAt(point);
1271 if (index.isValid())
1279 for(
int i = 0; i < nodes.count(); i++)
1282 NodeId id = nodes.at(i).data().toLongLong();
1298 m_node.
ban(stats->nodeStats.addr, bantime);
1314 bool unbanned{
false};
1315 for (
const auto& node_index : nodes) {
1316 unbanned |= ban_table_model->
unban(node_index);
1319 ban_table_model->refresh();
1325 ui->peerWidget->selectionModel()->clearSelection();
1336 ui->banlistWidget->setVisible(visible);
1337 ui->banHeading->setVisible(visible);
1342 ui->tabWidget->setCurrentIndex(
int(tabType));
1347 return ui->tabWidget->tabText(
int(tab_type));
1364 this->
ui->label_alerts->setVisible(!warnings.isEmpty());
1365 this->
ui->label_alerts->setText(warnings);
1373 const QString chainType = QString::fromStdString(
Params().GetChainTypeString());
1374 const QString title = tr(
"Node window - [%1]").arg(chainType);
1375 this->setWindowTitle(title);
const CChainParams & Params()
Return the currently selected parameters.
Qt model providing information about banned peers, similar to the "getpeerinfo" RPC call.
bool unban(const QModelIndex &index)
ChainType GetChainType() const
Return the chain type.
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.
std::map< CNetAddr, LocalServiceInfo > getNetLocalAddresses() const
PeerTableModel * getPeerTableModel()
PeerTableSortProxy * peerTableSortProxy()
void numConnectionsChanged(int count)
QString formatClientStartupTime() const
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
BanTableModel * getBanTableModel()
void numBlocksChanged(int count, const QDateTime &blockDate, double nVerificationProgress, SyncType header, SynchronizationState sync_state)
void alertsChanged(const QString &warnings)
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes, size_t mempoolMaxSizeInBytes)
QString formatFullVersion() const
QString formatSubVersion() const
void networkActiveChanged(bool networkActive)
interfaces::Node & node() const
static std::vector< std::string > ToStrings(NetPermissionFlags flags)
QString displayText(const QVariant &value, const QLocale &locale) const override
PeerIdViewDelegate(QObject *parent=nullptr)
Local Bitcoin RPC console.
static bool RPCExecuteCommandLine(interfaces::Node &node, std::string &strResult, const std::string &strCommand, std::string *const pstrFilteredOut=nullptr, const QString &wallet_name={})
QMenu * peersTableContextMenu
RPCConsole(interfaces::Node &node, const PlatformStyle *platformStyle, QWidget *parent)
struct RPCConsole::TranslatedStrings ts
void browseHistory(int offset)
Go forward or back in history.
static bool RPCParseCommandLine(interfaces::Node *node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string *const pstrFilteredOut=nullptr, const QString &wallet_name={})
Split shell command line into a list of arguments and optionally execute the command(s).
QByteArray m_banlist_widget_header_state
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)
const PlatformStyle *const platformStyle
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 updateDetailWidget()
show detailed information on ui about selected node
void showEvent(QShowEvent *event) override
void resizeEvent(QResizeEvent *event) override
QString tabTitle(TabTypes tab_type) const
void updateNetworkState()
Update UI with latest network info from model.
void clear(bool keep_prompt=false)
void disconnectSelectedNode()
Disconnect a selected node on the Peers tab.
@ SUBVERSION_COLUMN_WIDTH
QCompleter * autoCompleter
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 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)
QByteArray m_peer_widget_header_state
void changeEvent(QEvent *e) override
WalletModel * m_last_wallet_model
void showOrHideBanTableIfRequired()
Hides ban table if no bans are present.
QMenu * banTableContextMenu
void reply(int category, const QString &command)
RPCExecutor(interfaces::Node &node)
interfaces::Node & m_node
void request(const QString &command, const QString &wallet_name)
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 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 bool getNetworkActive()=0
Get network active.
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.
std::string TransportTypeAsString(TransportProtocolType transport_type)
Convert TransportProtocolType enum to a string value.
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.
QFont fixedPitchFont(bool use_embedded_font)
QString formatBytes(uint64_t bytes)
QString formatDurationStr(std::chrono::seconds dur)
Convert seconds into a QString with days, hours, mins, secs.
void AddButtonShortcut(QAbstractButton *button, const QKeySequence &shortcut)
Connects an additional shortcut to a QAbstractButton.
void handleCloseWindowShortcut(QWidget *w)
void copyEntryData(const QAbstractItemView *view, int column, int role)
Copy a field of the currently selected entry of a view to the clipboard.
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 ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction)
Convert enum ConnectionType to QString.
QString formatServicesStr(quint64 mask)
Format CNodeStats.nServices bitmask into a user-readable string.
QString formatTimeOffset(int64_t time_offset)
Format a CNodeStateStats.time_offset into a user-readable string.
bool IsEscapeOrBack(int key)
void ThreadRename(const std::string &)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name.
auto Join(const C &container, const S &separator, UnaryOp unary_op)
Join all container items.
const std::vector< std::string > CONNECTION_TYPE_DOC
const std::vector< std::string > TRANSPORT_TYPE_DOC
const int INITIAL_TRAFFIC_GRAPH_MINS
const struct @8 ICON_MAPPING[]
const QSize FONT_RANGE(4, 40)
const int CONSOLE_HISTORY
static QString categoryClass(int category)
const char fontSizeSettingsKey[]