Compare commits

...

4 Commits

  1. 2
      lib/Cargo.lock
  2. 2
      lib/Cargo.toml
  3. 4
      src/chatmodel.cpp
  4. 118
      src/controller.cpp
  5. 4
      src/mainwindow.cpp
  6. 4
      src/settings.cpp
  7. 1
      src/settings.h

2
lib/Cargo.lock

@ -1849,7 +1849,7 @@ dependencies = [
[[package]] [[package]]
name = "silentdragonlitelib" name = "silentdragonlitelib"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.hush.is/lucretius/silentdragonlite-cli?rev=eff5dd7b6dbcfd7e4db6fdba423399337b590722#eff5dd7b6dbcfd7e4db6fdba423399337b590722" source = "git+https://git.hush.is/lucretius/silentdragonlite-cli?rev=5dc29206937cd189c437a256b6af147d9f7b1621#5dc29206937cd189c437a256b6af147d9f7b1621"
dependencies = [ dependencies = [
"base58", "base58",
"bellman", "bellman",

2
lib/Cargo.toml

@ -12,4 +12,4 @@ crate-type = ["staticlib"]
libc = "0.2.58" libc = "0.2.58"
lazy_static = "1.4.0" lazy_static = "1.4.0"
blake3 = "0.3.4" blake3 = "0.3.4"
silentdragonlitelib = { git = "https://git.hush.is/lucretius/silentdragonlite-cli", rev = "eff5dd7b6dbcfd7e4db6fdba423399337b590722" } silentdragonlitelib = { git = "https://git.hush.is/lucretius/silentdragonlite-cli", rev = "5dc29206937cd189c437a256b6af147d9f7b1621" }

4
src/chatmodel.cpp

@ -509,7 +509,7 @@ Tx MainWindow::createTxFromChatPage() {
} }
} }
tx.fee = Settings::getMinerFee(); tx.fee = Settings::getMinerFeeChat();
return tx; return tx;
@ -803,7 +803,7 @@ Tx MainWindow::createTxForSafeContactRequest()
tx.toAddrs.push_back(ToFields{addr, amt, hmemo}); tx.toAddrs.push_back(ToFields{addr, amt, hmemo});
tx.toAddrs.push_back(ToFields{addr, amt, memo}); tx.toAddrs.push_back(ToFields{addr, amt, memo});
tx.fee = Settings::getMinerFee(); tx.fee = Settings::getMinerFeeChat();
} }
return tx; return tx;

118
src/controller.cpp

