Bitcoin Core  22.99.0
P2P Digital Currency
guiutil.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2021 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <qt/guiutil.h>
6 
8 #include <qt/bitcoinunits.h>
9 #include <qt/platformstyle.h>
10 #include <qt/qvalidatedlineedit.h>
11 #include <qt/sendcoinsrecipient.h>
12 
13 #include <base58.h>
14 #include <chainparams.h>
15 #include <fs.h>
16 #include <interfaces/node.h>
17 #include <key_io.h>
18 #include <policy/policy.h>
19 #include <primitives/transaction.h>
20 #include <protocol.h>
21 #include <script/script.h>
22 #include <script/standard.h>
23 #include <util/system.h>
24 #include <util/time.h>
25 
26 #ifdef WIN32
27 #ifndef NOMINMAX
28 #define NOMINMAX
29 #endif
30 #include <shellapi.h>
31 #include <shlobj.h>
32 #include <shlwapi.h>
33 #endif
34 
35 #include <QAbstractButton>
36 #include <QAbstractItemView>
37 #include <QApplication>
38 #include <QClipboard>
39 #include <QDateTime>
40 #include <QDesktopServices>
41 #include <QDialog>
42 #include <QDoubleValidator>
43 #include <QFileDialog>
44 #include <QFont>
45 #include <QFontDatabase>
46 #include <QFontMetrics>
47 #include <QGuiApplication>
48 #include <QJsonObject>
49 #include <QKeyEvent>
50 #include <QLatin1String>
51 #include <QLineEdit>
52 #include <QList>
53 #include <QLocale>
54 #include <QMenu>
55 #include <QMouseEvent>
56 #include <QPluginLoader>
57 #include <QProgressDialog>
58 #include <QScreen>
59 #include <QSettings>
60 #include <QShortcut>
61 #include <QSize>
62 #include <QString>
63 #include <QTextDocument> // for Qt::mightBeRichText
64 #include <QThread>
65 #include <QUrlQuery>
66 #include <QtGlobal>
67 
68 #include <cassert>
69 #include <chrono>
70 #include <exception>
71 #include <fstream>
72 #include <string>
73 #include <vector>
74 
75 #if defined(Q_OS_MAC)
76 
77 #include <QProcess>
78 
79 void ForceActivation();
80 #endif
81 
82 namespace GUIUtil {
83 
84 QString dateTimeStr(const QDateTime &date)
85 {
86  return QLocale::system().toString(date.date(), QLocale::ShortFormat) + QString(" ") + date.toString("hh:mm");
87 }
88 
89 QString dateTimeStr(qint64 nTime)
90 {
91  return dateTimeStr(QDateTime::fromSecsSinceEpoch(nTime));
92 }
93 
94 QFont fixedPitchFont(bool use_embedded_font)
95 {
96  if (use_embedded_font) {
97  return {"Roboto Mono"};
98  }
99  return QFontDatabase::systemFont(QFontDatabase::FixedFont);
100 }
101 
102 // Just some dummy data to generate a convincing random-looking (but consistent) address
103 static const uint8_t dummydata[] = {0xeb,0x15,0x23,0x1d,0xfc,0xeb,0x60,0x92,0x58,0x86,0xb6,0x7d,0x06,0x52,0x99,0x92,0x59,0x15,0xae,0xb1,0x72,0xc0,0x66,0x47};
104 
105 // Generate a dummy address with invalid CRC, starting with the network prefix.
106 static std::string DummyAddress(const CChainParams &params)
107 {
108  std::vector<unsigned char> sourcedata = params.Base58Prefix(CChainParams::PUBKEY_ADDRESS);
109  sourcedata.insert(sourcedata.end(), dummydata, dummydata + sizeof(dummydata));
110  for(int i=0; i<256; ++i) { // Try every trailing byte
111  std::string s = EncodeBase58(sourcedata);
112  if (!IsValidDestinationString(s)) {
113  return s;
114  }
115  sourcedata[sourcedata.size()-1] += 1;
116  }
117  return "";
118 }
119 
120 void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
121 {
122  parent->setFocusProxy(widget);
123 
124  widget->setFont(fixedPitchFont());
125  // We don't want translators to use own addresses in translations
126  // and this is the only place, where this address is supplied.
127  widget->setPlaceholderText(QObject::tr("Enter a Bitcoin address (e.g. %1)").arg(
128  QString::fromStdString(DummyAddress(Params()))));
129  widget->setValidator(new BitcoinAddressEntryValidator(parent));
130  widget->setCheckValidator(new BitcoinAddressCheckValidator(parent));
131 }
132 
133 void AddButtonShortcut(QAbstractButton* button, const QKeySequence& shortcut)
134 {
135  QObject::connect(new QShortcut(shortcut, button), &QShortcut::activated, [button]() { button->animateClick(); });
136 }
137 
138 bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
139 {
140  // return if URI is not valid or is no bitcoin: URI
141  if(!uri.isValid() || uri.scheme() != QString("bitcoin"))
142  return false;
143 
145  rv.address = uri.path();
146  // Trim any following forward slash which may have been added by the OS
147  if (rv.address.endsWith("/")) {
148  rv.address.truncate(rv.address.length() - 1);
149  }
150  rv.amount = 0;
151 
152  QUrlQuery uriQuery(uri);
153  QList<QPair<QString, QString> > items = uriQuery.queryItems();
154  for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++)
155  {
156  bool fShouldReturnFalse = false;
157  if (i->first.startsWith("req-"))
158  {
159  i->first.remove(0, 4);
160  fShouldReturnFalse = true;
161  }
162 
163  if (i->first == "label")
164  {
165  rv.label = i->second;
166  fShouldReturnFalse = false;
167  }
168  if (i->first == "message")
169  {
170  rv.message = i->second;
171  fShouldReturnFalse = false;
172  }
173  else if (i->first == "amount")
174  {
175  if(!i->second.isEmpty())
176  {
177  if(!BitcoinUnits::parse(BitcoinUnits::BTC, i->second, &rv.amount))
178  {
179  return false;
180  }
181  }
182  fShouldReturnFalse = false;
183  }
184 
185  if (fShouldReturnFalse)
186  return false;
187  }
188  if(out)
189  {
190  *out = rv;
191  }
192  return true;
193 }
194 
195 bool parseBitcoinURI(QString uri, SendCoinsRecipient *out)
196 {
197  QUrl uriInstance(uri);
198  return parseBitcoinURI(uriInstance, out);
199 }
200 
202 {
203  bool bech_32 = info.address.startsWith(QString::fromStdString(Params().Bech32HRP() + "1"));
204 
205  QString ret = QString("bitcoin:%1").arg(bech_32 ? info.address.toUpper() : info.address);
206  int paramCount = 0;
207 
208  if (info.amount)
209  {
210  ret += QString("?amount=%1").arg(BitcoinUnits::format(BitcoinUnits::BTC, info.amount, false, BitcoinUnits::SeparatorStyle::NEVER));
211  paramCount++;
212  }
213 
214  if (!info.label.isEmpty())
215  {
216  QString lbl(QUrl::toPercentEncoding(info.label));
217  ret += QString("%1label=%2").arg(paramCount == 0 ? "?" : "&").arg(lbl);
218  paramCount++;
219  }
220 
221  if (!info.message.isEmpty())
222  {
223  QString msg(QUrl::toPercentEncoding(info.message));
224  ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg);
225  paramCount++;
226  }
227 
228  return ret;
229 }
230 
231 bool isDust(interfaces::Node& node, const QString& address, const CAmount& amount)
232 {
233  CTxDestination dest = DecodeDestination(address.toStdString());
234  CScript script = GetScriptForDestination(dest);
235  CTxOut txOut(amount, script);
236  return IsDust(txOut, node.getDustRelayFee());
237 }
238 
239 QString HtmlEscape(const QString& str, bool fMultiLine)
240 {
241  QString escaped = str.toHtmlEscaped();
242  if(fMultiLine)
243  {
244  escaped = escaped.replace("\n", "<br>\n");
245  }
246  return escaped;
247 }
248 
249 QString HtmlEscape(const std::string& str, bool fMultiLine)
250 {
251  return HtmlEscape(QString::fromStdString(str), fMultiLine);
252 }
253 
254 void copyEntryData(const QAbstractItemView *view, int column, int role)
255 {
256  if(!view || !view->selectionModel())
257  return;
258  QModelIndexList selection = view->selectionModel()->selectedRows(column);
259 
260  if(!selection.isEmpty())
261  {
262  // Copy first item
263  setClipboard(selection.at(0).data(role).toString());
264  }
265 }
266 
267 QList<QModelIndex> getEntryData(const QAbstractItemView *view, int column)
268 {
269  if(!view || !view->selectionModel())
270  return QList<QModelIndex>();
271  return view->selectionModel()->selectedRows(column);
272 }
273 
274 bool hasEntryData(const QAbstractItemView *view, int column, int role)
275 {
276  QModelIndexList selection = getEntryData(view, column);
277  if (selection.isEmpty()) return false;
278  return !selection.at(0).data(role).toString().isEmpty();
279 }
280 
281 void LoadFont(const QString& file_name)
282 {
283  const int id = QFontDatabase::addApplicationFont(file_name);
284  assert(id != -1);
285 }
286 
288 {
290 }
291 
292 QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir,
293  const QString &filter,
294  QString *selectedSuffixOut)
295 {
296  QString selectedFilter;
297  QString myDir;
298  if(dir.isEmpty()) // Default to user documents location
299  {
300  myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
301  }
302  else
303  {
304  myDir = dir;
305  }
306  /* Directly convert path to native OS path separators */
307  QString result = QDir::toNativeSeparators(QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter));
308 
309  /* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */
310  QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]");
311  QString selectedSuffix;
312  if(filter_re.exactMatch(selectedFilter))
313  {
314  selectedSuffix = filter_re.cap(1);
315  }
316 
317  /* Add suffix if needed */
318  QFileInfo info(result);
319  if(!result.isEmpty())
320  {
321  if(info.suffix().isEmpty() && !selectedSuffix.isEmpty())
322  {
323  /* No suffix specified, add selected suffix */
324  if(!result.endsWith("."))
325  result.append(".");
326  result.append(selectedSuffix);
327  }
328  }
329 
330  /* Return selected suffix if asked to */
331  if(selectedSuffixOut)
332  {
333  *selectedSuffixOut = selectedSuffix;
334  }
335  return result;
336 }
337 
338 QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir,
339  const QString &filter,
340  QString *selectedSuffixOut)
341 {
342  QString selectedFilter;
343  QString myDir;
344  if(dir.isEmpty()) // Default to user documents location
345  {
346  myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
347  }
348  else
349  {
350  myDir = dir;
351  }
352  /* Directly convert path to native OS path separators */
353  QString result = QDir::toNativeSeparators(QFileDialog::getOpenFileName(parent, caption, myDir, filter, &selectedFilter));
354 
355  if(selectedSuffixOut)
356  {
357  /* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */
358  QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]");
359  QString selectedSuffix;
360  if(filter_re.exactMatch(selectedFilter))
361  {
362  selectedSuffix = filter_re.cap(1);
363  }
364  *selectedSuffixOut = selectedSuffix;
365  }
366  return result;
367 }
368 
370 {
371  if(QThread::currentThread() != qApp->thread())
372  {
373  return Qt::BlockingQueuedConnection;
374  }
375  else
376  {
377  return Qt::DirectConnection;
378  }
379 }
380 
381 bool checkPoint(const QPoint &p, const QWidget *w)
382 {
383  QWidget *atW = QApplication::widgetAt(w->mapToGlobal(p));
384  if (!atW) return false;
385  return atW->window() == w;
386 }
387 
388 bool isObscured(QWidget *w)
389 {
390  return !(checkPoint(QPoint(0, 0), w)
391  && checkPoint(QPoint(w->width() - 1, 0), w)
392  && checkPoint(QPoint(0, w->height() - 1), w)
393  && checkPoint(QPoint(w->width() - 1, w->height() - 1), w)
394  && checkPoint(QPoint(w->width() / 2, w->height() / 2), w));
395 }
396 
397 void bringToFront(QWidget* w)
398 {
399 #ifdef Q_OS_MAC
400  ForceActivation();
401 #endif
402 
403  if (w) {
404  // activateWindow() (sometimes) helps with keyboard focus on Windows
405  if (w->isMinimized()) {
406  w->showNormal();
407  } else {
408  w->show();
409  }
410  w->activateWindow();
411  w->raise();
412  }
413 }
414 
416 {
417  QObject::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), w), &QShortcut::activated, w, &QWidget::close);
418 }
419 
421 {
422  fs::path pathDebug = gArgs.GetDataDirNet() / "debug.log";
423 
424  /* Open debug.log with the associated application */
425  if (fs::exists(pathDebug))
426  QDesktopServices::openUrl(QUrl::fromLocalFile(PathToQString(pathDebug)));
427 }
428 
430 {
431  fs::path pathConfig = GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME));
432 
433  /* Create the file */
434  std::ofstream configFile{pathConfig, std::ios_base::app};
435 
436  if (!configFile.good())
437  return false;
438 
439  configFile.close();
440 
441  /* Open bitcoin.conf with the associated application */
442  bool res = QDesktopServices::openUrl(QUrl::fromLocalFile(PathToQString(pathConfig)));
443 #ifdef Q_OS_MAC
444  // Workaround for macOS-specific behavior; see #15409.
445  if (!res) {
446  res = QProcess::startDetached("/usr/bin/open", QStringList{"-t", PathToQString(pathConfig)});
447  }
448 #endif
449 
450  return res;
451 }
452 
453 ToolTipToRichTextFilter::ToolTipToRichTextFilter(int _size_threshold, QObject *parent) :
454  QObject(parent),
455  size_threshold(_size_threshold)
456 {
457 
458 }
459 
460 bool ToolTipToRichTextFilter::eventFilter(QObject *obj, QEvent *evt)
461 {
462  if(evt->type() == QEvent::ToolTipChange)
463  {
464  QWidget *widget = static_cast<QWidget*>(obj);
465  QString tooltip = widget->toolTip();
466  if(tooltip.size() > size_threshold && !tooltip.startsWith("<qt") && !Qt::mightBeRichText(tooltip))
467  {
468  // Envelop with <qt></qt> to make sure Qt detects this as rich text
469  // Escape the current message as HTML and replace \n by <br>
470  tooltip = "<qt>" + HtmlEscape(tooltip, true) + "</qt>";
471  widget->setToolTip(tooltip);
472  return true;
473  }
474  }
475  return QObject::eventFilter(obj, evt);
476 }
477 
479  : QObject(parent)
480 {
481 }
482 
483 bool LabelOutOfFocusEventFilter::eventFilter(QObject* watched, QEvent* event)
484 {
485  if (event->type() == QEvent::FocusOut) {
486  auto focus_out = static_cast<QFocusEvent*>(event);
487  if (focus_out->reason() != Qt::PopupFocusReason) {
488  auto label = qobject_cast<QLabel*>(watched);
489  if (label) {
490  auto flags = label->textInteractionFlags();
491  label->setTextInteractionFlags(Qt::NoTextInteraction);
492  label->setTextInteractionFlags(flags);
493  }
494  }
495  }
496 
497  return QObject::eventFilter(watched, event);
498 }
499 
500 #ifdef WIN32
501 fs::path static StartupShortcutPath()
502 {
503  std::string chain = gArgs.GetChainName();
504  if (chain == CBaseChainParams::MAIN)
505  return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin.lnk";
506  if (chain == CBaseChainParams::TESTNET) // Remove this special case when CBaseChainParams::TESTNET = "testnet4"
507  return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin (testnet).lnk";
508  return GetSpecialFolderPath(CSIDL_STARTUP) / strprintf("Bitcoin (%s).lnk", chain);
509 }
510 
512 {
513  // check for Bitcoin*.lnk
514  return fs::exists(StartupShortcutPath());
515 }
516 
517 bool SetStartOnSystemStartup(bool fAutoStart)
518 {
519  // If the shortcut exists already, remove it for updating
520  fs::remove(StartupShortcutPath());
521 
522  if (fAutoStart)
523  {
524  CoInitialize(nullptr);
525 
526  // Get a pointer to the IShellLink interface.
527  IShellLinkW* psl = nullptr;
528  HRESULT hres = CoCreateInstance(CLSID_ShellLink, nullptr,
529  CLSCTX_INPROC_SERVER, IID_IShellLinkW,
530  reinterpret_cast<void**>(&psl));
531 
532  if (SUCCEEDED(hres))
533  {
534  // Get the current executable path
535  WCHAR pszExePath[MAX_PATH];
536  GetModuleFileNameW(nullptr, pszExePath, ARRAYSIZE(pszExePath));
537 
538  // Start client minimized
539  QString strArgs = "-min";
540  // Set -testnet /-regtest options
541  strArgs += QString::fromStdString(strprintf(" -chain=%s", gArgs.GetChainName()));
542 
543  // Set the path to the shortcut target
544  psl->SetPath(pszExePath);
545  PathRemoveFileSpecW(pszExePath);
546  psl->SetWorkingDirectory(pszExePath);
547  psl->SetShowCmd(SW_SHOWMINNOACTIVE);
548  psl->SetArguments(strArgs.toStdWString().c_str());
549 
550  // Query IShellLink for the IPersistFile interface for
551  // saving the shortcut in persistent storage.
552  IPersistFile* ppf = nullptr;
553  hres = psl->QueryInterface(IID_IPersistFile, reinterpret_cast<void**>(&ppf));
554  if (SUCCEEDED(hres))
555  {
556  // Save the link by calling IPersistFile::Save.
557  hres = ppf->Save(StartupShortcutPath().wstring().c_str(), TRUE);
558  ppf->Release();
559  psl->Release();
560  CoUninitialize();
561  return true;
562  }
563  psl->Release();
564  }
565  CoUninitialize();
566  return false;
567  }
568  return true;
569 }
570 #elif defined(Q_OS_LINUX)
571 
572 // Follow the Desktop Application Autostart Spec:
573 // https://specifications.freedesktop.org/autostart-spec/autostart-spec-latest.html
574 
575 fs::path static GetAutostartDir()
576 {
577  char* pszConfigHome = getenv("XDG_CONFIG_HOME");
578  if (pszConfigHome) return fs::path(pszConfigHome) / "autostart";
579  char* pszHome = getenv("HOME");
580  if (pszHome) return fs::path(pszHome) / ".config" / "autostart";
581  return fs::path();
582 }
583 
584 fs::path static GetAutostartFilePath()
585 {
586  std::string chain = gArgs.GetChainName();
587  if (chain == CBaseChainParams::MAIN)
588  return GetAutostartDir() / "bitcoin.desktop";
589  return GetAutostartDir() / strprintf("bitcoin-%s.desktop", chain);
590 }
591 
593 {
594  std::ifstream optionFile{GetAutostartFilePath()};
595  if (!optionFile.good())
596  return false;
597  // Scan through file for "Hidden=true":
598  std::string line;
599  while (!optionFile.eof())
600  {
601  getline(optionFile, line);
602  if (line.find("Hidden") != std::string::npos &&
603  line.find("true") != std::string::npos)
604  return false;
605  }
606  optionFile.close();
607 
608  return true;
609 }
610 
611 bool SetStartOnSystemStartup(bool fAutoStart)
612 {
613  if (!fAutoStart)
614  fs::remove(GetAutostartFilePath());
615  else
616  {
617  char pszExePath[MAX_PATH+1];
618  ssize_t r = readlink("/proc/self/exe", pszExePath, sizeof(pszExePath) - 1);
619  if (r == -1)
620  return false;
621  pszExePath[r] = '\0';
622 
623  fs::create_directories(GetAutostartDir());
624 
625  std::ofstream optionFile{GetAutostartFilePath(), std::ios_base::out | std::ios_base::trunc};
626  if (!optionFile.good())
627  return false;
628  std::string chain = gArgs.GetChainName();
629  // Write a bitcoin.desktop file to the autostart directory:
630  optionFile << "[Desktop Entry]\n";
631  optionFile << "Type=Application\n";
632  if (chain == CBaseChainParams::MAIN)
633  optionFile << "Name=Bitcoin\n";
634  else
635  optionFile << strprintf("Name=Bitcoin (%s)\n", chain);
636  optionFile << "Exec=" << pszExePath << strprintf(" -min -chain=%s\n", chain);
637  optionFile << "Terminal=false\n";
638  optionFile << "Hidden=false\n";
639  optionFile.close();
640  }
641  return true;
642 }
643 
644 #else
645 
646 bool GetStartOnSystemStartup() { return false; }
647 bool SetStartOnSystemStartup(bool fAutoStart) { return false; }
648 
649 #endif
650 
651 void setClipboard(const QString& str)
652 {
653  QClipboard* clipboard = QApplication::clipboard();
654  clipboard->setText(str, QClipboard::Clipboard);
655  if (clipboard->supportsSelection()) {
656  clipboard->setText(str, QClipboard::Selection);
657  }
658 }
659 
660 fs::path QStringToPath(const QString &path)
661 {
662  return fs::u8path(path.toStdString());
663 }
664 
665 QString PathToQString(const fs::path &path)
666 {
667  return QString::fromStdString(path.u8string());
668 }
669 
671 {
672  switch (net) {
673  case NET_UNROUTABLE: return QObject::tr("Unroutable");
674  case NET_IPV4: return "IPv4";
675  case NET_IPV6: return "IPv6";
676  case NET_ONION: return "Onion";
677  case NET_I2P: return "I2P";
678  case NET_CJDNS: return "CJDNS";
679  case NET_INTERNAL: return QObject::tr("Internal");
680  case NET_MAX: assert(false);
681  } // no default case, so the compiler can warn about missing cases
682  assert(false);
683 }
684 
685 QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction)
686 {
687  QString prefix;
688  if (prepend_direction) {
689  prefix = (conn_type == ConnectionType::INBOUND) ?
690  /*: An inbound connection from a peer. An inbound connection
691  is a connection initiated by a peer. */
692  QObject::tr("Inbound") :
693  /*: An outbound connection to a peer. An outbound connection
694  is a connection initiated by us. */
695  QObject::tr("Outbound") + " ";
696  }
697  switch (conn_type) {
698  case ConnectionType::INBOUND: return prefix;
699  //: Peer connection type that relays all network information.
700  case ConnectionType::OUTBOUND_FULL_RELAY: return prefix + QObject::tr("Full Relay");
701  /*: Peer connection type that relays network information about
702  blocks and not transactions or addresses. */
703  case ConnectionType::BLOCK_RELAY: return prefix + QObject::tr("Block Relay");
704  //: Peer connection type established manually through one of several methods.
705  case ConnectionType::MANUAL: return prefix + QObject::tr("Manual");
706  //: Short-lived peer connection type that tests the aliveness of known addresses.
707  case ConnectionType::FEELER: return prefix + QObject::tr("Feeler");
708  //: Short-lived peer connection type that solicits known addresses from a peer.
709  case ConnectionType::ADDR_FETCH: return prefix + QObject::tr("Address Fetch");
710  } // no default case, so the compiler can warn about missing cases
711  assert(false);
712 }
713 
714 QString formatDurationStr(std::chrono::seconds dur)
715 {
716  const auto secs = count_seconds(dur);
717  QStringList strList;
718  int days = secs / 86400;
719  int hours = (secs % 86400) / 3600;
720  int mins = (secs % 3600) / 60;
721  int seconds = secs % 60;
722 
723  if (days)
724  strList.append(QObject::tr("%1 d").arg(days));
725  if (hours)
726  strList.append(QObject::tr("%1 h").arg(hours));
727  if (mins)
728  strList.append(QObject::tr("%1 m").arg(mins));
729  if (seconds || (!days && !hours && !mins))
730  strList.append(QObject::tr("%1 s").arg(seconds));
731 
732  return strList.join(" ");
733 }
734 
735 QString formatServicesStr(quint64 mask)
736 {
737  QStringList strList;
738 
739  for (const auto& flag : serviceFlagsToStr(mask)) {
740  strList.append(QString::fromStdString(flag));
741  }
742 
743  if (strList.size())
744  return strList.join(", ");
745  else
746  return QObject::tr("None");
747 }
748 
749 QString formatPingTime(std::chrono::microseconds ping_time)
750 {
751  return (ping_time == std::chrono::microseconds::max() || ping_time == 0us) ?
752  QObject::tr("N/A") :
753  QObject::tr("%1 ms").arg(QString::number((int)(count_microseconds(ping_time) / 1000), 10));
754 }
755 
756 QString formatTimeOffset(int64_t nTimeOffset)
757 {
758  return QObject::tr("%1 s").arg(QString::number((int)nTimeOffset, 10));
759 }
760 
761 QString formatNiceTimeOffset(qint64 secs)
762 {
763  // Represent time from last generated block in human readable text
764  QString timeBehindText;
765  const int HOUR_IN_SECONDS = 60*60;
766  const int DAY_IN_SECONDS = 24*60*60;
767  const int WEEK_IN_SECONDS = 7*24*60*60;
768  const int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calendar
769  if(secs < 60)
770  {
771  timeBehindText = QObject::tr("%n second(s)","",secs);
772  }
773  else if(secs < 2*HOUR_IN_SECONDS)
774  {
775  timeBehindText = QObject::tr("%n minute(s)","",secs/60);
776  }
777  else if(secs < 2*DAY_IN_SECONDS)
778  {
779  timeBehindText = QObject::tr("%n hour(s)","",secs/HOUR_IN_SECONDS);
780  }
781  else if(secs < 2*WEEK_IN_SECONDS)
782  {
783  timeBehindText = QObject::tr("%n day(s)","",secs/DAY_IN_SECONDS);
784  }
785  else if(secs < YEAR_IN_SECONDS)
786  {
787  timeBehindText = QObject::tr("%n week(s)","",secs/WEEK_IN_SECONDS);
788  }
789  else
790  {
791  qint64 years = secs / YEAR_IN_SECONDS;
792  qint64 remainder = secs % YEAR_IN_SECONDS;
793  timeBehindText = QObject::tr("%1 and %2").arg(QObject::tr("%n year(s)", "", years)).arg(QObject::tr("%n week(s)","", remainder/WEEK_IN_SECONDS));
794  }
795  return timeBehindText;
796 }
797 
798 QString formatBytes(uint64_t bytes)
799 {
800  if (bytes < 1'000)
801  return QObject::tr("%1 B").arg(bytes);
802  if (bytes < 1'000'000)
803  return QObject::tr("%1 kB").arg(bytes / 1'000);
804  if (bytes < 1'000'000'000)
805  return QObject::tr("%1 MB").arg(bytes / 1'000'000);
806 
807  return QObject::tr("%1 GB").arg(bytes / 1'000'000'000);
808 }
809 
810 qreal calculateIdealFontSize(int width, const QString& text, QFont font, qreal minPointSize, qreal font_size) {
811  while(font_size >= minPointSize) {
812  font.setPointSizeF(font_size);
813  QFontMetrics fm(font);
814  if (TextWidth(fm, text) < width) {
815  break;
816  }
817  font_size -= 0.5;
818  }
819  return font_size;
820 }
821 
822 ThemedLabel::ThemedLabel(const PlatformStyle* platform_style, QWidget* parent)
823  : QLabel{parent}, m_platform_style{platform_style}
824 {
825  assert(m_platform_style);
826 }
827 
828 void ThemedLabel::setThemedPixmap(const QString& image_filename, int width, int height)
829 {
830  m_image_filename = image_filename;
831  m_pixmap_width = width;
832  m_pixmap_height = height;
834 }
835 
837 {
838  if (e->type() == QEvent::PaletteChange) {
840  }
841 
842  QLabel::changeEvent(e);
843 }
844 
846 {
848 }
849 
850 ClickableLabel::ClickableLabel(const PlatformStyle* platform_style, QWidget* parent)
851  : ThemedLabel{platform_style, parent}
852 {
853 }
854 
855 void ClickableLabel::mouseReleaseEvent(QMouseEvent *event)
856 {
857  Q_EMIT clicked(event->pos());
858 }
859 
861 {
862  Q_EMIT clicked(event->pos());
863 }
864 
865 bool ItemDelegate::eventFilter(QObject *object, QEvent *event)
866 {
867  if (event->type() == QEvent::KeyPress) {
868  if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) {
869  Q_EMIT keyEscapePressed();
870  }
871  }
872  return QItemDelegate::eventFilter(object, event);
873 }
874 
875 void PolishProgressDialog(QProgressDialog* dialog)
876 {
877 #ifdef Q_OS_MAC
878  // Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357.
879  const int margin = TextWidth(dialog->fontMetrics(), ("X"));
880  dialog->resize(dialog->width() + 2 * margin, dialog->height());
881 #endif
882  // QProgressDialog estimates the time the operation will take (based on time
883  // for steps), and only shows itself if that estimate is beyond minimumDuration.
884  // The default minimumDuration value is 4 seconds, and it could make users
885  // think that the GUI is frozen.
886  dialog->setMinimumDuration(0);
887 }
888 
889 int TextWidth(const QFontMetrics& fm, const QString& text)
890 {
891 #if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
892  return fm.horizontalAdvance(text);
893 #else
894  return fm.width(text);
895 #endif
896 }
897 
898 void LogQtInfo()
899 {
900 #ifdef QT_STATIC
901  const std::string qt_link{"static"};
902 #else
903  const std::string qt_link{"dynamic"};
904 #endif
905 #ifdef QT_STATICPLUGIN
906  const std::string plugin_link{"static"};
907 #else
908  const std::string plugin_link{"dynamic"};
909 #endif
910  LogPrintf("Qt %s (%s), plugin=%s (%s)\n", qVersion(), qt_link, QGuiApplication::platformName().toStdString(), plugin_link);
911  const auto static_plugins = QPluginLoader::staticPlugins();
912  if (static_plugins.empty()) {
913  LogPrintf("No static plugins.\n");
914  } else {
915  LogPrintf("Static plugins:\n");
916  for (const QStaticPlugin& p : static_plugins) {
917  QJsonObject meta_data = p.metaData();
918  const std::string plugin_class = meta_data.take(QString("className")).toString().toStdString();
919  const int plugin_version = meta_data.take(QString("version")).toInt();
920  LogPrintf(" %s, version %d\n", plugin_class, plugin_version);
921  }
922  }
923 
924  LogPrintf("Style: %s / %s\n", QApplication::style()->objectName().toStdString(), QApplication::style()->metaObject()->className());
925  LogPrintf("System: %s, %s\n", QSysInfo::prettyProductName().toStdString(), QSysInfo::buildAbi().toStdString());
926  for (const QScreen* s : QGuiApplication::screens()) {
927  LogPrintf("Screen: %s %dx%d, pixel ratio=%.1f\n", s->name().toStdString(), s->size().width(), s->size().height(), s->devicePixelRatio());
928  }
929 }
930 
931 void PopupMenu(QMenu* menu, const QPoint& point, QAction* at_action)
932 {
933  // The qminimal plugin does not provide window system integration.
934  if (QApplication::platformName() == "minimal") return;
935  menu->popup(point, at_action);
936 }
937 
938 QDateTime StartOfDay(const QDate& date)
939 {
940 #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
941  return date.startOfDay();
942 #else
943  return QDateTime(date);
944 #endif
945 }
946 
947 bool HasPixmap(const QLabel* label)
948 {
949 #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
950  return !label->pixmap(Qt::ReturnByValue).isNull();
951 #else
952  return label->pixmap() != nullptr;
953 #endif
954 }
955 
956 QImage GetImage(const QLabel* label)
957 {
958  if (!HasPixmap(label)) {
959  return QImage();
960  }
961 
962 #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
963  return label->pixmap(Qt::ReturnByValue).toImage();
964 #else
965  return label->pixmap()->toImage();
966 #endif
967 }
968 
969 QString MakeHtmlLink(const QString& source, const QString& link)
970 {
971  return QString(source).replace(
972  link,
973  QLatin1String("<a href=\"") + link + QLatin1String("\">") + link + QLatin1String("</a>"));
974 }
975 
977  const std::exception* exception,
978  const QObject* sender,
979  const QObject* receiver)
980 {
981  std::string description = sender->metaObject()->className();
982  description += "->";
983  description += receiver->metaObject()->className();
984  PrintExceptionContinue(exception, description.c_str());
985 }
986 
987 void ShowModalDialogAsynchronously(QDialog* dialog)
988 {
989  dialog->setAttribute(Qt::WA_DeleteOnClose);
990  dialog->setWindowModality(Qt::ApplicationModal);
991  dialog->show();
992 }
993 
994 } // namespace GUIUtil
SendCoinsRecipient::amount
CAmount amount
Definition: sendcoinsrecipient.h:33
QValidatedLineEdit::setCheckValidator
void setCheckValidator(const QValidator *v)
Definition: qvalidatedlineedit.cpp:112
policy.h
GUIUtil::PathToQString
QString PathToQString(const fs::path &path)
Convert OS specific boost path to QString through UTF-8.
Definition: guiutil.cpp:665
BitcoinUnits::SeparatorStyle::NEVER
@ NEVER
fs::exists
static bool exists(const path &p)
Definition: fs.h:69
GUIUtil::openBitcoinConf
bool openBitcoinConf()
Definition: guiutil.cpp:429
GUIUtil::PopupMenu
void PopupMenu(QMenu *menu, const QPoint &point, QAction *at_action)
Call QMenu::popup() only on supported QT_QPA_PLATFORM.
Definition: guiutil.cpp:931
NET_UNROUTABLE
@ NET_UNROUTABLE
Addresses from these networks are not publicly routable on the global Internet.
Definition: netaddress.h:47
assert
assert(!tx.IsCoinBase())
NET_IPV4
@ NET_IPV4
IPv4.
Definition: netaddress.h:50
GUIUtil::QStringToPath
fs::path QStringToPath(const QString &path)
Convert QString to OS specific boost path through UTF-8.
Definition: guiutil.cpp:660
BitcoinAddressCheckValidator
Bitcoin address widget validator, checks for a valid bitcoin address.
Definition: bitcoinaddressvalidator.h:25
fs.h
GetDefaultDataDir
fs::path GetDefaultDataDir()
Definition: system.cpp:786
flags
int flags
Definition: bitcoin-tx.cpp:529
ArgsManager::GetDataDirNet
const fs::path & GetDataDirNet() const
Get data directory path with appended network identifier.
Definition: system.h:304
key_io.h
GUIUtil::ToolTipToRichTextFilter::ToolTipToRichTextFilter
ToolTipToRichTextFilter(int size_threshold, QObject *parent=nullptr)
Definition: guiutil.cpp:453
PlatformStyle::SingleColorIcon
QIcon SingleColorIcon(const QString &filename) const
Colorize an icon (given filename) with the icon color.
Definition: platformstyle.cpp:105
GUIUtil::SetStartOnSystemStartup
bool SetStartOnSystemStartup(bool fAutoStart)
Definition: guiutil.cpp:647
NET_INTERNAL
@ NET_INTERNAL
A set of addresses that represent the hash of a string or FQDN.
Definition: netaddress.h:66
transaction.h
GetScriptForDestination
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition: standard.cpp:310
GUIUtil::ItemDelegate::eventFilter
bool eventFilter(QObject *object, QEvent *event) override
Definition: guiutil.cpp:865
source
const char * source
Definition: rpcconsole.cpp:66
NET_MAX
@ NET_MAX
Dummy value to indicate the number of NET_* constants.
Definition: netaddress.h:69
GUIUtil::ClickableProgressBar::clicked
void clicked(const QPoint &point)
Emitted when the progressbar is clicked.
ArgsManager::GetChainName
std::string GetChainName() const
Returns the appropriate chain name from the program arguments.
Definition: system.cpp:987
ConnectionType::OUTBOUND_FULL_RELAY
@ OUTBOUND_FULL_RELAY
These are the default connections that we use to connect with the network.
SendCoinsRecipient::label
QString label
Definition: sendcoinsrecipient.h:32
serviceFlagsToStr
std::vector< std::string > serviceFlagsToStr(uint64_t flags)
Convert service flags (a bitmask of NODE_*) to human readable strings.
Definition: protocol.cpp:210
CBaseChainParams::TESTNET
static const std::string TESTNET
Definition: chainparamsbase.h:23
GUIUtil
Utility functions used by the Bitcoin Qt UI.
Definition: bitcoingui.h:59
CChainParams
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:69
GUIUtil::openDebugLogfile
void openDebugLogfile()
Definition: guiutil.cpp:420
GUIUtil::hasEntryData
bool hasEntryData(const QAbstractItemView *view, int column, int role)
Returns true if the specified field of the currently selected view entry is not empty.
Definition: guiutil.cpp:274
GUIUtil::parseBitcoinURI
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
Definition: guiutil.cpp:138
GUIUtil::formatBitcoinURI
QString formatBitcoinURI(const SendCoinsRecipient &info)
Definition: guiutil.cpp:201
GUIUtil::bringToFront
void bringToFront(QWidget *w)
Definition: guiutil.cpp:397
chainparams.h
Network
Network
A network type.
Definition: netaddress.h:45
GUIUtil::ItemDelegate::keyEscapePressed
void keyEscapePressed()
BITCOIN_CONF_FILENAME
const char *const BITCOIN_CONF_FILENAME
Definition: system.cpp:84
GUIUtil::isObscured
bool isObscured(QWidget *w)
Definition: guiutil.cpp:388
ConnectionType::MANUAL
@ MANUAL
We open manual connections to addresses that users explicitly requested via the addnode RPC or the -a...
GUIUtil::setClipboard
void setClipboard(const QString &str)
Definition: guiutil.cpp:651
BitcoinUnits::parse
static bool parse(int unit, const QString &value, CAmount *val_out)
Parse string to coin amount.
Definition: bitcoinunits.cpp:174
prefix
const char * prefix
Definition: rest.cpp:926
GUIUtil::ClickableLabel::ClickableLabel
ClickableLabel(const PlatformStyle *platform_style, QWidget *parent=nullptr)
Definition: guiutil.cpp:850
GUIUtil::GetImage
QImage GetImage(const QLabel *label)
Definition: guiutil.cpp:956
ConnectionType::INBOUND
@ INBOUND
Inbound connections are those initiated by a peer.
GUIUtil::ThemedLabel::m_pixmap_width
int m_pixmap_width
Definition: guiutil.h:255
SendCoinsRecipient
Definition: sendcoinsrecipient.h:19
NET_I2P
@ NET_I2P
I2P.
Definition: netaddress.h:59
GUIUtil::ConnectionTypeToQString
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction)
Convert enum ConnectionType to QString.
Definition: guiutil.cpp:685
GUIUtil::checkPoint
bool checkPoint(const QPoint &p, const QWidget *w)
Definition: guiutil.cpp:381
GUIUtil::ShowModalDialogAsynchronously
void ShowModalDialogAsynchronously(QDialog *dialog)
Shows a QDialog instance asynchronously, and deletes it on close.
Definition: guiutil.cpp:987
GUIUtil::dummydata
static const uint8_t dummydata[]
Definition: guiutil.cpp:103
GUIUtil::ThemedLabel
Definition: guiutil.h:241
GUIUtil::formatTimeOffset
QString formatTimeOffset(int64_t nTimeOffset)
Format a CNodeCombinedStats.nTimeOffset into a user-readable string.
Definition: guiutil.cpp:756
GUIUtil::formatDurationStr
QString formatDurationStr(std::chrono::seconds dur)
Convert seconds into a QString with days, hours, mins, secs.
Definition: guiutil.cpp:714
EncodeBase58
std::string EncodeBase58(Span< const unsigned char > input)
Why base-58 instead of standard base-64 encoding?
Definition: base58.cpp:87
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
GUIUtil::getOpenFileName
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedSuffixOut)
Get open filename, convenience wrapper for QFileDialog::getOpenFileName.
Definition: guiutil.cpp:338
GUIUtil::formatNiceTimeOffset
QString formatNiceTimeOffset(qint64 secs)
Definition: guiutil.cpp:761
CTxOut
An output of a transaction.
Definition: transaction.h:148
GUIUtil::StartOfDay
QDateTime StartOfDay(const QDate &date)
Returns the start-moment of the day in local time.
Definition: guiutil.cpp:938
fs::path
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:29
GUIUtil::ClickableLabel::clicked
void clicked(const QPoint &point)
Emitted when the label is clicked.
node.h
GUIUtil::PrintSlotException
void PrintSlotException(const std::exception *exception, const QObject *sender, const QObject *receiver)
Definition: guiutil.cpp:976
GUIUtil::ClickableLabel::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
Definition: guiutil.cpp:855
GUIUtil::LabelOutOfFocusEventFilter::eventFilter
bool eventFilter(QObject *watched, QEvent *event) override
Definition: guiutil.cpp:483
GUIUtil::ThemedLabel::changeEvent
void changeEvent(QEvent *e) override
Definition: guiutil.cpp:836
CChainParams::Base58Prefix
const std::vector< unsigned char > & Base58Prefix(Base58Type type) const
Definition: chainparams.h:115
time.h
ArgsManager::GetArg
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: system.cpp:588
GUIUtil::PolishProgressDialog
void PolishProgressDialog(QProgressDialog *dialog)
Definition: guiutil.cpp:875
LogPrintf
#define LogPrintf(...)
Definition: logging.h:188
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
QValidatedLineEdit
Line edit that can be marked as "invalid" to show input validation feedback.
Definition: qvalidatedlineedit.h:13
standard.h
GUIUtil::AddButtonShortcut
void AddButtonShortcut(QAbstractButton *button, const QKeySequence &shortcut)
Connects an additional shortcut to a QAbstractButton.
Definition: guiutil.cpp:133
guiutil.h
BitcoinAddressEntryValidator
Base58 entry widget validator, checks for valid characters and removes some whitespace.
Definition: bitcoinaddressvalidator.h:13
GUIUtil::formatBytes
QString formatBytes(uint64_t bytes)
Definition: guiutil.cpp:798
GUIUtil::formatServicesStr
QString formatServicesStr(quint64 mask)
Format CNodeStats.nServices bitmask into a user-readable string.
Definition: guiutil.cpp:735
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
ConnectionType::FEELER
@ FEELER
Feeler connections are short-lived connections made to check that a node is alive.
script.h
GUIUtil::fixedPitchFont
QFont fixedPitchFont(bool use_embedded_font)
Definition: guiutil.cpp:94
gArgs
ArgsManager gArgs
Definition: system.cpp:87
GUIUtil::MakeHtmlLink
QString MakeHtmlLink(const QString &source, const QString &link)
Replaces a plain text link with an HTML tagged one.
Definition: guiutil.cpp:969
GUIUtil::getDefaultDataDirectory
QString getDefaultDataDirectory()
Determine default data directory for operating system.
Definition: guiutil.cpp:287
interfaces::Node
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:68
qvalidatedlineedit.h
GUIUtil::HasPixmap
bool HasPixmap(const QLabel *label)
Returns true if pixmap has been set.
Definition: guiutil.cpp:947
CBaseChainParams::MAIN
static const std::string MAIN
Chain name strings.
Definition: chainparamsbase.h:22
GUIUtil::ToolTipToRichTextFilter::eventFilter
bool eventFilter(QObject *obj, QEvent *evt) override
Definition: guiutil.cpp:460
SUCCEEDED
@ SUCCEEDED
Succeeded.
Definition: netbase.cpp:266
GUIUtil::getSaveFileName
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedSuffixOut)
Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix when ...
Definition: guiutil.cpp:292
platformstyle.h
GUIUtil::ThemedLabel::m_pixmap_height
int m_pixmap_height
Definition: guiutil.h:256
system.h
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
GUIUtil::LabelOutOfFocusEventFilter::LabelOutOfFocusEventFilter
LabelOutOfFocusEventFilter(QObject *parent)
Definition: guiutil.cpp:478
count_microseconds
constexpr int64_t count_microseconds(std::chrono::microseconds t)
Definition: time.h:31
GUIUtil::GetStartOnSystemStartup
bool GetStartOnSystemStartup()
Definition: guiutil.cpp:646
GUIUtil::ThemedLabel::m_image_filename
QString m_image_filename
Definition: guiutil.h:254
GUIUtil::DummyAddress
static std::string DummyAddress(const CChainParams &params)
Definition: guiutil.cpp:106
GUIUtil::HtmlEscape
QString HtmlEscape(const QString &str, bool fMultiLine)
Definition: guiutil.cpp:239
bitcoinaddressvalidator.h
GUIUtil::copyEntryData
void copyEntryData(const QAbstractItemView *view, int column, int role)
Copy a field of the currently selected entry of a view to the clipboard.
Definition: guiutil.cpp:254
GetConfigFile
fs::path GetConfigFile(const std::string &confPath)
Definition: system.cpp:817
GUIUtil::ThemedLabel::ThemedLabel
ThemedLabel(const PlatformStyle *platform_style, QWidget *parent=nullptr)
Definition: guiutil.cpp:822
ConnectionType::ADDR_FETCH
@ ADDR_FETCH
AddrFetch connections are short lived connections used to solicit addresses from peers.
SendCoinsRecipient::address
QString address
Definition: sendcoinsrecipient.h:31
NET_ONION
@ NET_ONION
TOR (v2 or v3)
Definition: netaddress.h:56
fs::create_directories
static bool create_directories(const std::filesystem::path &p)
Create directory (and if necessary its parents), unless the leaf directory already exists or is a sym...
Definition: fs.h:150
GUIUtil::ToolTipToRichTextFilter::size_threshold
int size_threshold
Definition: guiutil.h:190
DecodeDestination
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
Definition: key_io.cpp:281
GUIUtil::blockingGUIThreadConnection
Qt::ConnectionType blockingGUIThreadConnection()
Get connection type to call object slot in GUI thread with invokeMethod.
Definition: guiutil.cpp:369
GUIUtil::NetworkToQString
QString NetworkToQString(Network net)
Convert enum Network to QString.
Definition: guiutil.cpp:670
GUIUtil::LogQtInfo
void LogQtInfo()
Writes to debug.log short info about the used Qt and the host system.
Definition: guiutil.cpp:898
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:561
count_seconds
constexpr int64_t count_seconds(std::chrono::seconds t)
Helper to count the seconds of a duration.
Definition: time.h:29
IsDust
bool IsDust(const CTxOut &txout, const CFeeRate &dustRelayFeeIn)
Definition: policy.cpp:53
CChainParams::PUBKEY_ADDRESS
@ PUBKEY_ADDRESS
Definition: chainparams.h:73
bitcoinunits.h
node
Definition: init.h:22
IsValidDestinationString
bool IsValidDestinationString(const std::string &str, const CChainParams &params)
Definition: key_io.cpp:292
ForceActivation
void ForceActivation()
Force application activation on macOS.
Definition: macdockiconhandler.mm:50
GUIUtil::ClickableProgressBar::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
Definition: guiutil.cpp:860
NET_IPV6
@ NET_IPV6
IPv6.
Definition: netaddress.h:53
GUIUtil::calculateIdealFontSize
qreal calculateIdealFontSize(int width, const QString &text, QFont font, qreal minPointSize, qreal font_size)
Definition: guiutil.cpp:810
GUIUtil::isDust
bool isDust(interfaces::Node &node, const QString &address, const CAmount &amount)
Definition: guiutil.cpp:231
base58.h
GUIUtil::TextWidth
int TextWidth(const QFontMetrics &fm, const QString &text)
Returns the distance in pixels appropriate for drawing a subsequent character after text.
Definition: guiutil.cpp:889
GUIUtil::dateTimeStr
QString dateTimeStr(const QDateTime &date)
Definition: guiutil.cpp:84
ConnectionType::BLOCK_RELAY
@ BLOCK_RELAY
We use block-relay-only connections to help prevent against partition attacks.
GUIUtil::handleCloseWindowShortcut
void handleCloseWindowShortcut(QWidget *w)
Definition: guiutil.cpp:415
PrintExceptionContinue
void PrintExceptionContinue(const std::exception *pex, const char *pszThread)
Definition: system.cpp:779
GUIUtil::getEntryData
QList< QModelIndex > getEntryData(const QAbstractItemView *view, int column)
Return a field of the currently selected entry as a QString.
Definition: guiutil.cpp:267
NET_CJDNS
@ NET_CJDNS
CJDNS.
Definition: netaddress.h:62
GUIUtil::ThemedLabel::setThemedPixmap
void setThemedPixmap(const QString &image_filename, int width, int height)
Definition: guiutil.cpp:828
GUIUtil::LoadFont
void LoadFont(const QString &file_name)
Loads the font from the file specified by file_name, aborts if it fails.
Definition: guiutil.cpp:281
PlatformStyle
Definition: platformstyle.h:13
GUIUtil::formatPingTime
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.
Definition: guiutil.cpp:749
GUIUtil::setupAddressWidget
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
Definition: guiutil.cpp:120
GUIUtil::ThemedLabel::m_platform_style
const PlatformStyle * m_platform_style
Definition: guiutil.h:253
ConnectionType
ConnectionType
Different types of connections to a peer.
Definition: net.h:121
MAX_PATH
#define MAX_PATH
Definition: compat.h:71
sendcoinsrecipient.h
GUIUtil::ThemedLabel::updateThemedPixmap
void updateThemedPixmap()
Definition: guiutil.cpp:845
BitcoinUnits::BTC
@ BTC
Definition: bitcoinunits.h:43
BitcoinUnits::format
static QString format(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD, bool justify=false)
Format as string.
Definition: bitcoinunits.cpp:103
SendCoinsRecipient::message
QString message
Definition: sendcoinsrecipient.h:35