PRCYCoin  2.0.0.7rc1
P2P Digital Currency
rpcconsole.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 The Bitcoin developers
2 // Copyright (c) 2014-2015 The Dash developers
3 // Copyright (c) 2015-2018 The PIVX developers
4 // Copyright (c) 2018-2020 The DAPS Project developers
5 // Distributed under the MIT/X11 software license, see the accompanying
6 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
7 
8 #include "rpcconsole.h"
9 #include "ui_rpcconsole.h"
10 #include "bantablemodel.h"
11 #include "clientmodel.h"
12 #include "guiutil.h"
13 #include "peertablemodel.h"
14 
15 #include "chainparams.h"
16 #include "netbase.h"
17 #include "rpc/client.h"
18 #include "rpc/server.h"
19 #include "util.h"
20 #ifdef ENABLE_WALLET
21 #include "wallet/wallet.h"
22 #endif // ENABLE_WALLET
23 
24 #include <univalue.h>
25 
26 #include <openssl/crypto.h>
27 
28 #ifdef ENABLE_WALLET
29 #include <db_cxx.h>
30 #endif
31 
32 #include <QDir>
33 #include <QKeyEvent>
34 #include <QMenu>
35 #include <QScrollBar>
36 #include <QSignalMapper>
37 #include <QThread>
38 #include <QTime>
39 #include <QTimer>
40 #include <QStringList>
41 
42 // TODO: add a scrollback limit, as there is currently none
43 // TODO: make it possible to filter out categories (esp debug messages when implemented)
44 // TODO: receive errors and debug messages through ClientModel
45 
46 const int CONSOLE_HISTORY = 50;
47 const QSize ICON_SIZE(24, 24);
48 
50 
51 // Repair parameters
52 const QString SALVAGEWALLET("-salvagewallet");
53 const QString RESCAN("-rescan");
54 const QString ZAPTXES1("-zapwallettxes=1");
55 const QString ZAPTXES2("-zapwallettxes=2");
56 const QString UPGRADEWALLET("-upgradewallet");
57 const QString REINDEX("-reindex");
58 const QString RESYNC("-resync");
59 
60 const struct {
61  const char* url;
62  const char* source;
63 } ICON_MAPPING[] = {
64  {"cmd-request", ":/icons/tx_input"},
65  {"cmd-reply", ":/icons/tx_output"},
66  {"cmd-error", ":/icons/tx_output"},
67  {"misc", ":/icons/tx_inout"},
68  {NULL, NULL}};
69 
70 /* Object for executing console RPC commands in a separate thread.
71 */
72 class RPCExecutor : public QObject
73 {
74  Q_OBJECT
75 
76 public Q_SLOTS:
77  void request(const QString& command);
78 
79 Q_SIGNALS:
80  void reply(int category, const QString& command);
81 };
82 
83 
87 class QtRPCTimerBase: public QObject, public RPCTimerBase
88 {
89  Q_OBJECT
90 public:
91  QtRPCTimerBase(boost::function<void(void)>& func, int64_t millis):
92  func(func)
93  {
94  timer.setSingleShot(true);
95  connect(&timer, SIGNAL(timeout()), this, SLOT(timeout()));
96  timer.start(millis);
97  }
99 private Q_SLOTS:
100  void timeout() { func(); }
101 private:
102  QTimer timer;
103  boost::function<void(void)> func;
104 };
105 
107 {
108 public:
110  const char *Name() { return "Qt"; }
111  RPCTimerBase* NewTimer(boost::function<void(void)>& func, int64_t millis)
112  {
113  return new QtRPCTimerBase(func, millis);
114  }
115 };
116 
117 #include "rpcconsole.moc"
118 
133 bool parseCommandLine(std::vector<std::string>& args, const std::string& strCommand)
134 {
135  enum CmdParseState {
136  STATE_EATING_SPACES,
137  STATE_ARGUMENT,
138  STATE_SINGLEQUOTED,
139  STATE_DOUBLEQUOTED,
140  STATE_ESCAPE_OUTER,
141  STATE_ESCAPE_DOUBLEQUOTED
142  } state = STATE_EATING_SPACES;
143  std::string curarg;
144  Q_FOREACH (char ch, strCommand) {
145  switch (state) {
146  case STATE_ARGUMENT: // In or after argument
147  case STATE_EATING_SPACES: // Handle runs of whitespace
148  switch (ch) {
149  case '"':
150  state = STATE_DOUBLEQUOTED;
151  break;
152  case '\'':
153  state = STATE_SINGLEQUOTED;
154  break;
155  case '\\':
156  state = STATE_ESCAPE_OUTER;
157  break;
158  case ' ':
159  case '\n':
160  case '\t':
161  if (state == STATE_ARGUMENT) // Space ends argument
162  {
163  args.push_back(curarg);
164  curarg.clear();
165  }
166  state = STATE_EATING_SPACES;
167  break;
168  default:
169  curarg += ch;
170  state = STATE_ARGUMENT;
171  }
172  break;
173  case STATE_SINGLEQUOTED: // Single-quoted string
174  switch (ch) {
175  case '\'':
176  state = STATE_ARGUMENT;
177  break;
178  default:
179  curarg += ch;
180  }
181  break;
182  case STATE_DOUBLEQUOTED: // Double-quoted string
183  switch (ch) {
184  case '"':
185  state = STATE_ARGUMENT;
186  break;
187  case '\\':
188  state = STATE_ESCAPE_DOUBLEQUOTED;
189  break;
190  default:
191  curarg += ch;
192  }
193  break;
194  case STATE_ESCAPE_OUTER: // '\' outside quotes
195  curarg += ch;
196  state = STATE_ARGUMENT;
197  break;
198  case STATE_ESCAPE_DOUBLEQUOTED: // '\' in double-quoted text
199  if (ch != '"' && ch != '\\') curarg += '\\'; // keep '\' for everything but the quote and '\' itself
200  curarg += ch;
201  state = STATE_DOUBLEQUOTED;
202  break;
203  }
204  }
205  switch (state) // final state
206  {
207  case STATE_EATING_SPACES:
208  return true;
209  case STATE_ARGUMENT:
210  args.push_back(curarg);
211  return true;
212  default: // ERROR to end in one of the other states
213  return false;
214  }
215 }
216 
217 void RPCExecutor::request(const QString& command)
218 {
219  std::vector<std::string> args;
220  if (!parseCommandLine(args, command.toStdString())) {
221  Q_EMIT reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \""));
222  return;
223  }
224  if (args.empty())
225  return; // Nothing to do
226  try {
227  std::string strPrint;
228  // Convert argument list to JSON objects in method-dependent way,
229  // and pass it along with the method name to the dispatcher.
230  UniValue result = tableRPC.execute(
231  args[0],
232  RPCConvertValues(args[0], std::vector<std::string>(args.begin() + 1, args.end())));
233 
234  // Format result reply
235  if (result.isNull())
236  strPrint = "";
237  else if (result.isStr())
238  strPrint = result.get_str();
239  else
240  strPrint = result.write(2);
241 
242  Q_EMIT reply(RPCConsole::CMD_REPLY, QString::fromStdString(strPrint));
243  } catch (const UniValue& objError) {
244  try // Nice formatting for standard-format error
245  {
246  int code = find_value(objError, "code").get_int();
247  std::string message = find_value(objError, "message").get_str();
248  Q_EMIT reply(RPCConsole::CMD_ERROR, QString::fromStdString(message) + " (code " + QString::number(code) + ")");
249  } catch (const std::runtime_error&) // raised when converting to invalid type, i.e. missing code or message
250  { // Show raw JSON object
251  Q_EMIT reply(RPCConsole::CMD_ERROR, QString::fromStdString(objError.write()));
252  }
253  } catch (const std::exception& e) {
254  Q_EMIT reply(RPCConsole::CMD_ERROR, QString("Error: ") + QString::fromStdString(e.what()));
255  }
256 }
257 
258 RPCConsole::RPCConsole(QWidget* parent) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint),
259  ui(new Ui::RPCConsole),
260  clientModel(0),
261  historyPtr(0),
262  cachedNodeid(-1),
263  peersTableContextMenu(0),
264  banTableContextMenu(0)
265 {
266  ui->setupUi(this);
267  GUIUtil::restoreWindowGeometry("nRPCConsoleWindow", this->size(), this);
268 
269 #ifndef Q_OS_MAC
270  ui->openDebugLogfileButton->setIcon(QIcon(":/icons/export"));
271 #endif
272 
273  // Install event filter for up and down arrow
274  ui->lineEdit->installEventFilter(this);
275  ui->messagesWidget->installEventFilter(this);
276 
277  connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear()));
278  connect(ui->btnClearTrafficGraph, SIGNAL(clicked()), ui->trafficGraph, SLOT(clear()));
279 
280  // Wallet Repair Buttons
281  connect(ui->btn_salvagewallet, SIGNAL(clicked()), this, SLOT(walletSalvage()));
282  connect(ui->btn_rescan, SIGNAL(clicked()), this, SLOT(walletRescan()));
283  connect(ui->btn_zapwallettxes1, SIGNAL(clicked()), this, SLOT(walletZaptxes1()));
284  connect(ui->btn_zapwallettxes2, SIGNAL(clicked()), this, SLOT(walletZaptxes2()));
285  connect(ui->btn_upgradewallet, SIGNAL(clicked()), this, SLOT(walletUpgrade()));
286  connect(ui->btn_reindex, SIGNAL(clicked()), this, SLOT(walletReindex()));
287  connect(ui->btn_resync, SIGNAL(clicked()), this, SLOT(walletResync()));
288 
289  // set library version labels
290  ui->openSSLVersion->setText(SSLeay_version(SSLEAY_VERSION));
291 #ifdef ENABLE_WALLET
292  std::string strPathCustom = GetArg("-backuppath", "");
293  int nCustomBackupThreshold = GetArg("-custombackupthreshold", DEFAULT_CUSTOMBACKUPTHRESHOLD);
294 
295  if(!strPathCustom.empty()) {
296  ui->wallet_custombackuppath->setText(QString::fromStdString(strPathCustom));
297  ui->wallet_custombackuppath_label->show();
298  ui->wallet_custombackuppath->show();
299  }
300 
301  if(!strPathCustom.empty() && nCustomBackupThreshold > 0) {
302  ui->wallet_custombackupthreshold->setText(QString::fromStdString(std::to_string(nCustomBackupThreshold)));
303  ui->wallet_custombackupthreshold_label->setVisible(true);
304  ui->wallet_custombackupthreshold->setVisible(true);
305  }
306 
307  ui->berkeleyDBVersion->setText(DbEnv::version(0, 0, 0));
308  ui->wallet_path->setText(QString::fromStdString(GetDataDir().string() + QDir::separator().toLatin1() + GetArg("-wallet", "wallet.dat")));
309 #else
310  ui->label_berkeleyDBVersion->hide();
311  ui->berkeleyDBVersion->hide();
312 #endif
313  // Register RPC timer interface
315  // avoid accidentally overwriting an existing, non QTThread
316  // based timer interface
318 
319  startExecutor();
321 
322  ui->peerHeading->setText(tr("Select a peer to view detailed information."));
323 
324  clear();
325 }
326 
328 {
329  GUIUtil::saveWindowGeometry("nRPCConsoleWindow", this);
330  Q_EMIT stopExecutor();
331  delete peersTableContextMenu;
332  delete banTableContextMenu;
334  delete rpcTimerInterface;
335  delete ui;
336 }
337 
338 bool RPCConsole::eventFilter(QObject* obj, QEvent* event)
339 {
340  if (event->type() == QEvent::KeyPress) // Special key handling
341  {
342  QKeyEvent* keyevt = static_cast<QKeyEvent*>(event);
343  int key = keyevt->key();
344  Qt::KeyboardModifiers mod = keyevt->modifiers();
345  switch (key) {
346  case Qt::Key_Up:
347  if (obj == ui->lineEdit) {
348  browseHistory(-1);
349  return true;
350  }
351  break;
352  case Qt::Key_Down:
353  if (obj == ui->lineEdit) {
354  browseHistory(1);
355  return true;
356  }
357  break;
358  case Qt::Key_PageUp: /* pass paging keys to messages widget */
359  case Qt::Key_PageDown:
360  if (obj == ui->lineEdit) {
361  QApplication::postEvent(ui->messagesWidget, new QKeyEvent(*keyevt));
362  return true;
363  }
364  break;
365  case Qt::Key_Return:
366  case Qt::Key_Enter:
367  // forward these events to lineEdit
368  if(obj == autoCompleter->popup()) {
369  QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
370  return true;
371  }
372  break;
373  default:
374  // Typing in messages widget brings focus to line edit, and redirects key there
375  // Exclude most combinations and keys that Q_EMIT no text, except paste shortcuts
376  if (obj == ui->messagesWidget && ((!mod && !keyevt->text().isEmpty() && key != Qt::Key_Tab) ||
377  ((mod & Qt::ControlModifier) && key == Qt::Key_V) ||
378  ((mod & Qt::ShiftModifier) && key == Qt::Key_Insert))) {
379  ui->lineEdit->setFocus();
380  QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
381  return true;
382  }
383  }
384  }
385  return QDialog::eventFilter(obj, event);
386 }
387 
389 {
390  clientModel = model;
391  ui->trafficGraph->setClientModel(model);
393  // Keep up to date with client
395  connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
396 
397  setNumBlocks(model->getNumBlocks());
398  connect(model, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int)));
399 
401  connect(model, SIGNAL(strMasternodesChanged(QString)), this, SLOT(setMasternodeCount(QString)));
402 
404  connect(model, SIGNAL(bytesChanged(quint64, quint64)), this, SLOT(updateTrafficStats(quint64, quint64)));
405 
406  // set up peer table
407  ui->peerWidget->setModel(model->getPeerTableModel());
408  ui->peerWidget->verticalHeader()->hide();
409  ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
410  ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
411  ui->peerWidget->setSelectionMode(QAbstractItemView::SingleSelection);
412  ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu);
413  ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH);
414  ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH);
415  ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_COLUMN_WIDTH);
416  ui->peerWidget->horizontalHeader()->setStretchLastSection(true);
417 
418  // create peer table context menu actions
419  QAction* disconnectAction = new QAction(tr("&Disconnect Node"), this);
420  QAction* banAction1h = new QAction(tr("Ban Node for") + " " + tr("1 &hour"), this);
421  QAction* banAction24h = new QAction(tr("Ban Node for") + " " + tr("1 &day"), this);
422  QAction* banAction7d = new QAction(tr("Ban Node for") + " " + tr("1 &week"), this);
423  QAction* banAction365d = new QAction(tr("Ban Node for") + " " + tr("1 &year"), this);
424 
425  // create peer table context menu
426  peersTableContextMenu = new QMenu();
427  peersTableContextMenu->addAction(disconnectAction);
428  peersTableContextMenu->addAction(banAction1h);
429  peersTableContextMenu->addAction(banAction24h);
430  peersTableContextMenu->addAction(banAction7d);
431  peersTableContextMenu->addAction(banAction365d);
432 
433  // Add a signal mapping to allow dynamic context menu arguments.
434  // We need to use int (instead of int64_t), because signal mapper only supports
435  // int or objects, which is okay because max bantime (1 year) is < int_max.
436  QSignalMapper* signalMapper = new QSignalMapper(this);
437  signalMapper->setMapping(banAction1h, 60*60);
438  signalMapper->setMapping(banAction24h, 60*60*24);
439  signalMapper->setMapping(banAction7d, 60*60*24*7);
440  signalMapper->setMapping(banAction365d, 60*60*24*365);
441 
442  connect(banAction1h, SIGNAL(triggered()), signalMapper, SLOT(map()));
443  connect(banAction24h, SIGNAL(triggered()), signalMapper, SLOT(map()));
444  connect(banAction7d, SIGNAL(triggered()), signalMapper, SLOT(map()));
445  connect(banAction365d, SIGNAL(triggered()), signalMapper, SLOT(map()));
446  connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(banSelectedNode(int)));
447 
448  // peer table context menu signals
449  connect(ui->peerWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showPeersTableContextMenu(const QPoint&)));
450  connect(disconnectAction, SIGNAL(triggered()), this, SLOT(disconnectSelectedNode()));
451 
452  // peer table signal handling - update peer details when selecting new node
453  connect(ui->peerWidget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
454  this, SLOT(peerSelected(const QItemSelection &, const QItemSelection &)));
455  // peer table signal handling - update peer details when new nodes are added to the model
456  connect(model->getPeerTableModel(), SIGNAL(layoutChanged()), this, SLOT(peerLayoutChanged()));
457 
458  // set up ban table
459  ui->banlistWidget->setModel(model->getBanTableModel());
460  ui->banlistWidget->verticalHeader()->hide();
461  ui->banlistWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
462  ui->banlistWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
463  ui->banlistWidget->setSelectionMode(QAbstractItemView::SingleSelection);
464  ui->banlistWidget->setContextMenuPolicy(Qt::CustomContextMenu);
465  ui->banlistWidget->setColumnWidth(BanTableModel::Address, BANSUBNET_COLUMN_WIDTH);
466  ui->banlistWidget->setColumnWidth(BanTableModel::Bantime, BANTIME_COLUMN_WIDTH);
467  ui->banlistWidget->horizontalHeader()->setStretchLastSection(true);
468 
469  // create ban table context menu action
470  QAction* unbanAction = new QAction(tr("&Unban Node"), this);
471 
472  // create ban table context menu
473  banTableContextMenu = new QMenu();
474  banTableContextMenu->addAction(unbanAction);
475 
476  // ban table context menu signals
477  connect(ui->banlistWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showBanTableContextMenu(const QPoint&)));
478  connect(unbanAction, SIGNAL(triggered()), this, SLOT(unbanSelectedNode()));
479 
480  // ban table signal handling - clear peer details when clicking a peer in the ban table
481  connect(ui->banlistWidget, SIGNAL(clicked(const QModelIndex&)), this, SLOT(clearSelectedNode()));
482 
483  // ban table signal handling - ensure ban table is shown or hidden (if empty)
484  connect(model->getBanTableModel(), SIGNAL(layoutChanged()), this, SLOT(showOrHideBanTableIfRequired()));
486 
487  // Provide initial values
488  ui->clientVersion->setText(model->formatFullVersion());
489  ui->clientName->setText(model->clientName());
490  ui->dataDir->setText(model->dataDir());
491  ui->startupTime->setText(model->formatClientStartupTime());
492  ui->networkName->setText(QString::fromStdString(Params().NetworkIDString()));
493 
494  //Setup autocomplete and attach it
495  QStringList wordList;
496  std::vector<std::string> commandList = tableRPC.listCommands();
497  for (size_t i = 0; i < commandList.size(); ++i)
498  {
499  wordList << commandList[i].c_str();
500  }
501 
502  autoCompleter = new QCompleter(wordList, this);
503  ui->lineEdit->setCompleter(autoCompleter);
504 
505  // clear the lineEdit after activating from QCompleter
506  autoCompleter->popup()->installEventFilter(this);
507  }
508 }
509 
510 static QString categoryClass(int category)
511 {
512  switch (category) {
514  return "cmd-request";
515  break;
517  return "cmd-reply";
518  break;
520  return "cmd-error";
521  break;
522  default:
523  return "misc";
524  }
525 }
526 
529 {
531 }
532 
535 {
537 }
538 
541 {
543 }
544 
547 {
549 }
550 
553 {
555 }
556 
559 {
561 }
562 
565 {
566  QString resyncWarning = tr("This will delete your local blockchain folders and the wallet will synchronize the complete Blockchain from scratch.<br /><br />");
567  resyncWarning += tr("This needs quite some time and downloads a lot of data.<br /><br />");
568  resyncWarning += tr("Your transactions and funds will be visible again after the download has completed.<br /><br />");
569  resyncWarning += tr("Do you want to continue?.<br />");
570  QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm resync Blockchain"),
571  resyncWarning,
572  QMessageBox::Yes | QMessageBox::Cancel,
573  QMessageBox::Cancel);
574 
575  if (retval != QMessageBox::Yes) {
576  // Resync canceled
577  return;
578  }
579 
580  // Restart and resync
582 }
583 
586 {
587  // Get command-line arguments and remove the application name
588  QStringList args = QApplication::arguments();
589  args.removeFirst();
590 
591  // Remove existing repair-options
592  args.removeAll(SALVAGEWALLET);
593  args.removeAll(RESCAN);
594  args.removeAll(ZAPTXES1);
595  args.removeAll(ZAPTXES2);
596  args.removeAll(UPGRADEWALLET);
597  args.removeAll(REINDEX);
598 
599  // Append repair parameter to command line.
600  args.append(arg);
601 
602  // Send command-line arguments to BitcoinGUI::handleRestart()
603  Q_EMIT handleRestart(args);
604 }
605 
607 {
608  ui->messagesWidget->clear();
609  history.clear();
610  historyPtr = 0;
611  ui->lineEdit->clear();
612  ui->lineEdit->setFocus();
613 
614  // Add smoothly scaled icon images.
615  // (when using width/height on an img, Qt uses nearest instead of linear interpolation)
616  for (int i = 0; ICON_MAPPING[i].url; ++i) {
617  ui->messagesWidget->document()->addResource(
618  QTextDocument::ImageResource,
619  QUrl(ICON_MAPPING[i].url),
620  QImage(ICON_MAPPING[i].source).scaled(ICON_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
621  }
622 
623  // Set default style sheet
624  ui->messagesWidget->document()->setDefaultStyleSheet(
625  "table { }"
626  "td.time { color: #808080; padding-top: 3px; } "
627  "td.message { font-family: Courier, Courier New, Lucida Console, monospace; font-size: 12px; } " // Todo: Remove fixed font-size
628  "td.cmd-request { color: #006060; } "
629  "td.cmd-error { color: red; } "
630  ".secwarning { color: red; }"
631  "b { color: #006060; } ");
632 
633 #ifdef Q_OS_MAC
634  QString clsKey = "(⌘)-L";
635 #else
636  QString clsKey = "Ctrl-L";
637 #endif
638 
639  message(CMD_REPLY, (tr("Welcome to the PRCY RPC console.") + "<br>" +
640  tr("Use up and down arrows to navigate history, and %1 to clear screen.").arg("<b>"+clsKey+"</b>") + "<br>" +
641  tr("Type <b>help</b> for an overview of available commands.") +
642  "<br><span class=\"secwarning\"><br>" +
643  tr("WARNING: Scammers have been active, telling users to type commands here, stealing their wallet contents. Do not use this console without fully understanding the ramifications of a command.") +
644  "</span>"),
645  true);
646 }
647 
649 {
650  // Ignore escape keypress if this is not a seperate window
651  if (windowType() != Qt::Widget)
652  QDialog::reject();
653 }
654 
655 void RPCConsole::message(int category, const QString& message, bool html)
656 {
657  QTime time = QTime::currentTime();
658  QString timeString = time.toString();
659  QString out;
660  out += "<table><tr><td class=\"time\" width=\"65\">" + timeString + "</td>";
661  out += "<td class=\"icon\" width=\"32\"><img src=\"" + categoryClass(category) + "\"></td>";
662  out += "<td class=\"message " + categoryClass(category) + "\" valign=\"middle\">";
663  if (html)
664  out += message;
665  else
666  out += GUIUtil::HtmlEscape(message, true);
667  out += "</td></tr></table>";
668  ui->messagesWidget->append(out);
669 }
670 
672 {
673  if (!clientModel)
674  return;
675 
676  QString connections = QString::number(count) + " (";
677  connections += tr("In:") + " " + QString::number(clientModel->getNumConnections(CONNECTIONS_IN)) + " / ";
678  connections += tr("Out:") + " " + QString::number(clientModel->getNumConnections(CONNECTIONS_OUT)) + ")";
679 
680  ui->numberOfConnections->setText(connections);
681 }
682 
684 {
685  ui->numberOfBlocks->setText(QString::number(count));
686  if (clientModel) {
687  ui->lastBlockTime->setText(clientModel->getLastBlockDate().toString());
688  ui->lastBlockHash->setText(clientModel->getLastBlockHash());
689  }
690 }
691 
692 void RPCConsole::setMasternodeCount(const QString& strMasternodes)
693 {
694  ui->masternodeCount->setText(strMasternodes);
695 }
696 
698 {
699  QString cmd = ui->lineEdit->text();
700  ui->lineEdit->clear();
701 
702  if (!cmd.isEmpty()) {
703  message(CMD_REQUEST, cmd);
704  Q_EMIT cmdRequest(cmd);
705  // Remove command, if already in history
706  history.removeOne(cmd);
707  // Append command to history
708  history.append(cmd);
709  // Enforce maximum history size
710  while (history.size() > CONSOLE_HISTORY)
711  history.removeFirst();
712  // Set pointer to end of history
713  historyPtr = history.size();
714  // Scroll console view to end
715  scrollToEnd();
716  }
717 }
718 
720 {
721  historyPtr += offset;
722  if (historyPtr < 0)
723  historyPtr = 0;
724  if (historyPtr > history.size())
725  historyPtr = history.size();
726  QString cmd;
727  if (historyPtr < history.size())
728  cmd = history.at(historyPtr);
729  ui->lineEdit->setText(cmd);
730 }
731 
733 {
734  QThread* thread = new QThread;
735  RPCExecutor* executor = new RPCExecutor();
736  executor->moveToThread(thread);
737 
738  // Replies from executor object must go to this object
739  connect(executor, SIGNAL(reply(int, QString)), this, SLOT(message(int, QString)));
740  // Requests from this object must go to executor
741  connect(this, SIGNAL(cmdRequest(QString)), executor, SLOT(request(QString)));
742 
743  // On stopExecutor signal
744  // - queue executor for deletion (in execution thread)
745  // - quit the Qt event loop in the execution thread
746  connect(this, SIGNAL(stopExecutor()), executor, SLOT(deleteLater()));
747  connect(this, SIGNAL(stopExecutor()), thread, SLOT(quit()));
748  // Queue the thread for deletion (in this thread) when it is finished
749  connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
750 
751  // Default implementation of QThread::run() simply spins up an event loop in the thread,
752  // which is what we want.
753  thread->start();
754 }
755 
757 {
758  if (ui->tabWidget->widget(index) == ui->tab_console) {
759  ui->lineEdit->setFocus();
760  } else if (ui->tabWidget->widget(index) != ui->tab_peers) {
762  }
763 }
764 
766 {
768 }
769 
771 {
772  QScrollBar* scrollbar = ui->messagesWidget->verticalScrollBar();
773  scrollbar->setValue(scrollbar->maximum());
774 }
775 
777 {
778  const int multiplier = 5; // each position on the slider represents 5 min
779  int mins = value * multiplier;
780  setTrafficGraphRange(mins);
781 }
782 
784 {
785  ui->trafficGraph->setGraphRangeMins(mins);
786  ui->lblGraphRange->setText(GUIUtil::formatDurationStr(mins * 60));
787 }
788 
789 void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
790 {
791  ui->lblBytesIn->setText(GUIUtil::formatBytes(totalBytesIn));
792  ui->lblBytesOut->setText(GUIUtil::formatBytes(totalBytesOut));
793 }
794 
796 {
797  ui->tabWidget->setCurrentIndex(0);
798  show();
799 }
800 
802 {
803  ui->tabWidget->setCurrentIndex(1);
804  show();
805 }
806 
808 {
809  ui->tabWidget->setCurrentIndex(2);
810  show();
811 }
812 
814 {
815  ui->tabWidget->setCurrentIndex(3);
816  show();
817 }
818 
820 {
821  ui->tabWidget->setCurrentIndex(4);
822  show();
823 }
824 
826 {
828 }
829 
831 {
833 }
834 
835 void RPCConsole::peerSelected(const QItemSelection& selected, const QItemSelection& deselected)
836 {
837  Q_UNUSED(deselected);
838 
839  if (!clientModel || !clientModel->getPeerTableModel() || selected.indexes().isEmpty())
840  return;
841 
842  const CNodeCombinedStats* stats = clientModel->getPeerTableModel()->getNodeStats(selected.indexes().first().row());
843  if (stats)
844  updateNodeDetail(stats);
845 }
846 
848 {
850  return;
851 
852  const CNodeCombinedStats* stats = NULL;
853  bool fUnselect = false;
854  bool fReselect = false;
855 
856  if (cachedNodeid == -1) // no node selected yet
857  return;
858 
859  // find the currently selected row
860  int selectedRow = -1;
861  QModelIndexList selectedModelIndex = ui->peerWidget->selectionModel()->selectedIndexes();
862 
863  if (!selectedModelIndex.isEmpty()) {
864  selectedRow = selectedModelIndex.first().row();
865  }
866 
867  // check if our detail node has a row in the table (it may not necessarily
868  // be at selectedRow since its position can change after a layout change)
869  int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid);
870 
871  if (detailNodeRow < 0) {
872  // detail node dissapeared from table (node disconnected)
873  fUnselect = true;
874  } else {
875  if (detailNodeRow != selectedRow) {
876  // detail node moved position
877  fUnselect = true;
878  fReselect = true;
879  }
880 
881  // get fresh stats on the detail node.
882  stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
883  }
884 
885  if (fUnselect && selectedRow >= 0) {
887  }
888 
889  if (fReselect) {
890  ui->peerWidget->selectRow(detailNodeRow);
891  }
892 
893  if (stats)
894  updateNodeDetail(stats);
895 }
896 
898 {
899  // Update cached nodeid
900  cachedNodeid = stats->nodeStats.nodeid;
901 
902  // update the detail ui with latest node information
903  QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName) + " ");
904  peerAddrDetails += tr("(node id: %1)").arg(QString::number(stats->nodeStats.nodeid));
905  if (!stats->nodeStats.addrLocal.empty())
906  peerAddrDetails += "<br />" + tr("via %1").arg(QString::fromStdString(stats->nodeStats.addrLocal));
907  ui->peerHeading->setText(peerAddrDetails);
908  ui->peerServices->setText(GUIUtil::formatServicesStr(stats->nodeStats.nServices));
909  ui->peerLastSend->setText(stats->nodeStats.nLastSend ? GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nLastSend) : tr("never"));
910  ui->peerLastRecv->setText(stats->nodeStats.nLastRecv ? GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nLastRecv) : tr("never"));
911  ui->peerBytesSent->setText(GUIUtil::formatBytes(stats->nodeStats.nSendBytes));
912  ui->peerBytesRecv->setText(GUIUtil::formatBytes(stats->nodeStats.nRecvBytes));
913  ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nTimeConnected));
914  ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingTime));
915  ui->peerPingWait->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingWait));
916  ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));
917  ui->peerVersion->setText(QString("%1").arg(QString::number(stats->nodeStats.nVersion)));
918  ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));
919  ui->peerDirection->setText(stats->nodeStats.fInbound ? tr("Inbound") : tr("Outbound"));
920  ui->peerHeight->setText(QString("%1").arg(QString::number(stats->nodeStats.nStartingHeight)));
921  ui->peerWhitelisted->setText(stats->nodeStats.fWhitelisted ? tr("Yes") : tr("No"));
922 
923  // This check fails for example if the lock was busy and
924  // nodeStateStats couldn't be fetched.
925  if (stats->fNodeStateStatsAvailable) {
926  // Ban score is init to 0
927  ui->peerBanScore->setText(QString("%1").arg(stats->nodeStateStats.nMisbehavior));
928 
929  // Sync height is init to -1
930  if (stats->nodeStateStats.nSyncHeight > -1)
931  ui->peerSyncHeight->setText(QString("%1").arg(stats->nodeStateStats.nSyncHeight));
932  else
933  ui->peerSyncHeight->setText(tr("Unknown"));
934 
935  // Common height is init to -1
936  if (stats->nodeStateStats.nCommonHeight > -1)
937  ui->peerCommonHeight->setText(QString("%1").arg(stats->nodeStateStats.nCommonHeight));
938  else
939  ui->peerCommonHeight->setText(tr("Unknown"));
940  }
941 
942  ui->detailWidget->show();
943 }
944 
945 void RPCConsole::resizeEvent(QResizeEvent* event)
946 {
947  QWidget::resizeEvent(event);
948 }
949 
950 void RPCConsole::showEvent(QShowEvent* event)
951 {
952  QWidget::showEvent(event);
953 
955  return;
956 
957  // start PeerTableModel auto refresh
960 }
961 
962 void RPCConsole::hideEvent(QHideEvent* event)
963 {
964  QWidget::hideEvent(event);
965 
967  return;
968 
969  // stop PeerTableModel auto refresh
972 }
973 
975 {
977 }
978 
980 {
982 }
983 
985 {
987 }
988 
989 void RPCConsole::showPeersTableContextMenu(const QPoint& point)
990 {
991  QModelIndex index = ui->peerWidget->indexAt(point);
992  if (index.isValid())
993  peersTableContextMenu->exec(QCursor::pos());
994 }
995 
996 void RPCConsole::showBanTableContextMenu(const QPoint& point)
997 {
998  QModelIndex index = ui->banlistWidget->indexAt(point);
999  if (index.isValid())
1000  banTableContextMenu->exec(QCursor::pos());
1001 }
1002 
1004 {
1005  if (!clientModel)
1006  return;
1007 
1008  if(cachedNodeid == -1)
1009  return;
1010 
1011  // Get currently selected peer address
1012  int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid);
1013  if(detailNodeRow < 0)
1014  return;
1015 
1016  const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
1017  // Find the node, disconnect it and clear the selected node
1018  if (CNode *bannedNode = FindNode(stats->nodeStats.addr.ToString())) {
1019  bannedNode->CloseSocketDisconnect();
1021  }
1022 }
1023 
1025 {
1026  if (!clientModel)
1027  return;
1028 
1029  if(cachedNodeid == -1)
1030  return;
1031 
1032  // Get currently selected peer address
1033  int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid);
1034  if(detailNodeRow < 0)
1035  return;
1036 
1037  // Find possible nodes, ban it and clear the selected node
1038  const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
1039 
1040  if (FindNode(stats->nodeStats.addr.ToString())) {
1041  std::string nStr = stats->nodeStats.addr.ToString();
1042  std::string addr;
1043  int port = 0;
1044  SplitHostPort(nStr, port, addr);
1045 
1046  CNetAddr resolved;
1047  if (!LookupHost(addr.c_str(), resolved, false))
1048  return;
1049  CNode::Ban(resolved, BanReasonManuallyAdded, bantime);
1050 
1053  }
1054 }
1055 
1057 {
1058  if (!clientModel)
1059  return;
1060  // Get currently selected ban address
1061  QString strNode = GUIUtil::getEntryData(ui->banlistWidget, 0, BanTableModel::Address).toString();
1062  CSubNet possibleSubnet;
1063 
1064  LookupSubNet(strNode.toStdString().c_str(), possibleSubnet);
1065  if (possibleSubnet.IsValid())
1066  {
1067  CNode::Unban(possibleSubnet);
1069  }
1070 }
1071 
1073 {
1074  ui->peerWidget->selectionModel()->clearSelection();
1075  cachedNodeid = -1;
1076  ui->detailWidget->hide();
1077  ui->peerHeading->setText(tr("Select a peer to view detailed information."));
1078 }
1079 
1081 {
1082  if (!clientModel)
1083  return;
1084  bool visible = clientModel->getBanTableModel()->shouldShow();
1085  ui->banlistWidget->setVisible(visible);
1086  ui->banHeading->setVisible(visible);
1087 }
RPCConsole::walletRescan
void walletRescan()
Restart wallet with "-rescan".
Definition: rpcconsole.cpp:534
CNodeStats::addrName
std::string addrName
Definition: net.h:189
RPCConsole::showNetwork
void showNetwork()
Switch to network tab and show.
Definition: rpcconsole.cpp:807
RPCConsole::buildParameterlist
void buildParameterlist(QString arg)
Build parameter list for restart.
Definition: rpcconsole.cpp:585
RPCConsole::eventFilter
virtual bool eventFilter(QObject *obj, QEvent *event)
Definition: rpcconsole.cpp:338
ClientModel::startMasternodesTimer
void startMasternodesTimer()
Definition: clientmodel.cpp:151
CONNECTIONS_IN
@ CONNECTIONS_IN
Definition: clientmodel.h:38
CNodeStats::fInbound
bool fInbound
Definition: net.h:192
CNodeStateStats::nCommonHeight
int nCommonHeight
Definition: main.h:291
BanReasonManuallyAdded
@ BanReasonManuallyAdded
Definition: net.h:248
LookupSubNet
bool LookupSubNet(const char *pszName, CSubNet &ret)
Definition: netbase.cpp:667
parseCommandLine
bool parseCommandLine(std::vector< std::string > &args, const std::string &strCommand)
Split shell command line into a list of arguments.
Definition: rpcconsole.cpp:133
ClientModel::getLastBlockHash
QString getLastBlockHash() const
Definition: clientmodel.cpp:115
RPCConsole::setNumConnections
void setNumConnections(int count)
Set number of connections shown in the UI.
Definition: rpcconsole.cpp:671
ICON_MAPPING
const struct @21 ICON_MAPPING[]
SplitHostPort
void SplitHostPort(std::string in, int &portOut, std::string &hostOut)
Definition: netbase.cpp:74
RPCConsole::ADDRESS_COLUMN_WIDTH
@ ADDRESS_COLUMN_WIDTH
Definition: rpcconsole.h:143
CONNECTIONS_OUT
@ CONNECTIONS_OUT
Definition: clientmodel.h:39
GUIUtil::openDebugLogfile
bool openDebugLogfile()
Definition: guiutil.cpp:359
GetTime
int64_t GetTime()
For unit testing.
Definition: utiltime.cpp:19
CNodeStats::addrLocal
std::string addrLocal
Definition: net.h:199
ICON_SIZE
const QSize ICON_SIZE(24, 24)
GUIUtil::openConfigfile
bool openConfigfile()
Definition: guiutil.cpp:364
QtRPCTimerBase
Class for handling RPC timers (used for e.g.
Definition: rpcconsole.cpp:87
GUIUtil::showDataDir
bool showDataDir()
Definition: guiutil.cpp:374
CNodeStats::nodeid
NodeId nodeid
Definition: net.h:183
ClientModel::getNumConnections
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:61
GUIUtil::openMNConfigfile
bool openMNConfigfile()
Definition: guiutil.cpp:369
CNodeCombinedStats::nodeStats
CNodeStats nodeStats
Definition: peertablemodel.h:22
RPCConsole::setNumBlocks
void setNumBlocks(int count)
Set number of blocks shown in the UI.
Definition: rpcconsole.cpp:683
RPCConsole::startExecutor
void startExecutor()
Definition: rpcconsole.cpp:732
CNodeStats::nVersion
int nVersion
Definition: net.h:190
RPCConsole::walletReindex
void walletReindex()
Restart wallet with "-reindex".
Definition: rpcconsole.cpp:558
RPCTimerInterface
RPC timer "driver".
Definition: server.h:88
QtRPCTimerInterface::Name
const char * Name()
Implementation name.
Definition: rpcconsole.cpp:110
RPCUnsetTimerInterface
void RPCUnsetTimerInterface(RPCTimerInterface *iface)
Unset factory function for timers.
Definition: server.cpp:622
RPCConsole::showPeers
void showPeers()
Switch to peers tab and show.
Definition: rpcconsole.cpp:813
RPCConsole::clearSelectedNode
void clearSelectedNode()
clear the selected node
Definition: rpcconsole.cpp:1072
INITIAL_TRAFFIC_GRAPH_MINS
const int INITIAL_TRAFFIC_GRAPH_MINS
Definition: rpcconsole.cpp:49
RESYNC
const QString RESYNC("-resync")
tableRPC
const CRPCTable tableRPC
Definition: server.cpp:636
CNetAddr
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
Definition: netaddress.h:30
source
const char * source
Definition: rpcconsole.cpp:62
QtRPCTimerBase::func
boost::function< void(void)> func
Definition: rpcconsole.cpp:103
RPCConsole::walletResync
void walletResync()
Restart wallet with "-resync".
Definition: rpcconsole.cpp:564
REINDEX
const QString REINDEX("-reindex")
GUIUtil::showQtDir
void showQtDir()
Definition: guiutil.cpp:384
QtRPCTimerBase::timeout
void timeout()
Definition: rpcconsole.cpp:100
CNode
Information about a peer.
Definition: net.h:306
ZAPTXES2
const QString ZAPTXES2("-zapwallettxes=2")
wallet.h
RPCConsole::CMD_REQUEST
@ CMD_REQUEST
Definition: rpcconsole.h:43
PeerTableModel::Subversion
@ Subversion
Definition: peertablemodel.h:60
RPCTimerBase
Opaque base class for timers returned by NewTimerFunc.
Definition: server.h:79
RPCConsole::showOrHideBanTableIfRequired
void showOrHideBanTableIfRequired()
Hides ban table if no bans are present.
Definition: rpcconsole.cpp:1080
CNodeStateStats::nSyncHeight
int nSyncHeight
Definition: main.h:290
RPCConsole::showConsole
void showConsole()
Switch to console tab and show.
Definition: rpcconsole.cpp:801
CNodeStateStats::nMisbehavior
int nMisbehavior
Definition: main.h:289
RPCConsole::RPCConsole
RPCConsole(QWidget *parent)
Definition: rpcconsole.cpp:258
RPCConsole::autoCompleter
QCompleter * autoCompleter
Definition: rpcconsole.h:155
RPCConsole::showConfEditor
void showConfEditor()
Open external (default) editor with prcycoin.conf.
Definition: rpcconsole.cpp:825
UniValue::isNull
bool isNull() const
Definition: univalue.h:77
RPCConsole::CMD_ERROR
@ CMD_ERROR
Definition: rpcconsole.h:45
CNode::Ban
static void Ban(const CNetAddr &ip, const BanReason &banReason, int64_t bantimeoffset=0, bool sinceUnixEpoch=false)
Definition: net.cpp:522
RPCConsole::setTrafficGraphRange
void setTrafficGraphRange(int mins)
Definition: rpcconsole.cpp:783
RPCConvertValues
UniValue RPCConvertValues(const std::string &strMethod, const std::vector< std::string > &strParams)
Convert strings to command-specific RPC representation.
Definition: client.cpp:193
CNodeStats::nLastRecv
int64_t nLastRecv
Definition: net.h:186
chainparams.h
PeerTableModel::Address
@ Address
Definition: peertablemodel.h:56
CNodeStats::addr
CAddress addr
Definition: net.h:200
RPCConsole::walletZaptxes1
void walletZaptxes1()
Restart wallet with "-zapwallettxes=1".
Definition: rpcconsole.cpp:540
FindNode
CNode * FindNode(const CNetAddr &ip)
Definition: net.cpp:301
RPCConsole::showEvent
void showEvent(QShowEvent *event)
Definition: rpcconsole.cpp:950
RPCConsole::message
void message(int category, const QString &message, bool html=false)
Definition: rpcconsole.cpp:655
BanTableModel::Bantime
@ Bantime
Definition: bantablemodel.h:51
QtRPCTimerBase::timer
QTimer timer
Definition: rpcconsole.cpp:102
UniValue
Definition: univalue.h:19
RPCConsole::cachedNodeid
NodeId cachedNodeid
Definition: rpcconsole.h:154
rpcconsole.h
RPCConsole::stopExecutor
void stopExecutor()
RPCConsole::clear
void clear()
Definition: rpcconsole.cpp:606
RPCConsole::peerLayoutChanged
void peerLayoutChanged()
Handle updated peer information.
Definition: rpcconsole.cpp:847
RPCConsole::reject
void reject()
Definition: rpcconsole.cpp:648
UniValue::get_str
const std::string & get_str() const
Definition: univalue.cpp:309
RPCConsole::updateTrafficStats
void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
update traffic statistics
Definition: rpcconsole.cpp:789
url
const char * url
Definition: rpcconsole.cpp:61
UniValue::isStr
bool isStr() const
Definition: univalue.h:81
GUIUtil::getEntryData
QVariant getEntryData(QAbstractItemView *view, int column, int role)
Return a field of the currently selected entry as a QString.
Definition: guiutil.cpp:227
CNodeStats::nTimeConnected
int64_t nTimeConnected
Definition: net.h:187
CService::ToString
std::string ToString() const
Definition: netaddress.cpp:568
GUIUtil::formatTimeOffset
QString formatTimeOffset(int64_t nTimeOffset)
Definition: guiutil.cpp:857
RPCConsole::scrollToEnd
void scrollToEnd()
Scroll console view to end.
Definition: rpcconsole.cpp:770
CRPCTable::execute
UniValue execute(const std::string &method, const UniValue &params) const
Execute a method.
Definition: server.cpp:569
RPCConsole::showInfo
void showInfo()
Switch to info tab and show.
Definition: rpcconsole.cpp:795
ClientModel::getPeerTableModel
PeerTableModel * getPeerTableModel()
Definition: clientmodel.cpp:203
CNode::Unban
static bool Unban(const CNetAddr &ip)
Definition: net.cpp:556
RPCConsole::showPeersTableContextMenu
void showPeersTableContextMenu(const QPoint &point)
Show custom context menu on Peers tab.
Definition: rpcconsole.cpp:989
RPCConsole::showMNConfEditor
void showMNConfEditor()
Open external (default) editor with masternode.conf.
Definition: rpcconsole.cpp:830
RPCConsole::showRepair
void showRepair()
Switch to wallet-repair tab and show.
Definition: rpcconsole.cpp:819
RPCSetTimerInterfaceIfUnset
void RPCSetTimerInterfaceIfUnset(RPCTimerInterface *iface)
Set factory function for timers, but only if unset.
Definition: server.cpp:613
CNodeStats::fWhitelisted
bool fWhitelisted
Definition: net.h:196
CNodeStats::dPingTime
double dPingTime
Definition: net.h:197
ClientModel::getMasternodeCountString
QString getMasternodeCountString() const
Definition: clientmodel.cpp:75
LookupHost
bool LookupHost(const char *pszName, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions, bool fAllowLookup)
Definition: netbase.cpp:184
RPCConsole::resizeEvent
void resizeEvent(QResizeEvent *event)
Definition: rpcconsole.cpp:945
RPCConsole::CMD_REPLY
@ CMD_REPLY
Definition: rpcconsole.h:44
RPCConsole::on_tabWidget_currentChanged
void on_tabWidget_currentChanged(int index)
Definition: rpcconsole.cpp:756
univalue.h
GUIUtil::saveWindowGeometry
void saveWindowGeometry(const QString &strSetting, QWidget *parent)
Save window size and position.
Definition: guiutil.cpp:691
RPCConsole::disconnectSelectedNode
void disconnectSelectedNode()
Disconnect a selected node on the Peers tab.
Definition: rpcconsole.cpp:1003
CNodeCombinedStats::fNodeStateStatsAvailable
bool fNodeStateStatsAvailable
Definition: peertablemodel.h:24
ClientModel::clientName
QString clientName() const
Definition: clientmodel.cpp:223
RPCConsole
Local Bitcoin RPC console.
Definition: rpcconsole.h:30
CONSOLE_HISTORY
const int CONSOLE_HISTORY
Definition: rpcconsole.cpp:46
GUIUtil::showBackups
bool showBackups()
Definition: guiutil.cpp:390
CRPCTable::listCommands
std::vector< std::string > listCommands() const
Returns a list of registered commands.
Definition: server.cpp:593
RPCExecutor::request
void request(const QString &command)
Definition: rpcconsole.cpp:217
QtRPCTimerInterface::NewTimer
RPCTimerBase * NewTimer(boost::function< void(void)> &func, int64_t millis)
Factory function for timers.
Definition: rpcconsole.cpp:111
RPCConsole::BANSUBNET_COLUMN_WIDTH
@ BANSUBNET_COLUMN_WIDTH
Definition: rpcconsole.h:146
RPCConsole::walletZaptxes2
void walletZaptxes2()
Restart wallet with "-zapwallettxes=2".
Definition: rpcconsole.cpp:546
CSubNet
Definition: netaddress.h:95
guiutil.h
ClientModel::formatFullVersion
QString formatFullVersion() const
Definition: clientmodel.cpp:213
CNodeStats::cleanSubVer
std::string cleanSubVer
Definition: net.h:191
RPCConsole::PING_COLUMN_WIDTH
@ PING_COLUMN_WIDTH
Definition: rpcconsole.h:145
RPCConsole::handleRestart
void handleRestart(QStringList args)
Get restart command-line parameters and handle restart.
RPCConsole::showBanTableContextMenu
void showBanTableContextMenu(const QPoint &point)
Show custom context menu on Bans tab.
Definition: rpcconsole.cpp:996
RPCConsole::showQtDir
void showQtDir()
Show Qt Dir folder in default browser.
Definition: rpcconsole.cpp:979
QtRPCTimerBase::QtRPCTimerBase
QtRPCTimerBase(boost::function< void(void)> &func, int64_t millis)
Definition: rpcconsole.cpp:91
RPCConsole::SUBVERSION_COLUMN_WIDTH
@ SUBVERSION_COLUMN_WIDTH
Definition: rpcconsole.h:144
CNodeCombinedStats
Definition: peertablemodel.h:21
QtRPCTimerInterface
Definition: rpcconsole.cpp:106
GUIUtil::formatBytes
QString formatBytes(uint64_t bytes)
Definition: guiutil.cpp:862
RPCConsole::BANTIME_COLUMN_WIDTH
@ BANTIME_COLUMN_WIDTH
Definition: rpcconsole.h:147
GUIUtil::formatServicesStr
QString formatServicesStr(quint64 mask)
Definition: guiutil.cpp:824
ClientModel::getTotalBytesSent
quint64 getTotalBytesSent() const
Definition: clientmodel.cpp:104
RESCAN
const QString RESCAN("-rescan")
UPGRADEWALLET
const QString UPGRADEWALLET("-upgradewallet")
PeerTableModel::getNodeStats
const CNodeCombinedStats * getNodeStats(int idx)
Definition: peertablemodel.cpp:229
RPCConsole::~RPCConsole
~RPCConsole()
Definition: rpcconsole.cpp:327
CNodeStats::nLastSend
int64_t nLastSend
Definition: net.h:185
CNodeStats::nTimeOffset
int64_t nTimeOffset
Definition: net.h:188
BanTableModel::shouldShow
bool shouldShow()
Definition: bantablemodel.cpp:183
PeerTableModel::Ping
@ Ping
Definition: peertablemodel.h:57
RPCConsole::showDataDir
void showDataDir()
Show DataDir folder in default browser.
Definition: rpcconsole.cpp:974
RPCConsole::updateNodeDetail
void updateNodeDetail(const CNodeCombinedStats *stats)
show detailed information on ui about selected node
Definition: rpcconsole.cpp:897
RPCConsole::history
QStringList history
Definition: rpcconsole.h:152
CNodeStats::dPingWait
double dPingWait
Definition: net.h:198
RPCExecutor
Definition: rpcconsole.cpp:72
ClientModel
Model for PRCY network client.
Definition: clientmodel.h:44
Ui
Definition: 2faconfirmdialog.h:7
CNodeStats::nSendBytes
uint64_t nSendBytes
Definition: net.h:194
RPCConsole::showBackups
void showBackups()
Show folder with wallet backups in default browser.
Definition: rpcconsole.cpp:984
GUIUtil::HtmlEscape
QString HtmlEscape(const QString &str, bool fMultiLine)
Definition: guiutil.cpp:200
ZAPTXES1
const QString ZAPTXES1("-zapwallettxes=1")
UniValue::get_int
int get_int() const
Definition: univalue.cpp:316
RPCConsole::on_lineEdit_returnPressed
void on_lineEdit_returnPressed()
Definition: rpcconsole.cpp:697
RPCConsole::peersTableContextMenu
QMenu * peersTableContextMenu
Definition: rpcconsole.h:156
QtRPCTimerInterface::~QtRPCTimerInterface
~QtRPCTimerInterface()
Definition: rpcconsole.cpp:109
ClientModel::getNumBlocks
int getNumBlocks()
Definition: clientmodel.cpp:84
key
CKey key
Definition: bip38tooldialog.cpp:173
RPCConsole::hideEvent
void hideEvent(QHideEvent *event)
Definition: rpcconsole.cpp:962
ClientModel::formatClientStartupTime
QString formatClientStartupTime() const
Definition: clientmodel.cpp:228
RPCConsole::cmdRequest
void cmdRequest(const QString &command)
PeerTableModel::startAutoRefresh
void startAutoRefresh()
Definition: peertablemodel.cpp:138
GetDataDir
const fs::path & GetDataDir(bool fNetSpecific)
Definition: util.cpp:349
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:463
GUIUtil::formatPingTime
QString formatPingTime(double dPingTime)
Definition: guiutil.cpp:852
CSubNet::IsValid
bool IsValid() const
Definition: netaddress.cpp:698
ClientModel::dataDir
QString dataDir() const
Definition: clientmodel.cpp:233
RPCConsole::on_openDebugLogfileButton_clicked
void on_openDebugLogfileButton_clicked()
open the debug.log from the current datadir
Definition: rpcconsole.cpp:765
RPCConsole::setMasternodeCount
void setMasternodeCount(const QString &strMasternodes)
Set number of masternodes shown in the UI.
Definition: rpcconsole.cpp:692
GUIUtil::formatDurationStr
QString formatDurationStr(int secs)
Definition: guiutil.cpp:804
RPCConsole::walletSalvage
void walletSalvage()
Wallet repair options.
Definition: rpcconsole.cpp:528
RPCConsole::browseHistory
void browseHistory(int offset)
Go forward or back in history.
Definition: rpcconsole.cpp:719
RPCExecutor::reply
void reply(int category, const QString &command)
RPCConsole::historyPtr
int historyPtr
Definition: rpcconsole.h:153
RPCConsole::on_sldGraphRange_valueChanged
void on_sldGraphRange_valueChanged(int value)
change the time range of the network traffic graph
Definition: rpcconsole.cpp:776
bantablemodel.h
netbase.h
find_value
const UniValue & find_value(const UniValue &obj, const std::string &name)
Definition: univalue.cpp:279
CNodeStats::nRecvBytes
uint64_t nRecvBytes
Definition: net.h:195
RPCConsole::setClientModel
void setClientModel(ClientModel *model)
Definition: rpcconsole.cpp:388
PeerTableModel::getRowByNodeId
int getRowByNodeId(NodeId nodeid)
Definition: peertablemodel.cpp:241
peertablemodel.h
RPCConsole::walletUpgrade
void walletUpgrade()
Restart wallet with "-upgradewallet".
Definition: rpcconsole.cpp:552
server.h
GetArg
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
Definition: util.cpp:241
RPCConsole::unbanSelectedNode
void unbanSelectedNode()
Unban a selected node on the Bans tab.
Definition: rpcconsole.cpp:1056
CNodeStats::nStartingHeight
int nStartingHeight
Definition: net.h:193
PeerTableModel::stopAutoRefresh
void stopAutoRefresh()
Definition: peertablemodel.cpp:143
ClientModel::getLastBlockDate
QDateTime getLastBlockDate() const
Definition: clientmodel.cpp:109
ClientModel::stopMasternodesTimer
void stopMasternodesTimer()
Definition: clientmodel.cpp:159
ClientModel::getTotalBytesRecv
quint64 getTotalBytesRecv() const
Definition: clientmodel.cpp:99
CNodeStats::nServices
ServiceFlags nServices
Definition: net.h:184
QtRPCTimerBase::~QtRPCTimerBase
~QtRPCTimerBase()
Definition: rpcconsole.cpp:98
RPCConsole::rpcTimerInterface
RPCTimerInterface * rpcTimerInterface
Definition: rpcconsole.h:158
RPCConsole::peerSelected
void peerSelected(const QItemSelection &selected, const QItemSelection &deselected)
Handle selection of peer in peers list.
Definition: rpcconsole.cpp:835
RPCConsole::banSelectedNode
void banSelectedNode(int bantime)
Ban a selected node on the Peers tab.
Definition: rpcconsole.cpp:1024
BanTableModel::refresh
void refresh()
Definition: bantablemodel.cpp:169
SALVAGEWALLET
const QString SALVAGEWALLET("-salvagewallet")
client.h
RPCConsole::clientModel
ClientModel * clientModel
Definition: rpcconsole.h:151
RPCConsole::banTableContextMenu
QMenu * banTableContextMenu
Definition: rpcconsole.h:157
clientmodel.h
GUIUtil::restoreWindowGeometry
void restoreWindowGeometry(const QString &strSetting, const QSize &defaultSize, QWidget *parent)
Restore window size and position.
Definition: guiutil.cpp:704
UniValue::write
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
Definition: univalue_write.cpp:31
BanTableModel::Address
@ Address
Definition: bantablemodel.h:50
RPCConsole::ui
Ui::RPCConsole * ui
Definition: rpcconsole.h:150
ClientModel::getBanTableModel
BanTableModel * getBanTableModel()
Definition: clientmodel.cpp:208
CNodeCombinedStats::nodeStateStats
CNodeStateStats nodeStateStats
Definition: peertablemodel.h:23