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]]
name = "silentdragonlitelib"
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 = [
"base58",
"bellman",

2
lib/Cargo.toml

@ -12,4 +12,4 @@ crate-type = ["staticlib"]
libc = "0.2.58"
lazy_static = "1.4.0"
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;
@ -803,7 +803,7 @@ Tx MainWindow::createTxForSafeContactRequest()
tx.toAddrs.push_back(ToFields{addr, amt, hmemo});
tx.toAddrs.push_back(ToFields{addr, amt, memo});
tx.fee = Settings::getMinerFee();
tx.fee = Settings::getMinerFeeChat();
}
return tx;

118
src/controller.cpp

@ -10,6 +10,8 @@
#include "websockets.h"
#include "Model/ChatItem.h"
#include "DataStore/DataStore.h"
#include <thread>
ChatModel *chatModel = new ChatModel();
Chat *chat = new Chat();
@ -273,15 +275,28 @@ void Controller::noConnection()
}
/// This will refresh all the balance data from hushd
void Controller::refresh(bool force)
{
qDebug()<< __func__;
if (!zrpc->haveConnection())
return;
#include <thread>
void Controller::refresh(bool force) {
qDebug() << __func__;
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)
{
// Testnet?
@ -302,9 +317,19 @@ void Controller::processInfo(const json& info)
void Controller::getInfoThenRefresh(bool force)
{
qDebug()<< __func__;
if (!zrpc->haveConnection())
return noConnection();
qDebug()<< __func__;
int attempts = 0;
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;
@ -630,8 +655,19 @@ void Controller::setLag(int lag)
void Controller::refreshAddresses()
{
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 newtaddresses = new QList<QString>();
@ -885,8 +921,19 @@ void Controller::updateUIBalances()
void Controller::refreshBalances()
{
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
zrpc->fetchBalance([=] (json reply) {
@ -961,8 +1008,19 @@ void printJsonValue(QTextStream& out, const nlohmann::json& j, int depth = 0) {
void Controller::refreshTransactions() {
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";
zrpc->fetchTransactions([=] (json reply) {
@ -1562,8 +1620,19 @@ void Controller::checkForUpdate(bool silent)
qDebug()<< __func__;
// No checking for updates, needs testing with Gitea
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");
@ -1651,8 +1720,19 @@ void Controller::checkForUpdate(bool silent)
void Controller::refreshHUSHPrice()
{
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
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;
@ -2240,7 +2240,7 @@ Tx MainWindow::createTxFromSendRequestChatPage() {
}
}
tx.fee = Settings::getMinerFee();
tx.fee = Settings::getMinerFeeChat();
return tx;

4
src/settings.cpp

@ -358,6 +358,10 @@ CAmount Settings::getMinerFee() {
return CAmount::fromqint64(10000);
}
CAmount Settings::getMinerFeeChat() {
return CAmount::fromqint64(0);
}
bool Settings::isValidSaplingPrivateKey(QString pk) {
if (isTestnet()) {
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 getRandomServer();
static CAmount getMinerFee();
static CAmount getMinerFeeChat();
static int getMaxMobileAppTxns() { return 30; }

Loading…
Cancel
Save