From 9c1db5ff8bc2f08a112fa55d8e4e7129cec0b14d Mon Sep 17 00:00:00 2001 From: fekt Date: Tue, 18 Oct 2022 15:32:18 -0400 Subject: [PATCH] getrescaninfo and other tweaks --- res/css/midnight.css | 7 +- src/bannedpeerstablemodel.cpp | 6 ++ src/bannedpeerstablemodel.h | 1 + src/connection.cpp | 101 +++++++++++++-------------- src/mainwindow.cpp | 126 +++++++++++++++++++--------------- src/qrcode.ui | 25 ++++++- src/rpc.cpp | 10 ++- src/rpc.h | 2 + src/settings.cpp | 2 +- 9 files changed, 167 insertions(+), 113 deletions(-) diff --git a/res/css/midnight.css b/res/css/midnight.css index f48a1b4..07edb51 100644 --- a/res/css/midnight.css +++ b/res/css/midnight.css @@ -23,6 +23,7 @@ QPushButton:hover { background: #222; } +/* QLineEdit, QRadioButton::indicator::unchecked, QCheckBox::indicator::unchecked { background: #222; border: 1px solid #333; @@ -35,11 +36,13 @@ font-size: 12px; QLineEdit:focus { border: 1px solid #9d8400; -} +}*/ +/* QWidget QLabel { font-size: 11pt; } +*/ QWidget QCheckBox { font-weight: bold; @@ -74,7 +77,7 @@ background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #333, st color:#fff; min-height:25px; font-weight:bold; -font-size:12px; +font-size:11px; outline:0; border:1px ridge #222; padding: 2px 5px; diff --git a/src/bannedpeerstablemodel.cpp b/src/bannedpeerstablemodel.cpp index 0c55e12..58f60ca 100644 --- a/src/bannedpeerstablemodel.cpp +++ b/src/bannedpeerstablemodel.cpp @@ -60,6 +60,7 @@ int BannedPeersTableModel::columnCount(const QModelIndex&) const case 0: return dat.address; case 1: return dat.subnet; case 2: return QDateTime::fromSecsSinceEpoch(dat.banned_until).toLocalTime().toString(); + case 3: return "AS" + QString::number(dat.asn); } } @@ -69,6 +70,7 @@ int BannedPeersTableModel::columnCount(const QModelIndex&) const case 0: return "Network Address"; case 1: return "Subnet Mask"; case 2: return "Banned Until " + QDateTime::fromSecsSinceEpoch(dat.banned_until).toUTC().toString(); + case 3: return "Autonomous System Number"; } } @@ -120,6 +122,10 @@ QString BannedPeersTableModel::getAddress(int row) const { return modeldata->at(row).address.trimmed(); } +qint64 BannedPeersTableModel::getASN(int row) const { + return modeldata->at(row).asn; +} + QString BannedPeersTableModel::getSubnet(int row) const { return modeldata->at(row).subnet; } diff --git a/src/bannedpeerstablemodel.h b/src/bannedpeerstablemodel.h index a317469..d6d046d 100644 --- a/src/bannedpeerstablemodel.h +++ b/src/bannedpeerstablemodel.h @@ -15,6 +15,7 @@ public: QString getSubnet(int row) const; QString getAddress(int row) const; + qint64 getASN(int row) const; qint64 getBannedUntil(int row) const; int rowCount(const QModelIndex &parent) const; diff --git a/src/connection.cpp b/src/connection.cpp index a09b70b..e66c539 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -68,12 +68,12 @@ void ConnectionLoader::doAutoConnect(bool tryEhushdStart) { } else { if (config->hushDaemon) { // hushd is configured to run as a daemon, so we must wait for a few seconds - // to let it start up. + // to let it start up. main->logger->write("hushd is daemon=1. Waiting for it to start up"); this->showInformation(QObject::tr("hushd is set to run as daemon"), QObject::tr("Waiting for hushd")); QTimer::singleShot(5000, [=]() { doAutoConnect(/* don't attempt to start ehushd */ false); }); } else { - // Something is wrong. + // Something is wrong. // We're going to attempt to connect to the one in the background one last time // and see if that works, else throw an error main->logger->write("Unknown problem while trying to start hushd!"); @@ -81,7 +81,7 @@ void ConnectionLoader::doAutoConnect(bool tryEhushdStart) { } } } else { - // We tried to start ehushd previously, and it didn't work. So, show the error. + // We tried to start ehushd previously, and it didn't work. So, show the error. main->logger->write("Couldn't start embedded hushd for unknown reason"); QString explanation; if (config->hushDaemon) { @@ -90,18 +90,18 @@ void ConnectionLoader::doAutoConnect(bool tryEhushdStart) { "Please remove the following line from your HUSH3.conf and restart SilentDragon\n" "daemon=1"); } else { - explanation = QString() % QObject::tr("Couldn't start the embedded hushd.\n\n" - "Please try restarting.\n\nIf you previously started hushd with custom arguments, you might need to reset HUSH3.conf.\n\n" - "If all else fails, please run hushd manually.") % + explanation = QString() % QObject::tr("Couldn't start the embedded hushd.\n\n" + "Please try restarting.\n\nIf you previously started hushd with custom arguments, you might need to reset HUSH3.conf.\n\n" + "If all else fails, please run hushd manually.") % (ehushd ? QObject::tr("The process returned") + ":\n\n" % ehushd->errorString() : QString("")); } - + this->showError(explanation); - } + } } else { // HUSH3.conf exists, there's no connection, and the user asked us not to start hushd. Error! main->logger->write("Not using embedded and couldn't connect to hushd"); - QString explanation = QString() % QObject::tr("Couldn't connect to hushd configured in HUSH3.conf.\n\n" + QString explanation = QString() % QObject::tr("Couldn't connect to hushd configured in HUSH3.conf.\n\n" "Not starting embedded hushd because --no-embedded was passed"); this->showError(explanation); } @@ -114,7 +114,7 @@ void ConnectionLoader::doAutoConnect(bool tryEhushdStart) { // Fall back to manual connect doManualConnect(); } - } + } } QString randomPassword() { @@ -136,7 +136,7 @@ QString randomPassword() { /** * This will create a new HUSH3.conf and download params if they cannot be found - */ + */ void ConnectionLoader::createHushConf() { main->logger->write(__func__); @@ -260,7 +260,7 @@ void ConnectionLoader::doNextDownload(std::function cb) { } // The downloaded file is written to a new name, and then renamed when the operation completes. - currentOutput = new QFile(QDir(paramsDir).filePath(filename + ".part")); + currentOutput = new QFile(QDir(paramsDir).filePath(filename + ".part")); if (!currentOutput->open(QIODevice::WriteOnly)) { main->logger->write("Couldn't open " + currentOutput->fileName() + " for writing"); @@ -268,12 +268,12 @@ void ConnectionLoader::doNextDownload(std::function cb) { } main->logger->write("Downloading to " + filename); qDebug() << "Downloading " << url << " to " << filename; - + QNetworkRequest request(url); request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); currentDownload = client->get(request); downloadTime.start(); - + // Download Progress QObject::connect(currentDownload, &QNetworkReply::downloadProgress, [=] (auto done, auto total) { // calculate the download speed @@ -293,7 +293,7 @@ void ConnectionLoader::doNextDownload(std::function cb) { QObject::tr("Downloading ") % filename % (filesRemaining > 1 ? " ( +" % QString::number(filesRemaining) % QObject::tr(" more remaining )") : QString("")), QString::number(done/1024/1024, 'f', 0) % QObject::tr("MB of ") % QString::number(total/1024/1024, 'f', 0) + QObject::tr("MB at ") % QString::number(speed, 'f', 2) % unit); }); - + // Download Finished QObject::connect(currentDownload, &QNetworkReply::finished, [=] () { // Rename file @@ -306,22 +306,22 @@ void ConnectionLoader::doNextDownload(std::function cb) { if (currentDownload->error()) { main->logger->write("Downloading " + filename + " failed"); - this->showError(QObject::tr("Downloading ") + filename + QObject::tr(" failed. Please check the help site for more info")); + this->showError(QObject::tr("Downloading ") + filename + QObject::tr(" failed. Please check the help site for more info")); } else { doNextDownload(cb); } }); - // Download new data available. + // Download new data available. QObject::connect(currentDownload, &QNetworkReply::readyRead, [=] () { currentOutput->write(currentDownload->readAll()); - }); + }); } bool ConnectionLoader::startEmbeddedHushd() { - if (!Settings::getInstance()->useEmbedded()) + if (!Settings::getInstance()->useEmbedded()) return false; - + main->logger->write("Trying to start embedded hushd"); // Static because it needs to survive even after this method returns. @@ -330,13 +330,13 @@ bool ConnectionLoader::startEmbeddedHushd() { if (ehushd != nullptr) { if (ehushd->state() == QProcess::NotRunning) { if (!processStdErrOutput.isEmpty()) { - QMessageBox::critical(main, QObject::tr("hushd error"), "hushd said: " + processStdErrOutput, + QMessageBox::critical(main, QObject::tr("hushd error"), "hushd said: " + processStdErrOutput, QMessageBox::Ok); } return false; } else { return true; - } + } } QDir appPath(QCoreApplication::applicationDirPath()); @@ -346,7 +346,7 @@ bool ConnectionLoader::startEmbeddedHushd() { #else auto hushdProgram = appPath.absoluteFilePath("hushd"); #endif - + //if (!QFile(hushdProgram).exists()) { if (!QFile::exists(hushdProgram)) { qDebug() << "Can't find hushd at " << hushdProgram; @@ -435,7 +435,7 @@ void ConnectionLoader::doManualConnect() { auto connection = makeConnection(config); refreshHushdState(connection, [=] () { QString explanation = QString() - % QObject::tr("Could not connect to hushd configured in settings.\n\n" + % QObject::tr("Could not connect to hushd configured in settings.\n\n" "Please set the host/port and user/password in the Edit->Settings menu."); showError(explanation); @@ -448,7 +448,7 @@ void ConnectionLoader::doManualConnect() { void ConnectionLoader::doRPCSetConnection(Connection* conn) { rpc->setEHushd(ehushd); rpc->setConnection(conn); - + d->accept(); delete this; @@ -456,7 +456,7 @@ void ConnectionLoader::doRPCSetConnection(Connection* conn) { Connection* ConnectionLoader::makeConnection(std::shared_ptr config) { QNetworkAccessManager* client = new QNetworkAccessManager(main); - + QUrl myurl; myurl.setScheme("http"); myurl.setHost(config.get()->host); @@ -465,10 +465,10 @@ Connection* ConnectionLoader::makeConnection(std::shared_ptr c QNetworkRequest* request = new QNetworkRequest(); request->setUrl(myurl); request->setHeader(QNetworkRequest::ContentTypeHeader, "text/plain"); - + QString userpass = config.get()->rpcuser % ":" % config.get()->rpcpassword; QString headerData = "Basic " + userpass.toLocal8Bit().toBase64(); - request->setRawHeader("Authorization", headerData.toLocal8Bit()); + request->setRawHeader("Authorization", headerData.toLocal8Bit()); return new Connection(main, client, request, config); } @@ -489,20 +489,20 @@ void ConnectionLoader::refreshHushdState(Connection* connection, std::functiondoRPCSetConnection(connection); }); }, [=] (QNetworkReply* reply, const QJsonValue &res) { - // Failed, see what it is. + // Failed, see what it is. auto err = reply->error(); //qDebug() << err << res; - if (err == QNetworkReply::NetworkError::ConnectionRefusedError) { + if (err == QNetworkReply::NetworkError::ConnectionRefusedError) { refused(); } else if (err == QNetworkReply::NetworkError::AuthenticationRequiredError) { main->logger->write("Authentication failed"); - QString explanation = QString() % + QString explanation = QString() % QObject::tr("Authentication failed. The username / password you specified was " "not accepted by hushd. Try changing it in the Edit->Settings menu"); this->showError(explanation); - } else if (err == QNetworkReply::NetworkError::InternalServerError && + } else if (err == QNetworkReply::NetworkError::InternalServerError && !res.isNull()) { // The server is loading, so just poll until it succeeds QString status = res["error"].toObject()["message"].toString(); @@ -526,9 +526,10 @@ void ConnectionLoader::refreshHushdState(Connection* connection, std::functionsetEHushd(nullptr); rpc->noConnection(); @@ -659,8 +660,8 @@ bool ConnectionLoader::verifyParams() { /** * Try to automatically detect a HUSH3/HUSH3.conf file in the correct location and load parameters - */ -std::shared_ptr ConnectionLoader::autoDetectHushConf() { + */ +std::shared_ptr ConnectionLoader::autoDetectHushConf() { auto confLocation = locateHushConfFile(); if (confLocation.isNull()) { @@ -682,7 +683,7 @@ std::shared_ptr ConnectionLoader::autoDetectHushConf() { hushconf->usingHushConf = true; hushconf->hushDir = QFileInfo(confLocation).absoluteDir().absolutePath(); hushconf->hushDaemon = false; - + Settings::getInstance()->setUsingHushConf(confLocation); while (!in.atEnd()) { @@ -733,21 +734,21 @@ std::shared_ptr ConnectionLoader::autoDetectHushConf() { hushconf->rpcuser, hushconf->rpcpassword); - // In addition to the HUSH3/HUSH3.conf file, also double check the params. + // In addition to the HUSH3/HUSH3.conf file, also double check the params. return std::shared_ptr(hushconf); } // Load connection settings from the UI, which indicates an unknown, external hushd std::shared_ptr ConnectionLoader::loadFromSettings() { - // Load from the QT Settings. + // Load from the QT Settings. QSettings s; - + auto host = s.value("connection/host").toString(); auto port = s.value("connection/port").toString(); auto username = s.value("connection/rpcuser").toString(); auto password = s.value("connection/rpcpassword").toString(); - + if (username.isEmpty() || password.isEmpty()) return nullptr; @@ -762,8 +763,8 @@ std::shared_ptr ConnectionLoader::loadFromSettings() { /*********************************************************************************** * Connection Class - ************************************************************************************/ -Connection::Connection(MainWindow* m, QNetworkAccessManager* c, QNetworkRequest* r, + ************************************************************************************/ +Connection::Connection(MainWindow* m, QNetworkAccessManager* c, QNetworkRequest* r, std::shared_ptr conf) { this->restclient = c; this->request = r; @@ -796,7 +797,7 @@ void Connection::doRPC(const QJsonValue& payload, const std::functionreadAll()); QJsonValue parsed; @@ -808,13 +809,13 @@ void Connection::doRPC(const QJsonValue& payload, const std::functionerror() != QNetworkReply::NoError) { ne(reply, parsed); return; - } - + } + if (parsed.isNull()) { ne(reply, "Unknown error"); } - - cb(parsed["result"]); + + cb(parsed["result"]); }); } @@ -850,7 +851,7 @@ void Connection::showTxError(const QString& error) { /** * Prevent all future calls from going through - */ + */ void Connection::shutdown() { shutdownInProgress = true; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 74806c4..ac1fb68 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -115,6 +115,7 @@ MainWindow::MainWindow(QWidget *parent) : // Initialize to the balances tab ui->tabWidget->setCurrentIndex(0); + setupSendTab(); setupTransactionsTab(); setupReceiveTab(); @@ -510,7 +511,7 @@ void MainWindow::setupSettingsModal() { } settings.chkzindex->setChecked(isUsingZindex); if (rpc->getEHushD() == nullptr) { - settings.chkzindex->setEnabled(false); + settings.chkzindex->setEnabled(false); } // Connection Settings @@ -530,7 +531,7 @@ void MainWindow::setupSettingsModal() { settings.hostname->setEnabled(true); settings.port->setEnabled(true); settings.rpcuser->setEnabled(true); - settings.rpcpassword->setEnabled(true); + settings.rpcpassword->setEnabled(true); } // Load current values into the dialog @@ -715,21 +716,21 @@ void MainWindow::setupSettingsModal() { if (!rpc->getConnection()->config->consolidation.isEmpty()==false) { if (settings.chkConso->isChecked()) { Settings::addToHushConf(hushConfLocation, "consolidation=1"); - showRestartInfo = true; + showRestartInfo = true; } } if (!rpc->getConnection()->config->consolidation.isEmpty()) { if (settings.chkConso->isChecked() == false) { Settings::removeFromHushConf(hushConfLocation, "consolidation"); - showRestartInfo = true; + showRestartInfo = true; } } - + if (!rpc->getConnection()->config->deletetx.isEmpty() == false) { if (settings.chkDeletetx->isChecked()) { Settings::addToHushConf(hushConfLocation, "deletetx=1"); - showRestartInfo = true; + showRestartInfo = true; } } @@ -739,12 +740,12 @@ void MainWindow::setupSettingsModal() { showRestartInfo = true; } } - + if (!rpc->getConnection()->config->zindex.isEmpty() == false) { if (settings.chkzindex->isChecked()) { Settings::addToHushConf(hushConfLocation, "zindex=1"); Settings::addToHushConf(hushConfLocation, "reindex=1"); - showReindexInfo = true; + showReindexInfo = true; } } @@ -752,10 +753,10 @@ void MainWindow::setupSettingsModal() { if (settings.chkzindex->isChecked() == false) { Settings::removeFromHushConf(hushConfLocation, "zindex"); Settings::addToHushConf(hushConfLocation, "reindex=1"); - showReindexInfo = true; + showReindexInfo = true; } } - + if (showRestartInfo) { auto desc = tr("SilentDragon needs to restart to rescan,reindex,consolidation or deletetx. SilentDragon will now close, please restart SilentDragon to continue"); @@ -1148,8 +1149,30 @@ void MainWindow::getQRCode(QString addr) { // Display QR Code for address qrui.qrcodeDisplayAddr->setQrcodeString(addr); + // Set text/tip + qrui.saveQRCodeBtn->setText(tr("Save")); + qrui.saveQRCodeBtn->setToolTip(tr("Save QR Code to file")); + auto isDialogAlive = std::make_shared(true); + // Connect and handle Save button + QObject::connect(qrui.saveQRCodeBtn, &QPushButton::clicked, [&] () { + qDebug() << "Save QR Code clicked"; + QString fileName = QFileDialog::getSaveFileName(this, + tr("Save QR Code to file"), "", + tr("Portable Network Graphics (*.png);;All Files (*)")); + + if (fileName.isEmpty()) + return; + else { + QFile file(fileName); + // TODO: fix this. Saves as black image instead of QR code + qrui.qrcodeDisplayAddr->grab().save(fileName, "png", -1); + statusBar()->showMessage(tr("QR code saved"), 3000); + d.close(); + } + }); + d.exec(); *isDialogAlive = false; } @@ -1336,11 +1359,11 @@ void MainWindow::setupBalancesTab() { qDebug() << "ShieldCoinbase reply=" << reply; // By default we shield 50 blocks at a time if(remainingUTXOs > 0) { - //TODO: more utxos to shield + //TODO: more utxos to shield } ui->statusBar->showMessage(tr("Shielded") + shieldingValue + " HUSH in Mining funds to " + addr + " in opid " + opid, 3 * 1000); }, [=](QString errStr) { - //error("", errStr); + //error("", errStr); qDebug() << "z_shieldcoinbase pooped:" << errStr; if(errStr == "Could not find any coinbase funds to shield.") { ui->statusBar->showMessage("No mining funds found to shield!"); @@ -1450,8 +1473,10 @@ void MainWindow::setupPeersTab() { auto bannedPeerModel = dynamic_cast(ui->bannedPeersTable->model()); QString addr = bannedPeerModel->getAddress(index.row()); + qint64 asn = bannedPeerModel->getASN(index.row()); QString ip = peer2ip(addr); QString subnet = bannedPeerModel->getSubnet(index.row()); + QString as = QString::number(asn); //qint64 banned_until = bannedPeerModel->getBannedUntil(index.row()); if(!ip.isEmpty()) { @@ -1471,6 +1496,14 @@ void MainWindow::setupPeersTab() { }); } + if(!as.isEmpty()) { + menu.addAction(tr("View ASN on bgpview.io (3rd party service)"), [=] () { + QString url = "https://bgpview.io/asn/" + as; + qDebug() << "opening " << url; + QDesktopServices::openUrl(QUrl(url)); + }); + } + if(!ip.isEmpty()) { menu.addAction(tr("Unban this peer"), [=] () { ui->statusBar->showMessage(tr("Unbanning peer...")); @@ -1585,7 +1618,7 @@ void MainWindow::setupPeersTab() { #elif defined(Q_OS_DARWIN) debuglog = "~/Library/Application Support/Komodo/HUSH3/debug.log"; #elif defined(Q_OS_WIN64) - // "C:/Users//AppData/Roaming/", + // "C:/Users//AppData/Roaming/", // TODO: get current username debuglog = "C:/Users//AppData/Roaming/Komodo/HUSH3/debug.log"; #else @@ -2190,7 +2223,7 @@ void MainWindow::rescanButtonClicked(int number) { if (dialog.exec() == QDialog::Accepted) { // Show message in status bar - ui->statusBar->showMessage(tr("Rescanning..."), 3 * 1000); + ui->statusBar->showMessage(tr("Rescanning...")); // Close settings QWidget *modalWidget = QApplication::activeModalWidget(); @@ -2204,50 +2237,33 @@ void MainWindow::rescanButtonClicked(int number) { // Call rescan RPC rpc->rescan(rescanHeight, [=] (QJsonValue response){ qDebug() << "rescanning finished" << response; + ui->statusBar->showMessage(tr("Rescanning finished"), 3000); }); - // TODO: Display progress somewhere by reading debug.log - #ifdef Q_OS_LINUX - auto debugLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, ".hush/HUSH3/debug.log"); - if(!QFile(debugLocation).exists()) { - // legacy location - debugLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, ".komodo/HUSH3/debug.log"); - } - #elif defined(Q_OS_DARWIN) - auto debugLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, "Library/Application Support/Hush/HUSH3/debug.log"); - if(!QFile(debugLocation).exists()) { - // legacy location - debugLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, "Library/Application Support/Komodo/HUSH3/debug.log"); - } - #else - auto debugLocation = QStandardPaths::locate(QStandardPaths::AppDataLocation, "../../Hush/HUSH3/debug.log"); - if(!QFile(debugLocation).exists()) { - // legacy location - debugLocation = QStandardPaths::locate(QStandardPaths::AppDataLocation, "../../Komodo/HUSH3/debug.log"); - } - #endif - - if(QFile(debugLocation).exists()){ - qDebug() << "Found debug.log at "+ debugLocation; - QFile debugLog(debugLocation); - - if(debugLog.open(QIODevice::ReadOnly)){ - debugLog.seek(debugLog.size()-1); - int count = 0; - int lines = 25; - while ( (count < lines) && (debugLog.pos() > 0) ) - { - QString ch = debugLog.read(1); - debugLog.seek(debugLog.pos()-2); - if (ch == "\n") - count++; + // Get rescan info + QTimer *rescanTimer = new QTimer(this); + QObject::connect(rescanTimer, &QTimer::timeout, [=]() { + rpc->getRescanInfo([=] (QJsonValue response){ + + + auto rescanning = response.toObject().value("rescanning").toBool(); + auto rescan_progress = response.toObject().value("rescan_progress").toString(); + auto rescan_start_height = (qint64)response.toObject().value("rescan_start_height").toInt(); + auto rescan_height = (qint64)response.toObject().value("rescan_height").toInt(); + double percent = QString(rescan_progress).toDouble() * 100; + qDebug() << "getrescaninfo" << rescanning << " " << percent << " " << rescan_start_height << " " << rescan_height; + + if(rescanning){ + qDebug() << "Rescanning..."; + ui->statusBar->showMessage(tr("Rescanning... ") + QString::number(percent)+ "% " + QObject::tr("at height") + " " + QString::number(rescan_height)); } - qDebug() << "debug.log =" + debugLog.readAll(); - debugLog.close(); - }else{ - qDebug() <<"couldn't open debug.log for reading"; - } - } + else{ + qDebug() << "rescanTimer Stop"; + rescanTimer->stop(); + } + }); + }); + rescanTimer->start(1000); } } diff --git a/src/qrcode.ui b/src/qrcode.ui index 81f7eaf..c34fde2 100644 --- a/src/qrcode.ui +++ b/src/qrcode.ui @@ -7,17 +7,23 @@ 0 0 320 - 320 + 344 + + + 0 + 0 + + QR Code - + QLayout::SetFixedSize - + @@ -57,6 +63,19 @@ + + + + + 0 + 0 + + + + Save + + + diff --git a/src/rpc.cpp b/src/rpc.cpp index 3ec4998..2eef349 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -167,6 +167,12 @@ void RPC::rescan(qint64 height, const std::function& cb) { conn->doRPCWithDefaultErrorHandling(makePayload(method, height), cb); } +// get rescan info +void RPC::getRescanInfo(const std::function& cb){ + QString method = "getrescaninfo"; + conn->doRPCWithDefaultErrorHandling(makePayload(method), cb); +} + // add/remove a banned node. ip can include an optional netmask void RPC::setban(QString ip, QString command, const std::function& cb) { QString method = "setban"; @@ -651,7 +657,6 @@ void RPC::refresh(bool force) { getInfoThenRefresh(force); } - void RPC::getInfoThenRefresh(bool force) { //qDebug() << "getinfo"; if (conn == nullptr) @@ -982,11 +987,12 @@ void RPC::refreshPeers() { QList peerdata; for (const auto& it : reply.toArray()) { auto addr = it.toObject()["address"].toString(); + auto asn = (qint64)it.toObject()["mapped_as"].toInt(); auto bantime = (qint64)it.toObject()["banned_until"].toInt(); auto parts = addr.split("/"); auto ip = parts[0]; auto subnet = parts[1]; - BannedPeerItem peer { ip, subnet, bantime }; + BannedPeerItem peer { ip, subnet, bantime, asn }; qDebug() << "Adding banned peer with address=" << addr; peerdata.push_back(peer); } diff --git a/src/rpc.h b/src/rpc.h index 1349b36..01a73b3 100755 --- a/src/rpc.h +++ b/src/rpc.h @@ -27,6 +27,7 @@ struct BannedPeerItem { QString address; QString subnet; qint64 banned_until; + qint64 asn; }; struct PeerItem { @@ -118,6 +119,7 @@ public: Connection* getConnection() { return conn; } void rescan(qint64 height, const std::function& cb); + void getRescanInfo(const std::function& cb); private: void refreshBalances(); diff --git a/src/settings.cpp b/src/settings.cpp index 95f2fba..2cf5524 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -258,7 +258,7 @@ void Settings::setAllowCustomFees(bool allow) { QString Settings::get_theme_name() { // Load from the QT Settings. QString theme_name = QSettings().value("options/theme_name", false).toString(); - qDebug() << __func__ << ": theme_name=" << theme_name; + //qDebug() << __func__ << ": theme_name=" << theme_name; return theme_name; }