@ -10,6 +10,8 @@
#include "websockets.h" #include "websockets.h"
#include "Model/ChatItem.h" #include "Model/ChatItem.h"
#include "DataStore/DataStore.h" #include "DataStore/DataStore.h"
#include <thread>
ChatModel *chatModel = new ChatModel(); ChatModel *chatModel = new ChatModel();
Chat *chat = new Chat(); Chat *chat = new Chat();
@ -273,15 +275,28 @@ void Controller::noConnection()
} }
/// This will refresh all the balance data from hushd /// This will refresh all the balance data from hushd
void Controller::refresh(bool force) #include <thread>
{
qDebug()<< __func__; void Controller::refresh(bool force) {
if (!zrpc->haveConnection()) qDebug() << __func__;
return;
int attempts = 0;
const int max_attempts = 10;
getInfoThenRefresh(force); while (!zrpc->haveConnection()) {
if (attempts >= max_attempts) {
qDebug() << "Max retry reached";
return;
}
qDebug() << "Waiting for connection... try : " << attempts + 1;
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts));
attempts++;
}
getInfoThenRefresh(force);
} }
void Controller::processInfo(const json& info) void Controller::processInfo(const json& info)
{ {
// Testnet? // Testnet?
@ -302,9 +317,19 @@ void Controller::processInfo(const json& info)
void Controller::getInfoThenRefresh(bool force) void Controller::getInfoThenRefresh(bool force)
{ {
qDebug()<< __func__; qDebug()<< __func__;
if (!zrpc->haveConnection()) int attempts = 0;
return noConnection(); int max_attempts = 10;
while (!zrpc->haveConnection()) {
if (attempts >= max_attempts) {
return noConnection();
}
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts));
attempts++;
}
static bool prevCallSucceeded = false; static bool prevCallSucceeded = false;
@ -630,8 +655,19 @@ void Controller::setLag(int lag)
void Controller::refreshAddresses() void Controller::refreshAddresses()
{ {
qDebug()<< __func__; qDebug()<< __func__;
if (!zrpc->haveConnection())
return noConnection(); int attempts = 0;
const int max_attempts = 10;
while (!zrpc->haveConnection()) {
if (attempts >= max_attempts) {
qDebug() << "Max try reached";
return noConnection();
}
qDebug() << "Waiting for connection... try : " << attempts + 1;
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts));
attempts++;
}
auto newzaddresses = new QList<QString>(); auto newzaddresses = new QList<QString>();
auto newtaddresses = new QList<QString>(); auto newtaddresses = new QList<QString>();
@ -885,8 +921,19 @@ void Controller::updateUIBalances()
void Controller::refreshBalances() void Controller::refreshBalances()
{ {
qDebug()<< __func__; qDebug()<< __func__;
if (!zrpc->haveConnection())
return noConnection(); int attempts = 0;
const int max_attempts = 10;
while (!zrpc->haveConnection()) {
if (attempts >= max_attempts) {
qDebug() << "Max try reached";
return noConnection();
}
qDebug() << "Waiting for connection... try : " << attempts + 1;
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts));
attempts++;
}
// 1. Get the Balances // 1. Get the Balances
zrpc->fetchBalance([=] (json reply) { zrpc->fetchBalance([=] (json reply) {
@ -961,8 +1008,19 @@ void printJsonValue(QTextStream& out, const nlohmann::json& j, int depth = 0) {
void Controller::refreshTransactions() { void Controller::refreshTransactions() {
qDebug()<< __func__; qDebug()<< __func__;
if (!zrpc->haveConnection())
return noConnection(); int attempts = 0;
const int max_attempts = 10;
while (!zrpc->haveConnection()) {
if (attempts >= max_attempts) {
qDebug() << "Max try reached";
return noConnection();
}
qDebug() << "Waiting for connection... try : " << attempts + 1;
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts));
attempts++;
}
qDebug() << __func__ << ": fetchTransactions"; qDebug() << __func__ << ": fetchTransactions";
zrpc->fetchTransactions([=] (json reply) { zrpc->fetchTransactions([=] (json reply) {
@ -1562,8 +1620,19 @@ void Controller::checkForUpdate(bool silent)
qDebug()<< __func__; qDebug()<< __func__;
// No checking for updates, needs testing with Gitea // No checking for updates, needs testing with Gitea
return; return;
if (!zrpc->haveConnection())
return noConnection(); int attempts = 0;
const int max_attempts = 10;
while (!zrpc->haveConnection()) {
if (attempts >= max_attempts) {
qDebug() << "Max try reached";
return noConnection();
}
qDebug() << "Waiting for connection... try : " << attempts + 1;
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts));
attempts++;
}
QUrl cmcURL("https://git.hush.is/repos/MyHush/SilentDragonLite/releases"); QUrl cmcURL("https://git.hush.is/repos/MyHush/SilentDragonLite/releases");
@ -1651,8 +1720,19 @@ void Controller::checkForUpdate(bool silent)
void Controller::refreshHUSHPrice() void Controller::refreshHUSHPrice()
{ {
qDebug()<< __func__; qDebug()<< __func__;
if (!zrpc->haveConnection())
return; int attempts = 0;
const int max_attempts = 10;
while (!zrpc->haveConnection()) {
if (attempts >= max_attempts) {
qDebug() << "Max try reached";
return noConnection();
}
qDebug() << "Waiting for connection... try : " << attempts + 1;
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts));
attempts++;
}
// TODO: use/render all this data // TODO: use/render all this data
QUrl cmcURL("https://api.coingecko.com/api/v3/simple/price?ids=hush&vs_currencies=btc%2Cusd%2Ceur%2Ceth%2Cgbp%2Ccny%2Cjpy%2Crub%2Ccad%2Csgd%2Cchf%2Cinr%2Caud%2Cinr&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true"); QUrl cmcURL("https://api.coingecko.com/api/v3/simple/price?ids=hush&vs_currencies=btc%2Cusd%2Ceur%2Ceth%2Cgbp%2Ccny%2Cjpy%2Crub%2Ccad%2Csgd%2Cchf%2Cinr%2Caud%2Cinr&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true");

4
src/mainwindow.cpp

@ -1950,7 +1950,7 @@ Tx MainWindow::createTxFromSendChatPage() {
} }
} }
tx.fee = Settings::getMinerFee(); tx.fee = Settings::getMinerFeeChat();
return tx; return tx;
@ -2240,7 +2240,7 @@ Tx MainWindow::createTxFromSendRequestChatPage() {
} }
} }
tx.fee = Settings::getMinerFee(); tx.fee = Settings::getMinerFeeChat();
return tx; return tx;

4
src/settings.cpp

@ -358,6 +358,10 @@ CAmount Settings::getMinerFee() {
return CAmount::fromqint64(10000); return CAmount::fromqint64(10000);
} }
CAmount Settings::getMinerFeeChat() {
return CAmount::fromqint64(0);
}
bool Settings::isValidSaplingPrivateKey(QString pk) { bool Settings::isValidSaplingPrivateKey(QString pk) {
if (isTestnet()) { if (isTestnet()) {
QRegExp zspkey("^secret-extended-key-test[0-9a-z]{278}$", Qt::CaseInsensitive); QRegExp zspkey("^secret-extended-key-test[0-9a-z]{278}$", Qt::CaseInsensitive);

1
src/settings.h

@ -164,6 +164,7 @@ public:
static QString getDefaultServer(); static QString getDefaultServer();
static QString getRandomServer(); static QString getRandomServer();
static CAmount getMinerFee(); static CAmount getMinerFee();
static CAmount getMinerFeeChat();
static int getMaxMobileAppTxns() { return 30; } static int getMaxMobileAppTxns() { return 30; }

Loading…
Cancel
Save