diff --git a/src/rpc.cpp b/src/rpc.cpp index 04cfdde..dd4a01f 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -88,7 +88,8 @@ void RPC::setConnection(Connection* c) { ui->statusBar->showMessage("Ready!"); refreshZECPrice(); - checkForUpdate(); + // Commented for Android beta. + // checkForUpdate(); // Force update, because this might be coming from a settings update // where we need to immediately refresh diff --git a/src/version.h b/src/version.h index ec5d866..edfe526 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define APP_VERSION "0.5.7" +#define APP_VERSION "0.5.7-androidbeta" diff --git a/src/websockets.cpp b/src/websockets.cpp index 253922b..ae487c4 100644 --- a/src/websockets.cpp +++ b/src/websockets.cpp @@ -3,6 +3,7 @@ #include "rpc.h" #include "settings.h" #include "ui_mobileappconnector.h" +#include "version.h" WSServer::WSServer(quint16 port, bool debug, QObject *parent) : QObject(parent), @@ -408,30 +409,23 @@ void AppDataServer::processSendTx(QJsonObject sendTx, MainWindow* mainwindow, QW // Filter out sprout Txns if (Settings::getInstance()->isSproutAddress(i)) continue; + // Filter out balances that don't have the requisite amount + if (allBalances->value(i) < amt) + continue; + bals.append(QPair(i, allBalances->value(i))); } if (bals.isEmpty()) { - error("No sapling or transparent addresses"); + error("No sapling or transparent addresses with enough balance to spend."); return; } - std::sort(bals.begin(), bals.end(), [=](const QPaira, const QPair b) ->bool { - // If same type, sort by amount - if (a.first[0] == b.first[0]) { - return a.second > b.second; - } - else { - return a > b; - } + std::sort(bals.begin(), bals.end(), [=](const QPaira, const QPair b) -> bool { + // Sort z addresses first + return a.first > b.first; }); - if (amt > bals[0].second) { - // There isn't any any address capable of sending the Tx. - error("Amount exceeds the balance of your largest address."); - return; - } - tx.fromAddr = bals[0].first; tx.toAddrs = { ToFields{ sendTx["to"].toString(), amt, sendTx["memo"].toString(), sendTx["memo"].toString().toUtf8().toHex()} }; @@ -468,6 +462,13 @@ void AppDataServer::processSendTx(QJsonObject sendTx, MainWindow* mainwindow, QW void AppDataServer::processGetInfo(QJsonObject jobj, MainWindow* mainWindow, QWebSocket* pClient) { auto connectedName = jobj["name"].toString(); + double maxSpendable = 0; + auto balances = mainWindow->getRPC()->getAllBalances()->values(); + if (balances.length() > 0) { + std::sort(balances.begin(), balances.end(), std::less()); + maxSpendable = balances[balances.length() - 1]; + } + { QSettings s; s.setValue("mobileapp/connectedname", connectedName); @@ -479,8 +480,10 @@ void AppDataServer::processGetInfo(QJsonObject jobj, MainWindow* mainWindow, QWe {"saplingAddress", mainWindow->getRPC()->getDefaultSaplingAddress()}, {"tAddress", mainWindow->getRPC()->getDefaultTAddress()}, {"balance", AppDataModel::getInstance()->getTotalBalance()}, + {"maxspendable", maxSpendable}, {"tokenName", Settings::getTokenName()}, - {"zecprice", Settings::getInstance()->getZECPrice()} + {"zecprice", Settings::getInstance()->getZECPrice()}, + {"serverversion", QString(APP_VERSION)} }).toJson(); pClient->sendTextMessage(encryptOutgoing(r)); } diff --git a/src/websockets.h b/src/websockets.h index 9dce130..59ae1f2 100644 --- a/src/websockets.h +++ b/src/websockets.h @@ -89,7 +89,6 @@ private: double balTransparent; double balShielded; double balTotal; - double balMaxSingle; QString saplingAddress;