diff --git a/lib/Cargo.lock b/lib/Cargo.lock index fcabaa8..1bd2058 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -2308,51 +2308,6 @@ dependencies = [ "zcash_primitives 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", ] -[[package]] -name = "silentdragonlitelib" -version = "0.1.0" -source = "git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc#caaee693c47c2ee9ecd1e1546b8fe3c714f342bc" -dependencies = [ - "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bellman 0.1.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.4.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", - "json 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "log4rs 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", - "prost 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", - "ripemd160 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rust-embed 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "secp256k1 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sodiumoxide 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-rustls 0.10.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tower-grpc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tower-grpc-build 0.1.0 (git+https://github.com/tower-rs/tower-grpc)", - "tower-h2 0.1.0 (git+https://github.com/tower-rs/tower-h2?rev=0865040d699697bbaf1c3b77b3f256b72f98cdf4)", - "tower-request-modifier 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tower-service 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tower-util 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", - "webpki-roots 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_client_backend 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", - "zcash_primitives 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", - "zcash_proofs 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)", -] - [metadata] "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" @@ -2608,4 +2563,3 @@ dependencies = [ "checksum zcash_client_backend 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "" "checksum zcash_primitives 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "" "checksum zcash_proofs 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "" -"checksum silentdragonlitelib 0.1.0 (git+https://github.com/DenioD/silentdragonlite-cli?rev=4d9c09433007e71e259b10f15c28ba1c6ac3efae)" = "" diff --git a/silentdragonlite b/silentdragonlite deleted file mode 100755 index 292d189..0000000 Binary files a/silentdragonlite and /dev/null differ diff --git a/src/balancestablemodel.cpp b/src/balancestablemodel.cpp index 58dcd46..673b3bb 100644 --- a/src/balancestablemodel.cpp +++ b/src/balancestablemodel.cpp @@ -2,12 +2,11 @@ #include "addressbook.h" #include "settings.h" - BalancesTableModel::BalancesTableModel(QObject *parent) : QAbstractTableModel(parent) { } -void BalancesTableModel::setNewData(const QMap balances, +void BalancesTableModel::setNewData(const QMap balances, const QList outputs) { loading = false; @@ -22,7 +21,7 @@ void BalancesTableModel::setNewData(const QMap balances, // Process the address balances into a list delete modeldata; - modeldata = new QList>(); + modeldata = new QList>(); std::for_each(balances.keyBegin(), balances.keyEnd(), [=] (auto keyIt) { if (balances.value(keyIt) > 0) modeldata->push_back(std::make_tuple(keyIt, balances.value(keyIt))); @@ -95,7 +94,7 @@ QVariant BalancesTableModel::data(const QModelIndex &index, int role) const if(role == Qt::ToolTipRole) { switch (index.column()) { case 0: return AddressBook::addLabelToAddress(std::get<0>(modeldata->at(index.row()))); - case 1: return Settings::getUSDFromhushAmount(std::get<1>(modeldata->at(index.row()))); + case 1: return Settings::getUSDFormat(std::get<1>(modeldata->at(index.row()))); } } diff --git a/src/balancestablemodel.h b/src/balancestablemodel.h index 3c41fca..e712f62 100644 --- a/src/balancestablemodel.h +++ b/src/balancestablemodel.h @@ -4,13 +4,14 @@ #include "precompiled.h" #include "datamodel.h" + class BalancesTableModel : public QAbstractTableModel { public: BalancesTableModel(QObject* parent); ~BalancesTableModel(); - void setNewData(const QMap balances, const QList outputs); + void setNewData(const QMap balances, const QList outputs); int rowCount(const QModelIndex &parent) const; int columnCount(const QModelIndex &parent) const; @@ -18,7 +19,7 @@ public: QVariant headerData(int section, Qt::Orientation orientation, int role) const; private: - QList>* modeldata = nullptr; + QList>* modeldata = nullptr; QList* utxos = nullptr; bool loading = true; diff --git a/src/connection.cpp b/src/connection.cpp index fe91567..22ddc1a 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -51,7 +51,7 @@ void ConnectionLoader::doAutoConnect() { litelib_initialize_existing(config->dangerous, config->server.toStdString().c_str()); } else { main->logger->write(QObject::tr("Create/restore wallet.")); - createOrRestore(config->dangerous, config->server); + litelib_initialize_existing(config->dangerous, config->server.toStdString().c_str()); } auto connection = makeConnection(config); diff --git a/src/controller.cpp b/src/controller.cpp index 4906d49..95918e4 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -64,7 +64,7 @@ void Controller::setConnection(Connection* c) { this->zrpc->setConnection(c); - ui->statusBar->showMessage("Ready!"); + ui->statusBar->showMessage("Your hushd is connected"); // See if we need to remove the reindex/rescan flags from the hush.conf file auto hushConfLocation = Settings::getInstance()->gethushdConfLocation(); @@ -96,7 +96,7 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx) { // Construct the JSON params json rec = json::object(); rec["address"] = toAddr.addr.toStdString(); - rec["amount"] = toAddr.amount; + rec["amount"] = toAddr.amount * 10000000; if (Settings::isZAddress(toAddr.addr) && !toAddr.memo.trimmed().isEmpty()) rec["memo"] = toAddr.memo.toStdString(); @@ -120,7 +120,7 @@ void Controller::noConnection() { main->ui->statusBar->showMessage(QObject::tr("No Connection"), 1000); // Clear balances table. - QMap emptyBalances; + QMap emptyBalances; QList emptyOutputs; balancesTableModel->setNewData(emptyBalances, emptyOutputs); @@ -251,7 +251,7 @@ void Controller::updateUI(bool anyUnconfirmed) { }; // Function to process reply of the listunspent and z_listunspent API calls, used below. -bool Controller::processUnspent(const json& reply, QMap* balancesMap, QList* newUtxos) { +bool Controller::processUnspent(const json& reply, QMap* balancesMap, QList* newUtxos) { bool anyUnconfirmed = false; auto processFn = [=](const json& array) { @@ -259,11 +259,11 @@ bool Controller::processUnspent(const json& reply, QMap* balanc QString qsAddr = QString::fromStdString(it["address"]); int block = it["created_in_block"].get(); QString txid = QString::fromStdString(it["created_in_txid"]); - QString amount = Settings::getDecimalString(it["value"].get()); + QString amount = Settings::getDecimalString(it["value"].get()); newUtxos->push_back(UnspentOutput{ qsAddr, txid, amount, block, true }); - (*balancesMap)[qsAddr] = (*balancesMap)[qsAddr] + it["value"].get(); + (*balancesMap)[qsAddr] = ((*balancesMap)[qsAddr] + it["value"].get()) /10000000; } }; @@ -279,26 +279,28 @@ void Controller::refreshBalances() { // 1. Get the Balances zrpc->fetchBalance([=] (json reply) { - auto balT = reply["tbalance"].get(); - auto balZ = reply["zbalance"].get(); + auto balT = reply["tbalance"].get(); + auto balZ = reply["zbalance"].get(); auto balTotal = balT + balZ; AppDataModel::getInstance()->setBalances(balT, balZ); - ui->balSheilded ->setText(Settings::gethushDisplayFormat(balZ)); - ui->balTransparent->setText(Settings::gethushDisplayFormat(balT)); - ui->balTotal ->setText(Settings::gethushDisplayFormat(balTotal)); + ui->balSheilded ->setText(Settings::gethushDisplayFormat(balZ /10000000)); + ui->balTransparent->setText(Settings::gethushDisplayFormat(balT /10000000)); + ui->balTotal ->setText(Settings::gethushDisplayFormat(balTotal /10000000)); - ui->balSheilded ->setToolTip(Settings::gethushDisplayFormat(balZ)); - ui->balTransparent->setToolTip(Settings::gethushDisplayFormat(balT)); - ui->balTotal ->setToolTip(Settings::gethushDisplayFormat(balTotal)); + ui->balSheilded ->setToolTip(Settings::gethushDisplayFormat(balZ /10000000)); + ui->balTransparent->setToolTip(Settings::gethushDisplayFormat(balT /10000000)); + ui->balTotal ->setToolTip(Settings::gethushDisplayFormat(balTotal /10000000)); + + }); // 2. Get the UTXOs // First, create a new UTXO list. It will be replacing the existing list when everything is processed. auto newUtxos = new QList(); - auto newBalances = new QMap(); + auto newBalances = new QMap(); // Call the Transparent and Z unspent APIs serially and then, once they're done, update the UI zrpc->fetchUnspent([=] (json reply) { @@ -323,7 +325,7 @@ void Controller::refreshTransactions() { for (auto& it : reply.get()) { QString address; - qint64 total_amount; + double total_amount; QList items; // First, check if there's outgoing metadata @@ -331,7 +333,7 @@ void Controller::refreshTransactions() { for (auto o: it["outgoing_metadata"].get()) { QString address = QString::fromStdString(o["address"]); - qint64 amount = -1 * o["value"].get(); // Sent items are -ve + double amount = -1 * o["value"].get() /10000000;// Sent items are -ve QString memo; if (!o["memo"].is_null()) { @@ -353,7 +355,7 @@ void Controller::refreshTransactions() { it["datetime"].get(), address, QString::fromStdString(it["txid"]), - model->getLatestBlock() - it["block_height"].get(), + model->getLatestBlock() - it["block_height"].get(), items }); } else { @@ -363,7 +365,7 @@ void Controller::refreshTransactions() { items.push_back(TransactionItemDetail{ address, - it["amount"].get(), + it["amount"].get(), "" }); @@ -509,7 +511,7 @@ void Controller::refreshhushPrice() { return noConnection(); // TODO: use/render all this data - QUrl cmcURL("https://api.coingecko.com/api/v3/simple/price?ids=hush&vs_currencies=btc%2Cusd%2Ceur&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true"); + QUrl cmcURL("ncies=btc%2Cusd%2Ceur&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true"); QNetworkRequest req; req.setUrl(cmcURL); @@ -544,7 +546,7 @@ void Controller::refreshhushPrice() { qDebug() << "Parsed JSON"; const json& item = parsed.get(); - const json& hush = item["hush"].get(); + const json& hush = item["Hush"].get(); if (hush["usd"] >= 0) { qDebug() << "Found hush key in price json"; diff --git a/src/controller.h b/src/controller.h index 28a2653..852ee6b 100644 --- a/src/controller.h +++ b/src/controller.h @@ -78,7 +78,7 @@ private: void refreshTransactions(); - bool processUnspent (const json& reply, QMap* newBalances, QList* newUtxos); + bool processUnspent (const json& reply, QMap* newBalances, QList* newUtxos); void updateUI (bool anyUnconfirmed); void getInfoThenRefresh(bool force); diff --git a/src/datamodel.cpp b/src/datamodel.cpp index 60990c4..d86259c 100644 --- a/src/datamodel.cpp +++ b/src/datamodel.cpp @@ -7,7 +7,7 @@ DataModel::DataModel() { QWriteLocker locker(lock); utxos = new QList(); - balances = new QMap(); + balances = new QMap(); usedAddresses = new QMap(); zaddresses = new QList(); taddresses = new QList(); @@ -44,7 +44,7 @@ void DataModel::replaceTaddresses(QList* newT) { taddresses = newT; } -void DataModel::replaceBalances(QMap* newBalances) { +void DataModel::replaceBalances(QMap* newBalances) { QWriteLocker locker(lock); Q_ASSERT(newBalances); diff --git a/src/datamodel.h b/src/datamodel.h index f69b3d8..c3dd12c 100644 --- a/src/datamodel.h +++ b/src/datamodel.h @@ -18,7 +18,7 @@ class DataModel { public: void replaceZaddresses(QList* newZ); void replaceTaddresses(QList* newZ); - void replaceBalances(QMap* newBalances); + void replaceBalances(QMap* newBalances); void replaceUTXOs(QList* utxos); void markAddressUsed(QString address); @@ -29,8 +29,8 @@ public: const QList getAllZAddresses() { QReadLocker locker(lock); return *zaddresses; } const QList getAllTAddresses() { QReadLocker locker(lock); return *taddresses; } const QList getUTXOs() { QReadLocker locker(lock); return *utxos; } - const QMap getAllBalances() { QReadLocker locker(lock); return *balances; } - const QMap getUsedAddresses() { QReadLocker locker(lock); return *usedAddresses; } + const QMap getAllBalances() { QReadLocker locker(lock); return *balances; } + const QMap getUsedAddresses() { QReadLocker locker(lock); return *usedAddresses; } DataModel(); @@ -39,7 +39,7 @@ private: int latestBlock; QList* utxos = nullptr; - QMap* balances = nullptr; + QMap* balances = nullptr; QMap* usedAddresses = nullptr; QList* zaddresses = nullptr; QList* taddresses = nullptr; diff --git a/src/liteinterface.h b/src/liteinterface.h index 860824c..5e71cb4 100644 --- a/src/liteinterface.h +++ b/src/liteinterface.h @@ -11,7 +11,7 @@ using json = nlohmann::json; // into a struct with address, amount, memo struct TransactionItemDetail { QString address; - qint64 amount; + double amount; QString memo; }; @@ -45,6 +45,7 @@ public: const std::function& err); void fetchBalance(const std::function& cb); + void createNewZaddr(bool sapling, const std::function& cb); void createNewTaddr(const std::function& cb); diff --git a/src/mainwindow.h b/src/mainwindow.h index 16107f3..bdb86ef 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -17,7 +17,7 @@ using json = nlohmann::json; // Struct used to hold destination info when sending a Tx. struct ToFields { QString addr; - qint64 amount; + double amount; QString memo; }; @@ -25,7 +25,7 @@ struct ToFields { struct Tx { QString fromAddr; QList toAddrs; - qint64 fee; + double fee; }; namespace Ui { diff --git a/src/settings.cpp b/src/settings.cpp index 52dbc6b..ab9a1c6 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -315,7 +315,7 @@ bool Settings::removeFromhushConf(QString confLocation, QString option) { } double Settings::getMinerFee() { - return 10000; + return 0.01; } double Settings::getZboardAmount() {