Use latest block instead of info
This commit is contained in:
6
lib/Cargo.lock
generated
6
lib/Cargo.lock
generated
@@ -1051,7 +1051,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=af0e0b9b2bcc131804d5e940f94d45c6fef74481)",
|
"zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=61dc063fe155d1510e9a074e5a3577a0621f8c3a)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2266,7 +2266,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "zecwalletlitelib"
|
name = "zecwalletlitelib"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/adityapk00/zecwallet-light-cli?rev=af0e0b9b2bcc131804d5e940f94d45c6fef74481#af0e0b9b2bcc131804d5e940f94d45c6fef74481"
|
source = "git+https://github.com/adityapk00/zecwallet-light-cli?rev=61dc063fe155d1510e9a074e5a3577a0621f8c3a#61dc063fe155d1510e9a074e5a3577a0621f8c3a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bellman 0.1.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)",
|
"bellman 0.1.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)",
|
||||||
@@ -2562,4 +2562,4 @@ dependencies = [
|
|||||||
"checksum zcash_client_backend 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>"
|
"checksum zcash_client_backend 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>"
|
||||||
"checksum zcash_primitives 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>"
|
"checksum zcash_primitives 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>"
|
||||||
"checksum zcash_proofs 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>"
|
"checksum zcash_proofs 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>"
|
||||||
"checksum zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=af0e0b9b2bcc131804d5e940f94d45c6fef74481)" = "<none>"
|
"checksum zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=61dc063fe155d1510e9a074e5a3577a0621f8c3a)" = "<none>"
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ crate-type = ["staticlib"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2.58"
|
libc = "0.2.58"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
zecwalletlitelib = { git = "https://github.com/adityapk00/zecwallet-light-cli", rev = "af0e0b9b2bcc131804d5e940f94d45c6fef74481" }
|
zecwalletlitelib = { git = "https://github.com/adityapk00/zecwallet-light-cli", rev = "61dc063fe155d1510e9a074e5a3577a0621f8c3a" }
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ void ConnectionLoader::doAutoConnect() {
|
|||||||
main->logger->write(QObject::tr("Attempting to initialize library with ") + config->server);
|
main->logger->write(QObject::tr("Attempting to initialize library with ") + config->server);
|
||||||
|
|
||||||
// Check to see if there's an existing wallet
|
// Check to see if there's an existing wallet
|
||||||
if (litelib_wallet_exists(Settings::getChainName().toStdString().c_str())) {
|
if (litelib_wallet_exists(Settings::getDefaultChainName().toStdString().c_str())) {
|
||||||
main->logger->write(QObject::tr("Using existing wallet."));
|
main->logger->write(QObject::tr("Using existing wallet."));
|
||||||
char* resp = litelib_initialize_existing(config->dangerous, config->server.toStdString().c_str());
|
char* resp = litelib_initialize_existing(config->dangerous, config->server.toStdString().c_str());
|
||||||
QString response = litelib_process_response(resp);
|
QString response = litelib_process_response(resp);
|
||||||
@@ -68,9 +68,10 @@ void ConnectionLoader::doAutoConnect() {
|
|||||||
auto me = this;
|
auto me = this;
|
||||||
|
|
||||||
// After the lib is initialized, try to do get info
|
// After the lib is initialized, try to do get info
|
||||||
connection->doRPC("info", "", [=](auto) {
|
connection->doRPC("info", "", [=](auto reply) {
|
||||||
// If success, set the connection
|
// If success, set the connection
|
||||||
main->logger->write("Connection is online.");
|
main->logger->write("Connection is online.");
|
||||||
|
connection->setInfo(reply);
|
||||||
|
|
||||||
isSyncing = new QAtomicInteger<bool>();
|
isSyncing = new QAtomicInteger<bool>();
|
||||||
isSyncing->store(true);
|
isSyncing->store(true);
|
||||||
|
|||||||
@@ -123,8 +123,12 @@ public:
|
|||||||
|
|
||||||
void showTxError(const QString& error);
|
void showTxError(const QString& error);
|
||||||
|
|
||||||
|
json getInfo() { return serverInfo; }
|
||||||
|
void setInfo(const json& info) { serverInfo = info; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool shutdownInProgress = false;
|
bool shutdownInProgress = false;
|
||||||
|
json serverInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ void Controller::setConnection(Connection* c) {
|
|||||||
|
|
||||||
ui->statusBar->showMessage("Ready!");
|
ui->statusBar->showMessage("Ready!");
|
||||||
|
|
||||||
|
processInfo(c->getInfo());
|
||||||
|
|
||||||
// If we're allowed to get the Zec Price, get the prices
|
// If we're allowed to get the Zec Price, get the prices
|
||||||
if (Settings::getInstance()->getAllowFetchPrices())
|
if (Settings::getInstance()->getAllowFetchPrices())
|
||||||
refreshZECPrice();
|
refreshZECPrice();
|
||||||
@@ -137,42 +139,46 @@ void Controller::refresh(bool force) {
|
|||||||
getInfoThenRefresh(force);
|
getInfoThenRefresh(force);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::processInfo(const json& info) {
|
||||||
|
// Testnet?
|
||||||
|
QString chainName;
|
||||||
|
if (!info["chain_name"].is_null()) {
|
||||||
|
chainName = QString::fromStdString(info["chain_name"].get<json::string_t>());
|
||||||
|
Settings::getInstance()->setTestnet(chainName == "test");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
QString version = QString::fromStdString(info["version"].get<json::string_t>());
|
||||||
|
Settings::getInstance()->setZcashdVersion(version);
|
||||||
|
|
||||||
|
// Recurring pamynets are testnet only
|
||||||
|
if (!Settings::getInstance()->isTestnet())
|
||||||
|
main->disableRecurring();
|
||||||
|
}
|
||||||
|
|
||||||
void Controller::getInfoThenRefresh(bool force) {
|
void Controller::getInfoThenRefresh(bool force) {
|
||||||
if (!zrpc->haveConnection())
|
if (!zrpc->haveConnection())
|
||||||
return noConnection();
|
return noConnection();
|
||||||
|
|
||||||
static bool prevCallSucceeded = false;
|
static bool prevCallSucceeded = false;
|
||||||
|
|
||||||
zrpc->fetchInfo([=] (const json& reply) {
|
zrpc->fetchLatestBlock([=] (const json& reply) {
|
||||||
prevCallSucceeded = true;
|
prevCallSucceeded = true;
|
||||||
|
|
||||||
// Testnet?
|
int curBlock = reply["height"].get<json::number_integer_t>();
|
||||||
QString chainName;
|
|
||||||
if (!reply["chain_name"].is_null()) {
|
|
||||||
chainName = QString::fromStdString(reply["chain_name"].get<json::string_t>());
|
|
||||||
Settings::getInstance()->setTestnet(chainName == "test");
|
|
||||||
};
|
|
||||||
|
|
||||||
// Recurring pamynets are testnet only
|
|
||||||
if (!Settings::getInstance()->isTestnet())
|
|
||||||
main->disableRecurring();
|
|
||||||
|
|
||||||
int curBlock = reply["latest_block_height"].get<json::number_integer_t>();
|
|
||||||
bool doUpdate = force || (model->getLatestBlock() != curBlock);
|
bool doUpdate = force || (model->getLatestBlock() != curBlock);
|
||||||
model->setLatestBlock(curBlock);
|
model->setLatestBlock(curBlock);
|
||||||
|
|
||||||
// Connected, so display checkmark.
|
// Connected, so display checkmark.
|
||||||
auto tooltip = Settings::getInstance()->getSettings().server + "\n" + QString::fromStdString(reply.dump());
|
auto tooltip = Settings::getInstance()->getSettings().server + "\n" +
|
||||||
|
QString::fromStdString(zrpc->getConnection()->getInfo().dump());
|
||||||
QIcon i(":/icons/res/connected.gif");
|
QIcon i(":/icons/res/connected.gif");
|
||||||
|
QString chainName = Settings::getInstance()->isTestnet() ? "test" : "main";
|
||||||
main->statusLabel->setText(chainName + "(" + QString::number(curBlock) + ")");
|
main->statusLabel->setText(chainName + "(" + QString::number(curBlock) + ")");
|
||||||
main->statusLabel->setToolTip(tooltip);
|
main->statusLabel->setToolTip(tooltip);
|
||||||
main->statusIcon->setPixmap(i.pixmap(16, 16));
|
main->statusIcon->setPixmap(i.pixmap(16, 16));
|
||||||
main->statusIcon->setToolTip(tooltip);
|
main->statusIcon->setToolTip(tooltip);
|
||||||
|
|
||||||
//int version = reply["version"].get<json::string_t>();
|
|
||||||
int version = 1;
|
|
||||||
Settings::getInstance()->setZcashdVersion(version);
|
|
||||||
|
|
||||||
// See if recurring payments needs anything
|
// See if recurring payments needs anything
|
||||||
Recurring::getInstance()->processPending(main);
|
Recurring::getInstance()->processPending(main);
|
||||||
|
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ public:
|
|||||||
QString getDefaultTAddress();
|
QString getDefaultTAddress();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void processInfo(const json&);
|
||||||
void refreshBalances();
|
void refreshBalances();
|
||||||
|
|
||||||
void refreshTransactions();
|
void refreshTransactions();
|
||||||
|
|||||||
@@ -130,6 +130,15 @@ void LiteInterface::fetchInfo(const std::function<void(json)>& cb,
|
|||||||
conn->doRPC("info", "", cb, err);
|
conn->doRPC("info", "", cb, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LiteInterface::fetchLatestBlock(const std::function<void(json)>& cb,
|
||||||
|
const std::function<void(QString)>& err) {
|
||||||
|
if (conn == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
conn->doRPC("height", "", cb, err);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to get all the private keys for both z and t addresses. It will make 2 batch calls,
|
* Method to get all the private keys for both z and t addresses. It will make 2 batch calls,
|
||||||
* combine the result, and call the callback with a single list containing both the t-addr and z-addr
|
* combine the result, and call the callback with a single list containing both the t-addr and z-addr
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ public:
|
|||||||
|
|
||||||
void fetchInfo(const std::function<void(json)>& cb,
|
void fetchInfo(const std::function<void(json)>& cb,
|
||||||
const std::function<void(QString)>& err);
|
const std::function<void(QString)>& err);
|
||||||
|
|
||||||
|
void fetchLatestBlock(const std::function<void(json)>& cb,
|
||||||
|
const std::function<void(QString)>& err);
|
||||||
|
|
||||||
void fetchBalance(const std::function<void(json)>& cb);
|
void fetchBalance(const std::function<void(json)>& cb);
|
||||||
|
|
||||||
|
|||||||
@@ -74,11 +74,11 @@ bool Settings::isTAddress(QString addr) {
|
|||||||
return addr.startsWith("t");
|
return addr.startsWith("t");
|
||||||
}
|
}
|
||||||
|
|
||||||
int Settings::getZcashdVersion() {
|
QString Settings::getZcashdVersion() {
|
||||||
return _zcashdVersion;
|
return _zcashdVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setZcashdVersion(int version) {
|
void Settings::setZcashdVersion(QString version) {
|
||||||
_zcashdVersion = version;
|
_zcashdVersion = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ public:
|
|||||||
bool isSyncing();
|
bool isSyncing();
|
||||||
void setSyncing(bool syncing);
|
void setSyncing(bool syncing);
|
||||||
|
|
||||||
int getZcashdVersion();
|
QString getZcashdVersion();
|
||||||
void setZcashdVersion(int version);
|
void setZcashdVersion(QString version);
|
||||||
|
|
||||||
void setUseEmbedded(bool r) { _useEmbedded = r; }
|
void setUseEmbedded(bool r) { _useEmbedded = r; }
|
||||||
bool useEmbedded() { return _useEmbedded; }
|
bool useEmbedded() { return _useEmbedded; }
|
||||||
@@ -95,12 +95,11 @@ public:
|
|||||||
|
|
||||||
static bool isValidAddress(QString addr);
|
static bool isValidAddress(QString addr);
|
||||||
|
|
||||||
static QString getChainName() { return QString("main"); }
|
static QString getDefaultChainName() { return QString("main"); }
|
||||||
|
|
||||||
static const QString labelRegExp;
|
static const QString labelRegExp;
|
||||||
|
|
||||||
static const int updateSpeed = 20 * 1000; // 20 sec
|
static const int updateSpeed = 60 * 1000; // 60 sec
|
||||||
static const int quickUpdateSpeed = 5 * 1000; // 5 sec
|
|
||||||
static const int priceRefreshSpeed = 60 * 60 * 1000; // 1 hr
|
static const int priceRefreshSpeed = 60 * 60 * 1000; // 1 hr
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -114,7 +113,7 @@ private:
|
|||||||
bool _isTestnet = false;
|
bool _isTestnet = false;
|
||||||
bool _isSyncing = false;
|
bool _isSyncing = false;
|
||||||
int _blockNumber = 0;
|
int _blockNumber = 0;
|
||||||
int _zcashdVersion = 0;
|
QString _zcashdVersion = 0;
|
||||||
bool _useEmbedded = false;
|
bool _useEmbedded = false;
|
||||||
bool _headless = false;
|
bool _headless = false;
|
||||||
|
|
||||||
|
|||||||
@@ -70,15 +70,18 @@ bool TxTableModel::exportToCsv(QString fileName) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString TxTableModel::concatMultipleMemos(const TransactionItem& dat) const {
|
QString TxTableModel::concatMultipleMemos(const TransactionItem& dat) const {
|
||||||
// Concat all the memos
|
if (dat.items.length() == 1) {
|
||||||
QString memo;
|
return dat.items[0].memo;
|
||||||
for (auto item : dat.items) {
|
} else {
|
||||||
if (!item.memo.trimmed().isEmpty()) {
|
// Concat all the memos
|
||||||
memo += item.address + ": \"" + item.memo + "\"\n";
|
QString memo;
|
||||||
|
for (auto item : dat.items) {
|
||||||
|
if (!item.memo.trimmed().isEmpty()) {
|
||||||
|
memo += item.address + ": \"" + item.memo + "\"\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return memo;
|
||||||
}
|
}
|
||||||
|
|
||||||
return memo;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QVariant TxTableModel::data(const QModelIndex &index, int role) const {
|
QVariant TxTableModel::data(const QModelIndex &index, int role) const {
|
||||||
|
|||||||
Reference in New Issue
Block a user