Balances
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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<json::boolean_t>());
|
||||
if (!reply["chain_name"].is_null()) {
|
||||
Settings::getInstance()->setTestnet(reply["chain_name"].get<json::string_t>() == "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<json::number_integer_t>();
|
||||
int version = reply["version"].get<json::number_integer_t>();
|
||||
int curBlock = reply["latest_block_height"].get<json::number_integer_t>();
|
||||
//int version = reply["version"].get<json::string_t>();
|
||||
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<json::number_integer_t>();
|
||||
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<double>();
|
||||
@@ -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<json::number_unsigned_t>();
|
||||
auto balZ = reply["zbalance"].get<json::number_unsigned_t>();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -179,14 +179,7 @@ void LiteInterface::fetchBalance(const std::function<void(json)>& 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<void(json)>& cb) {
|
||||
@@ -228,13 +221,7 @@ void LiteInterface::fetchInfo(const std::function<void(json)>& 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<void(json)>& cb) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user