mirror of
https://git.wownero.com/wowlet/wowlet.git
synced 2024-08-15 01:03:14 +00:00
Don't use unsigned ints
This commit is contained in:
parent
136f877778
commit
14e3422423
18 changed files with 68 additions and 69 deletions
|
@ -134,11 +134,11 @@ AppContext::AppContext(QCommandLineParser *cmdargs) {
|
||||||
auto genesis_timestamp = this->restoreHeights[NetworkType::Type::MAINNET]->data.firstKey();
|
auto genesis_timestamp = this->restoreHeights[NetworkType::Type::MAINNET]->data.firstKey();
|
||||||
AppContext::txFiatHistory = new TxFiatHistory(genesis_timestamp, this->configDirectory);
|
AppContext::txFiatHistory = new TxFiatHistory(genesis_timestamp, this->configDirectory);
|
||||||
connect(this->ws, &WSClient::connectionEstablished, AppContext::txFiatHistory, &TxFiatHistory::onUpdateDatabase);
|
connect(this->ws, &WSClient::connectionEstablished, AppContext::txFiatHistory, &TxFiatHistory::onUpdateDatabase);
|
||||||
connect(AppContext::txFiatHistory, &TxFiatHistory::requestYear, [=](unsigned int year){
|
connect(AppContext::txFiatHistory, &TxFiatHistory::requestYear, [=](int year){
|
||||||
QByteArray data = QString(R"({"cmd": "txFiatHistory", "data": {"year": %1}})").arg(year).toUtf8();
|
QByteArray data = QString(R"({"cmd": "txFiatHistory", "data": {"year": %1}})").arg(year).toUtf8();
|
||||||
this->ws->sendMsg(data);
|
this->ws->sendMsg(data);
|
||||||
});
|
});
|
||||||
connect(AppContext::txFiatHistory, &TxFiatHistory::requestYearMonth, [=](unsigned int year, unsigned int month) {
|
connect(AppContext::txFiatHistory, &TxFiatHistory::requestYearMonth, [=](int year, int month) {
|
||||||
QByteArray data = QString(R"({"cmd": "txFiatHistory", "data": {"year": %1, "month": %2}})").arg(year).arg(month).toUtf8();
|
QByteArray data = QString(R"({"cmd": "txFiatHistory", "data": {"year": %1, "month": %2}})").arg(year).arg(month).toUtf8();
|
||||||
this->ws->sendMsg(data);
|
this->ws->sendMsg(data);
|
||||||
});
|
});
|
||||||
|
@ -378,22 +378,22 @@ void AppContext::onWSMessage(const QJsonObject &msg) {
|
||||||
auto changed = false;
|
auto changed = false;
|
||||||
|
|
||||||
if(!this->heights.contains("mainnet")) {
|
if(!this->heights.contains("mainnet")) {
|
||||||
this->heights["mainnet"] = (unsigned int) mainnet;
|
this->heights["mainnet"] = mainnet;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (mainnet > this->heights["mainnet"]) {
|
if (mainnet > this->heights["mainnet"]) {
|
||||||
this->heights["mainnet"] = (unsigned int) mainnet;
|
this->heights["mainnet"] = mainnet;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!this->heights.contains("stagenet")) {
|
if(!this->heights.contains("stagenet")) {
|
||||||
this->heights["stagenet"] = (unsigned int) stagenet;
|
this->heights["stagenet"] = stagenet;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (stagenet > this->heights["stagenet"]) {
|
if (stagenet > this->heights["stagenet"]) {
|
||||||
this->heights["stagenet"] = (unsigned int) stagenet;
|
this->heights["stagenet"] = stagenet;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -605,7 +605,7 @@ void AppContext::initRestoreHeights() {
|
||||||
restoreHeights[NetworkType::MAINNET] = RestoreHeightLookup::fromFile(":/assets/restore_heights_monero_mainnet.txt", NetworkType::MAINNET);
|
restoreHeights[NetworkType::MAINNET] = RestoreHeightLookup::fromFile(":/assets/restore_heights_monero_mainnet.txt", NetworkType::MAINNET);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppContext::onSetRestoreHeight(unsigned int height){
|
void AppContext::onSetRestoreHeight(quint64 height){
|
||||||
auto seed = this->currentWallet->getCacheAttribute("feather.seed");
|
auto seed = this->currentWallet->getCacheAttribute("feather.seed");
|
||||||
if(!seed.isEmpty()) {
|
if(!seed.isEmpty()) {
|
||||||
const auto msg = "This wallet has a 14 word mnemonic seed which has the restore height embedded.";
|
const auto msg = "This wallet has a 14 word mnemonic seed which has the restore height embedded.";
|
||||||
|
|
|
@ -66,9 +66,9 @@ public:
|
||||||
|
|
||||||
static void createConfigDirectory(const QString &dir) ;
|
static void createConfigDirectory(const QString &dir) ;
|
||||||
|
|
||||||
QMap<QString, unsigned int> heights;
|
QMap<QString, int> heights;
|
||||||
QMap<NetworkType::Type, RestoreHeightLookup*> restoreHeights;
|
QMap<NetworkType::Type, RestoreHeightLookup*> restoreHeights;
|
||||||
const unsigned int kdfRounds = 1;
|
const quint64 kdfRounds = 1;
|
||||||
PendingTransaction::Priority tx_priority = PendingTransaction::Priority::Priority_Low;
|
PendingTransaction::Priority tx_priority = PendingTransaction::Priority::Priority_Low;
|
||||||
quint32 tx_mixin = static_cast<const quint32 &>(10);
|
quint32 tx_mixin = static_cast<const quint32 &>(10);
|
||||||
QString seedLanguage = "English"; // 14 word `monero-seed` only has English
|
QString seedLanguage = "English"; // 14 word `monero-seed` only has English
|
||||||
|
@ -90,7 +90,6 @@ public:
|
||||||
static TxFiatHistory *txFiatHistory;
|
static TxFiatHistory *txFiatHistory;
|
||||||
|
|
||||||
// libwalletqt
|
// libwalletqt
|
||||||
unsigned int blockHeight = 0;
|
|
||||||
bool refreshed = false;
|
bool refreshed = false;
|
||||||
WalletManager *walletManager;
|
WalletManager *walletManager;
|
||||||
Wallet *currentWallet = nullptr;
|
Wallet *currentWallet = nullptr;
|
||||||
|
@ -116,7 +115,7 @@ public slots:
|
||||||
void onSweepOutput(const QString &keyImage, QString address, bool churn, int outputs) const;
|
void onSweepOutput(const QString &keyImage, QString address, bool churn, int outputs) const;
|
||||||
void onCreateTransactionError(const QString &msg);
|
void onCreateTransactionError(const QString &msg);
|
||||||
void onOpenAliasResolve(const QString &openAlias);
|
void onOpenAliasResolve(const QString &openAlias);
|
||||||
void onSetRestoreHeight(unsigned int height);
|
void onSetRestoreHeight(quint64 height);
|
||||||
void onPreferredFiatCurrencyChanged(const QString &symbol);
|
void onPreferredFiatCurrencyChanged(const QString &symbol);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -142,7 +141,7 @@ signals:
|
||||||
void blockchainSync(int height, int target);
|
void blockchainSync(int height, int target);
|
||||||
void refreshSync(int height, int target);
|
void refreshSync(int height, int target);
|
||||||
void synchronized();
|
void synchronized();
|
||||||
void blockHeightWSUpdated(QMap<QString, unsigned int> heights);
|
void blockHeightWSUpdated(QMap<QString, int> heights);
|
||||||
void walletSynchronized();
|
void walletSynchronized();
|
||||||
void walletOpened();
|
void walletOpened();
|
||||||
void walletClosed();
|
void walletClosed();
|
||||||
|
@ -164,7 +163,7 @@ signals:
|
||||||
void openAliasResolveError(const QString &msg);
|
void openAliasResolveError(const QString &msg);
|
||||||
void openAliasResolved(const QString &address, const QString &openAlias);
|
void openAliasResolved(const QString &address, const QString &openAlias);
|
||||||
void setRestoreHeightError(const QString &msg);
|
void setRestoreHeightError(const QString &msg);
|
||||||
void customRestoreHeightSet(unsigned int height);
|
void customRestoreHeightSet(int height);
|
||||||
void closeApplication();
|
void closeApplication();
|
||||||
void donationNag();
|
void donationNag();
|
||||||
void initiateTransaction();
|
void initiateTransaction();
|
||||||
|
@ -173,7 +172,7 @@ signals:
|
||||||
void setTitle(const QString &title); // set window title
|
void setTitle(const QString &title); // set window title
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const unsigned int m_donationBoundary = 15;
|
const int m_donationBoundary = 15;
|
||||||
UtilsNetworking *m_utilsNetworkingNodes;
|
UtilsNetworking *m_utilsNetworkingNodes;
|
||||||
QTimer *m_storeTimer = new QTimer(this);
|
QTimer *m_storeTimer = new QTimer(this);
|
||||||
QUrl m_wsUrl = QUrl(QStringLiteral("ws://7e6egbawekbkxzkv4244pqeqgoo4axko2imgjbedwnn6s5yb6b7oliqd.onion/ws"));
|
QUrl m_wsUrl = QUrl(QStringLiteral("ws://7e6egbawekbkxzkv4244pqeqgoo4axko2imgjbedwnn6s5yb6b7oliqd.onion/ws"));
|
||||||
|
|
|
@ -24,7 +24,7 @@ RestoreDialog::RestoreDialog(AppContext *ctx, QWidget *parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int RestoreDialog::getHeight() {
|
int RestoreDialog::getHeight() {
|
||||||
return ui->restoreHeightWidget->getHeight();
|
return ui->restoreHeightWidget->getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit RestoreDialog(AppContext *ctx, QWidget *parent = nullptr);
|
explicit RestoreDialog(AppContext *ctx, QWidget *parent = nullptr);
|
||||||
void initRestoreHeights(RestoreHeightLookup *lookup);
|
void initRestoreHeights(RestoreHeightLookup *lookup);
|
||||||
unsigned int getHeight();
|
int getHeight();
|
||||||
~RestoreDialog() override;
|
~RestoreDialog() override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -434,7 +434,7 @@ void MainWindow::initMenu() {
|
||||||
|
|
||||||
// set restore height
|
// set restore height
|
||||||
connect(ui->actionChange_restore_height, &QAction::triggered, this, &MainWindow::showRestoreHeightDialog);
|
connect(ui->actionChange_restore_height, &QAction::triggered, this, &MainWindow::showRestoreHeightDialog);
|
||||||
connect(m_ctx, &AppContext::customRestoreHeightSet, [=](unsigned int height){
|
connect(m_ctx, &AppContext::customRestoreHeightSet, [=](int height){
|
||||||
auto msg = QString("The restore height for this wallet has been set to %1. "
|
auto msg = QString("The restore height for this wallet has been set to %1. "
|
||||||
"Please re-open the wallet. Feather will now quit.").arg(height);
|
"Please re-open the wallet. Feather will now quit.").arg(height);
|
||||||
QMessageBox::information(this, "Cannot set custom restore height", msg);
|
QMessageBox::information(this, "Cannot set custom restore height", msg);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <utils/nodes.h>
|
#include <utils/nodes.h>
|
||||||
#include "appcontext.h"
|
#include "appcontext.h"
|
||||||
|
|
||||||
NodeModel::NodeModel(unsigned int nodeSource, QObject *parent)
|
NodeModel::NodeModel(int nodeSource, QObject *parent)
|
||||||
: QAbstractTableModel(parent)
|
: QAbstractTableModel(parent)
|
||||||
, m_nodeSource(nodeSource)
|
, m_nodeSource(nodeSource)
|
||||||
, m_offline(QIcon(":/assets/images/expired_icon.png"))
|
, m_offline(QIcon(":/assets/images/expired_icon.png"))
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
COUNT
|
COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit NodeModel(unsigned int nodeSource, QObject *parent = nullptr);
|
explicit NodeModel(int nodeSource, QObject *parent = nullptr);
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent) const override;
|
int rowCount(const QModelIndex &parent) const override;
|
||||||
int columnCount(const QModelIndex &parent) const override;
|
int columnCount(const QModelIndex &parent) const override;
|
||||||
|
@ -34,7 +34,7 @@ private:
|
||||||
QList<FeatherNode> m_nodes;
|
QList<FeatherNode> m_nodes;
|
||||||
QIcon m_offline;
|
QIcon m_offline;
|
||||||
QIcon m_online;
|
QIcon m_online;
|
||||||
unsigned int m_nodeSource;
|
int m_nodeSource;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //FEATHER_NODEMODEL_H
|
#endif //FEATHER_NODEMODEL_H
|
||||||
|
|
|
@ -19,44 +19,44 @@
|
||||||
|
|
||||||
struct RestoreHeightLookup {
|
struct RestoreHeightLookup {
|
||||||
NetworkType::Type type;
|
NetworkType::Type type;
|
||||||
QMap<unsigned int, unsigned int> data;
|
QMap<int, int> data;
|
||||||
explicit RestoreHeightLookup(NetworkType::Type type) : type(type) {}
|
explicit RestoreHeightLookup(NetworkType::Type type) : type(type) {}
|
||||||
|
|
||||||
unsigned int dateToRestoreHeight(unsigned int date) {
|
int dateToRestoreHeight(int date) {
|
||||||
// restore height based on a given timestamp using a lookup
|
// restore height based on a given timestamp using a lookup
|
||||||
// table. If it cannot find the date in the lookup table, it
|
// table. If it cannot find the date in the lookup table, it
|
||||||
// will calculate the blockheight based off the last known
|
// will calculate the blockheight based off the last known
|
||||||
// date: ((now - lastKnownDate) / blockTime) - clearance
|
// date: ((now - lastKnownDate) / blockTime) - clearance
|
||||||
|
|
||||||
if(this->type == NetworkType::TESTNET) return 1;
|
if(this->type == NetworkType::TESTNET) return 1;
|
||||||
unsigned int blockTime = 120;
|
int blockTime = 120;
|
||||||
unsigned int blocksPerDay = 86400 / blockTime;
|
int blocksPerDay = 86400 / blockTime;
|
||||||
unsigned int blockCalcClearance = blocksPerDay * 5;
|
int blockCalcClearance = blocksPerDay * 5;
|
||||||
QList<unsigned int> values = this->data.keys();
|
QList<int> values = this->data.keys();
|
||||||
if(date <= values.at(0))
|
if(date <= values.at(0))
|
||||||
return this->data[values.at(0)];
|
return this->data[values.at(0)];
|
||||||
for(unsigned int i = 0; i != values.count(); i++) {
|
for(int i = 0; i != values.count(); i++) {
|
||||||
if(values[i] > date) {
|
if(values[i] > date) {
|
||||||
return i - 1 < 0 ? this->data[values[i]] : this->data[values[i-1]] - blockCalcClearance;
|
return i - 1 < 0 ? this->data[values[i]] : this->data[values[i-1]] - blockCalcClearance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// lookup failed, calculate blockheight from last known checkpoint
|
// lookup failed, calculate blockheight from last known checkpoint
|
||||||
unsigned int lastBlockHeightTime = values.at(values.count() - 1);
|
int lastBlockHeightTime = values.at(values.count() - 1);
|
||||||
unsigned int lastBlockHeight = this->data[lastBlockHeightTime];
|
int lastBlockHeight = this->data[lastBlockHeightTime];
|
||||||
unsigned int deltaTime = date - lastBlockHeightTime;
|
int deltaTime = date - lastBlockHeightTime;
|
||||||
unsigned int deltaBlocks = deltaTime / blockTime;
|
int deltaBlocks = deltaTime / blockTime;
|
||||||
unsigned int blockHeight = (lastBlockHeight + deltaBlocks) - blockCalcClearance;
|
int blockHeight = (lastBlockHeight + deltaBlocks) - blockCalcClearance;
|
||||||
qDebug() << "Calculated blockheight: " << blockHeight << " from epoch " << date;
|
qDebug() << "Calculated blockheight: " << blockHeight << " from epoch " << date;
|
||||||
return blockHeight;
|
return blockHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int restoreHeightToDate(unsigned int height) {
|
int restoreHeightToDate(int height) {
|
||||||
// @TODO: most likely inefficient, refactor
|
// @TODO: most likely inefficient, refactor
|
||||||
QMap<unsigned int, unsigned int>::iterator i;
|
QMap<int, int>::iterator i;
|
||||||
unsigned int timestamp = 0;
|
int timestamp = 0;
|
||||||
for (i = this->data.begin(); i != this->data.end(); ++i) {
|
for (i = this->data.begin(); i != this->data.end(); ++i) {
|
||||||
unsigned int ts = i.key();
|
int ts = i.key();
|
||||||
if (i.value() > height)
|
if (i.value() > height)
|
||||||
return timestamp;
|
return timestamp;
|
||||||
timestamp = ts;
|
timestamp = ts;
|
||||||
|
@ -68,7 +68,7 @@ struct RestoreHeightLookup {
|
||||||
// initialize this class using a lookup table, e.g `:/assets/restore_heights_monero_mainnet.txt`/
|
// initialize this class using a lookup table, e.g `:/assets/restore_heights_monero_mainnet.txt`/
|
||||||
auto rtn = new RestoreHeightLookup(type);
|
auto rtn = new RestoreHeightLookup(type);
|
||||||
auto data = Utils::barrayToString(Utils::fileOpen(fn));
|
auto data = Utils::barrayToString(Utils::fileOpen(fn));
|
||||||
QMap<unsigned int, unsigned int> _data;
|
QMap<int, int> _data;
|
||||||
for(const auto &line: data.split('\n')) {
|
for(const auto &line: data.split('\n')) {
|
||||||
if(line.trimmed().isEmpty()) continue;
|
if(line.trimmed().isEmpty()) continue;
|
||||||
auto spl = line.trimmed().split(':');
|
auto spl = line.trimmed().split(':');
|
||||||
|
@ -82,7 +82,7 @@ struct FeatherSeed {
|
||||||
QString mnemonicSeed;
|
QString mnemonicSeed;
|
||||||
QString spendKey;
|
QString spendKey;
|
||||||
time_t time = 0;
|
time_t time = 0;
|
||||||
unsigned int restoreHeight = 0;
|
int restoreHeight = 0;
|
||||||
RestoreHeightLookup *lookup = nullptr;
|
RestoreHeightLookup *lookup = nullptr;
|
||||||
QString language;
|
QString language;
|
||||||
std::string coinName;
|
std::string coinName;
|
||||||
|
@ -124,7 +124,7 @@ struct FeatherSeed {
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
Wallet *writeWallet(WalletManager *manager, NetworkType::Type type, const QString &path, const QString &password, unsigned int kdfRounds) {
|
Wallet *writeWallet(WalletManager *manager, NetworkType::Type type, const QString &path, const QString &password, quint64 kdfRounds) {
|
||||||
// writes both 14/25 word mnemonic seeds.
|
// writes both 14/25 word mnemonic seeds.
|
||||||
Wallet *wallet = nullptr;
|
Wallet *wallet = nullptr;
|
||||||
if(this->lookup == nullptr) return wallet;
|
if(this->lookup == nullptr) return wallet;
|
||||||
|
@ -136,25 +136,25 @@ struct FeatherSeed {
|
||||||
this->restoreHeight = _seed.restoreHeight;
|
this->restoreHeight = _seed.restoreHeight;
|
||||||
this->spendKey = _seed.spendKey;
|
this->spendKey = _seed.spendKey;
|
||||||
}
|
}
|
||||||
wallet = manager->createDeterministicWalletFromSpendKey(path, password, this->language, type, this->spendKey, this->restoreHeight, (quint64)kdfRounds);
|
wallet = manager->createDeterministicWalletFromSpendKey(path, password, this->language, type, this->spendKey, this->restoreHeight, kdfRounds);
|
||||||
wallet->setCacheAttribute("feather.seed", this->mnemonicSeed);
|
wallet->setCacheAttribute("feather.seed", this->mnemonicSeed);
|
||||||
} else {
|
} else {
|
||||||
wallet = manager->recoveryWallet(path, password, this->mnemonicSeed, "", type, this->restoreHeight, (quint64) kdfRounds);
|
wallet = manager->recoveryWallet(path, password, this->mnemonicSeed, "", type, this->restoreHeight, kdfRounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
wallet->setPassword(password);
|
wallet->setPassword(password);
|
||||||
return wallet;
|
return wallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int setRestoreHeight() {
|
int setRestoreHeight() {
|
||||||
if(this->lookup == nullptr) return 1;
|
if(this->lookup == nullptr) return 1;
|
||||||
if(this->time == 0) return 1;
|
if(this->time == 0) return 1;
|
||||||
this->restoreHeight = this->lookup->dateToRestoreHeight((unsigned int)this->time);
|
this->restoreHeight = this->lookup->dateToRestoreHeight(this->time);
|
||||||
return this->restoreHeight;
|
return this->restoreHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int setRestoreHeight(unsigned int height) {
|
int setRestoreHeight(int height) {
|
||||||
auto now = (unsigned int)std::time(nullptr);
|
auto now = std::time(nullptr);
|
||||||
auto nowClearance = 3600 * 24;
|
auto nowClearance = 3600 * 24;
|
||||||
auto currentBlockHeight = this->lookup->dateToRestoreHeight(now - nowClearance);
|
auto currentBlockHeight = this->lookup->dateToRestoreHeight(now - nowClearance);
|
||||||
if(height >= currentBlockHeight + nowClearance) {
|
if(height >= currentBlockHeight + nowClearance) {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "txfiathistory.h"
|
#include "txfiathistory.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
TxFiatHistory::TxFiatHistory(unsigned int genesis_timestamp, const QString &configDirectory, QObject *parent) :
|
TxFiatHistory::TxFiatHistory(int genesis_timestamp, const QString &configDirectory, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_genesis_timestamp(genesis_timestamp),
|
m_genesis_timestamp(genesis_timestamp),
|
||||||
m_configDirectory(configDirectory) {
|
m_configDirectory(configDirectory) {
|
||||||
|
@ -15,7 +15,7 @@ TxFiatHistory::TxFiatHistory(unsigned int genesis_timestamp, const QString &conf
|
||||||
this->loadDatabase();
|
this->loadDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
double TxFiatHistory::get(unsigned int timestamp) {
|
double TxFiatHistory::get(int timestamp) {
|
||||||
QDateTime ts;
|
QDateTime ts;
|
||||||
ts.setTime_t(timestamp);
|
ts.setTime_t(timestamp);
|
||||||
auto key = ts.toString("yyyyMMdd");
|
auto key = ts.toString("yyyyMMdd");
|
||||||
|
@ -59,7 +59,7 @@ void TxFiatHistory::onUpdateDatabase() {
|
||||||
|
|
||||||
auto now = QDate::currentDate();
|
auto now = QDate::currentDate();
|
||||||
auto nowKey = now.toString("yyyyMMdd");
|
auto nowKey = now.toString("yyyyMMdd");
|
||||||
unsigned int year = genesis.toString("yyyy").toUInt();
|
int year = genesis.toString("yyyy").toInt();
|
||||||
auto yearCurrent = now.year();
|
auto yearCurrent = now.year();
|
||||||
|
|
||||||
// if current year is genesis year we'll refresh regardless.
|
// if current year is genesis year we'll refresh regardless.
|
||||||
|
@ -71,7 +71,7 @@ void TxFiatHistory::onUpdateDatabase() {
|
||||||
|
|
||||||
// keep local fiatTxHistory database up to date, loop for missing dates
|
// keep local fiatTxHistory database up to date, loop for missing dates
|
||||||
for(year; year != yearCurrent + 1; year += 1){
|
for(year; year != yearCurrent + 1; year += 1){
|
||||||
for(unsigned int month = 1; month != 13; month++) {
|
for(int month = 1; month != 13; month++) {
|
||||||
if(year == yearCurrent && month == now.month() && now.day() == 1) break;
|
if(year == yearCurrent && month == now.month() && now.day() == 1) break;
|
||||||
QDateTime _now;
|
QDateTime _now;
|
||||||
_now.setDate(QDate(year, month, 1));
|
_now.setDate(QDate(year, month, 1));
|
||||||
|
|
|
@ -6,17 +6,17 @@ class TxFiatHistory : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TxFiatHistory(unsigned int genesis_timestamp, const QString &configDirectory, QObject *parent = nullptr);
|
explicit TxFiatHistory(int genesis_timestamp, const QString &configDirectory, QObject *parent = nullptr);
|
||||||
double get(const QString &date);
|
double get(const QString &date);
|
||||||
double get(unsigned int timestamp);
|
double get(int timestamp);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onUpdateDatabase();
|
void onUpdateDatabase();
|
||||||
void onWSData(const QJsonObject &data);
|
void onWSData(const QJsonObject &data);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void requestYear(unsigned int year);
|
void requestYear(int year);
|
||||||
void requestYearMonth(unsigned int year, unsigned int month);
|
void requestYearMonth(int year, int month);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadDatabase();
|
void loadDatabase();
|
||||||
|
@ -25,7 +25,7 @@ private:
|
||||||
QString m_configDirectory;
|
QString m_configDirectory;
|
||||||
bool m_initialized = false;
|
bool m_initialized = false;
|
||||||
QMap<QString, double> m_database;
|
QMap<QString, double> m_database;
|
||||||
unsigned int m_genesis_timestamp;
|
int m_genesis_timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //FEATHER_TXFIATHISTORY_H
|
#endif //FEATHER_TXFIATHISTORY_H
|
||||||
|
|
|
@ -33,7 +33,7 @@ void XmRig::stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmRig::start(const QString &path,
|
void XmRig::start(const QString &path,
|
||||||
unsigned int threads,
|
int threads,
|
||||||
const QString &address,
|
const QString &address,
|
||||||
const QString &username,
|
const QString &username,
|
||||||
const QString &password,
|
const QString &password,
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
explicit XmRig(const QString &configDir, QObject *parent = nullptr);
|
explicit XmRig(const QString &configDir, QObject *parent = nullptr);
|
||||||
void prepare();
|
void prepare();
|
||||||
|
|
||||||
void start(const QString &path, unsigned int threads, const QString &address, const QString &username, const QString &password, bool tor = false, bool tls = true);
|
void start(const QString &path, int threads, const QString &address, const QString &username, const QString &password, bool tor = false, bool tls = true);
|
||||||
void stop();
|
void stop();
|
||||||
bool unpackBins();
|
bool unpackBins();
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ void RestoreHeightWidget::hideSlider(){
|
||||||
void RestoreHeightWidget::initRestoreHeights(RestoreHeightLookup *lookup) {
|
void RestoreHeightWidget::initRestoreHeights(RestoreHeightLookup *lookup) {
|
||||||
// init slider
|
// init slider
|
||||||
m_restoreHeightLookup = lookup;
|
m_restoreHeightLookup = lookup;
|
||||||
auto now = (unsigned int)std::time(nullptr);
|
int now = std::time(nullptr);
|
||||||
QList<unsigned int> blockDates = m_restoreHeightLookup->data.keys();
|
QList<int> blockDates = m_restoreHeightLookup->data.keys();
|
||||||
ui->restoreSlider->setMinimum(blockDates[0]);
|
ui->restoreSlider->setMinimum(blockDates[0]);
|
||||||
ui->restoreSlider->setMaximum(now);
|
ui->restoreSlider->setMaximum(now);
|
||||||
connect(ui->restoreSlider, &QSlider::valueChanged, this, &RestoreHeightWidget::onValueChanged);
|
connect(ui->restoreSlider, &QSlider::valueChanged, this, &RestoreHeightWidget::onValueChanged);
|
||||||
|
@ -45,14 +45,14 @@ void RestoreHeightWidget::initRestoreHeights(RestoreHeightLookup *lookup) {
|
||||||
|
|
||||||
void RestoreHeightWidget::onValueChanged(int date) {
|
void RestoreHeightWidget::onValueChanged(int date) {
|
||||||
QDateTime timestamp;
|
QDateTime timestamp;
|
||||||
timestamp.setTime_t((unsigned int) date);
|
timestamp.setTime_t(date);
|
||||||
ui->label_restoreHeightDate->setText(timestamp.toString("yyyy-MM-dd"));
|
ui->label_restoreHeightDate->setText(timestamp.toString("yyyy-MM-dd"));
|
||||||
auto blockHeight = m_restoreHeightLookup->dateToRestoreHeight((unsigned int) date);
|
auto blockHeight = m_restoreHeightLookup->dateToRestoreHeight(date);
|
||||||
ui->lineEdit_restoreHeight->setText(QString::number(blockHeight));
|
ui->lineEdit_restoreHeight->setText(QString::number(blockHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int RestoreHeightWidget::getHeight() {
|
int RestoreHeightWidget::getHeight() {
|
||||||
return ui->lineEdit_restoreHeight->text().toUInt();
|
return ui->lineEdit_restoreHeight->text().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
RestoreHeightWidget::~RestoreHeightWidget() {
|
RestoreHeightWidget::~RestoreHeightWidget() {
|
||||||
|
|
|
@ -20,9 +20,9 @@ class RestoreHeightWidget : public QWidget
|
||||||
public:
|
public:
|
||||||
explicit RestoreHeightWidget(QWidget *parent = nullptr);
|
explicit RestoreHeightWidget(QWidget *parent = nullptr);
|
||||||
void initRestoreHeights(RestoreHeightLookup *lookup);
|
void initRestoreHeights(RestoreHeightLookup *lookup);
|
||||||
unsigned int getHeight();
|
int getHeight();
|
||||||
void hideSlider();
|
void hideSlider();
|
||||||
~RestoreHeightWidget();
|
~RestoreHeightWidget() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onValueChanged(int date);
|
void onValueChanged(int date);
|
||||||
|
|
|
@ -40,7 +40,7 @@ private:
|
||||||
Ui::CreateWalletSeedPage *ui;
|
Ui::CreateWalletSeedPage *ui;
|
||||||
|
|
||||||
QString m_mnemonic;
|
QString m_mnemonic;
|
||||||
unsigned int m_restoreHeight;
|
int m_restoreHeight;
|
||||||
|
|
||||||
bool m_roulette = false;
|
bool m_roulette = false;
|
||||||
int m_rouletteSpin = 15;
|
int m_rouletteSpin = 15;
|
||||||
|
|
|
@ -31,7 +31,7 @@ RestorePage::RestorePage(AppContext *ctx, QWidget *parent) :
|
||||||
auto data = Utils::fileOpen(":/assets/mnemonic_25_english.txt");
|
auto data = Utils::fileOpen(":/assets/mnemonic_25_english.txt");
|
||||||
for(const auto &seed_word: data.split('\n'))
|
for(const auto &seed_word: data.split('\n'))
|
||||||
m_words25 << seed_word;
|
m_words25 << seed_word;
|
||||||
for(unsigned int i = 0; i != 2048; i++)
|
for(int i = 0; i != 2048; i++)
|
||||||
m_words14 << QString::fromStdString(wordlist::english.get_word(i));
|
m_words14 << QString::fromStdString(wordlist::english.get_word(i));
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -109,7 +109,7 @@ void RestorePage::cleanupPage() const {}
|
||||||
bool RestorePage::validatePage() {
|
bool RestorePage::validatePage() {
|
||||||
ui->label_errorString->hide();
|
ui->label_errorString->hide();
|
||||||
auto errStyle = "QTextEdit{border: 1px solid red;}";
|
auto errStyle = "QTextEdit{border: 1px solid red;}";
|
||||||
unsigned int restoreHeight = ui->restoreHeightWidget->getHeight();
|
int restoreHeight = ui->restoreHeightWidget->getHeight();
|
||||||
auto seed = ui->seedEdit->toPlainText().replace("\n", "").replace("\r", "").trimmed();
|
auto seed = ui->seedEdit->toPlainText().replace("\n", "").replace("\r", "").trimmed();
|
||||||
auto seedSplit = seed.split(" ");
|
auto seedSplit = seed.split(" ");
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ private:
|
||||||
QLabel *topLabel;
|
QLabel *topLabel;
|
||||||
Ui::RestorePage *ui;
|
Ui::RestorePage *ui;
|
||||||
|
|
||||||
unsigned int m_mode = 14;
|
int m_mode = 14;
|
||||||
QStringList m_words14;
|
QStringList m_words14;
|
||||||
QStringList m_words25;
|
QStringList m_words25;
|
||||||
QStringListModel *m_completer14Model = nullptr;
|
QStringListModel *m_completer14Model = nullptr;
|
||||||
|
|
|
@ -72,7 +72,7 @@ bool ViewOnlyPage::validatePage() {
|
||||||
ui->lineEdit_viewkey->setStyleSheet("");
|
ui->lineEdit_viewkey->setStyleSheet("");
|
||||||
ui->label_errorString->hide();
|
ui->label_errorString->hide();
|
||||||
|
|
||||||
unsigned int restoreHeight = ui->restoreHeightWidget->getHeight();
|
int restoreHeight = ui->restoreHeightWidget->getHeight();
|
||||||
auto spendkey = ui->lineEdit_spendkey->text().trimmed();
|
auto spendkey = ui->lineEdit_spendkey->text().trimmed();
|
||||||
auto viewkey = ui->lineEdit_viewkey->text().trimmed();
|
auto viewkey = ui->lineEdit_viewkey->text().trimmed();
|
||||||
auto address = ui->lineEdit_address->text().trimmed();
|
auto address = ui->lineEdit_address->text().trimmed();
|
||||||
|
|
Loading…
Reference in a new issue