diff --git a/src/connection.cpp b/src/connection.cpp index e616f95..2f5ea90 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -43,6 +43,7 @@ void ConnectionLoader::doAutoConnect(bool tryEzcashdStart) { // Initialize the library main->logger->write(QObject::tr("Attempting to initialize")); litelib_initialze(config->dangerous, config->server.toStdString().c_str()); + auto connection = makeConnection(config); // After the lib is initialized, try to do get info @@ -87,7 +88,6 @@ void ConnectionLoader::showInformation(QString info, QString detail) { * Show error will close the loading dialog and show an error. */ void ConnectionLoader::showError(QString explanation) { - rpc->setEZcashd(nullptr); rpc->noConnection(); QMessageBox::critical(main, QObject::tr("Connection Error"), explanation, QMessageBox::Ok); diff --git a/src/controller.cpp b/src/controller.cpp index 3382599..0e5272b 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -70,13 +70,6 @@ Controller::~Controller() { delete zrpc; } -void Controller::setEZcashd(QProcess* p) { - ezcashd = p; - - if (ezcashd && ui->tabWidget->widget(4) == nullptr) { - ui->tabWidget->addTab(main->zcashdtab, "zcashd"); - } -} // Called when a connection to zcashd is available. void Controller::setConnection(Connection* c) { @@ -209,10 +202,13 @@ void Controller::getInfoThenRefresh(bool force) { static bool prevCallSucceeded = false; zrpc->fetchInfo([=] (const json& reply) { + qDebug() << "Info updated"; + prevCallSucceeded = true; + // Testnet? - if (!reply["testnet"].is_null()) { - Settings::getInstance()->setTestnet(reply["testnet"].get()); + if (!reply["chain_name"].is_null()) { + Settings::getInstance()->setTestnet(reply["chain_name"].get() == "test"); }; // Recurring pamynets are testnet only @@ -224,8 +220,9 @@ void Controller::getInfoThenRefresh(bool force) { main->statusIcon->setPixmap(i.pixmap(16, 16)); static int lastBlock = 0; - int curBlock = reply["blocks"].get(); - int version = reply["version"].get(); + int curBlock = reply["latest_block_height"].get(); + //int version = reply["version"].get(); + int version = 1; Settings::getInstance()->setZcashdVersion(version); // See if recurring payments needs anything @@ -241,23 +238,6 @@ void Controller::getInfoThenRefresh(bool force) { refreshMigration(); // Sapling turnstile migration status. } - int connections = reply["connections"].get(); - Settings::getInstance()->setPeers(connections); - - if (connections == 0) { - // If there are no peers connected, then the internet is probably off or something else is wrong. - QIcon i = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning); - main->statusIcon->setPixmap(i.pixmap(16, 16)); - } - - // Get network sol/s - if (ezcashd) { - zrpc->fetchNetSolOps([=] (qint64 solrate) { - ui->numconnections->setText(QString::number(connections)); - ui->solrate->setText(QString::number(solrate) % " Sol/s"); - }); - } - // Call to see if the blockchain is syncing. zrpc->fetchBlockchainInfo([=](const json& reply) { auto progress = reply["verificationprogress"].get(); @@ -304,12 +284,8 @@ void Controller::getInfoThenRefresh(bool force) { auto zecPrice = Settings::getInstance()->getUSDFromZecAmount(1); QString tooltip; - if (connections > 0) { - tooltip = QObject::tr("Connected to zcashd"); - } - else { - tooltip = QObject::tr("zcashd has no peer connections"); - } + tooltip = QObject::tr("Connected to zcashd"); + tooltip = tooltip % "(v " % QString::number(Settings::getInstance()->getZcashdVersion()) % ")"; if (!zecPrice.isEmpty()) { @@ -428,9 +404,9 @@ void Controller::refreshBalances() { // 1. Get the Balances zrpc->fetchBalance([=] (json reply) { - auto balT = QString::fromStdString(reply["transparent"]).toDouble(); - auto balZ = QString::fromStdString(reply["private"]).toDouble(); - auto balTotal = QString::fromStdString(reply["total"]).toDouble(); + auto balT = reply["tbalance"].get(); + auto balZ = reply["zbalance"].get(); + auto balTotal = balT + balZ; AppDataModel::getInstance()->setBalances(balT, balZ); @@ -763,7 +739,7 @@ void Controller::refreshZECPrice() { void Controller::shutdownZcashd() { // Shutdown embedded zcashd if it was started - if (ezcashd == nullptr || ezcashd->processId() == 0 || ~zrpc->haveConnection()) { + if (ezcashd == nullptr || ezcashd->processId() == 0 || !zrpc->haveConnection()) { // No zcashd running internally, just return return; } diff --git a/src/controller.h b/src/controller.h index 7b05421..4e921ce 100644 --- a/src/controller.h +++ b/src/controller.h @@ -40,9 +40,6 @@ public: Connection* getConnection() { return zrpc->getConnection(); } void setConnection(Connection* c); - void setEZcashd(QProcess* p); - const QProcess* getEZcashD() { return ezcashd; } - void refresh(bool force = false); void refreshAddresses(); diff --git a/src/liteinterface.cpp b/src/liteinterface.cpp index a88af7b..dc90678 100644 --- a/src/liteinterface.cpp +++ b/src/liteinterface.cpp @@ -179,14 +179,7 @@ void LiteInterface::fetchBalance(const std::function& cb) { if (conn == nullptr) return; - // json payload = { - // {"jsonrpc", "1.0"}, - // {"id", "someid"}, - // {"method", "z_gettotalbalance"}, - // {"params", {0}} // Get Unconfirmed balance as well. - // }; - - // conn->doRPCWithDefaultErrorHandling(payload, cb); + conn->doRPCWithDefaultErrorHandling("balance", "", cb); } void LiteInterface::fetchTransactions(const std::function& cb) { @@ -228,13 +221,7 @@ void LiteInterface::fetchInfo(const std::function& cb, if (conn == nullptr) return; - // json payload = { - // {"jsonrpc", "1.0"}, - // {"id", "someid"}, - // {"method", "getinfo"} - // }; - - // conn->doRPC(payload, cb, err); + conn->doRPC("info", "", cb, err); } void LiteInterface::fetchBlockchainInfo(const std::function& cb) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c00241e..1cded2a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -335,14 +335,7 @@ void MainWindow::setupSettingsModal() { isUsingTor = !rpc->getConnection()->config->proxy.isEmpty(); } settings.chkTor->setChecked(isUsingTor); - if (rpc->getEZcashD() == nullptr) { - settings.chkTor->setEnabled(false); - settings.lblTor->setEnabled(false); - QString tooltip = tr("Tor configuration is available only when running an embedded zcashd."); - settings.chkTor->setToolTip(tooltip); - settings.lblTor->setToolTip(tooltip); - } - + // Connection Settings QIntValidator validator(0, 65535); settings.port->setValidator(&validator);