switch to Hush as Unit
This commit is contained in:
46
lib/Cargo.lock
generated
46
lib/Cargo.lock
generated
@@ -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)" = "<none>"
|
||||
"checksum zcash_primitives 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "<none>"
|
||||
"checksum zcash_proofs 0.0.0 (git+https://github.com/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)" = "<none>"
|
||||
"checksum silentdragonlitelib 0.1.0 (git+https://github.com/DenioD/silentdragonlite-cli?rev=4d9c09433007e71e259b10f15c28ba1c6ac3efae)" = "<none>"
|
||||
|
||||
BIN
silentdragonlite
BIN
silentdragonlite
Binary file not shown.
@@ -2,12 +2,11 @@
|
||||
#include "addressbook.h"
|
||||
#include "settings.h"
|
||||
|
||||
|
||||
BalancesTableModel::BalancesTableModel(QObject *parent)
|
||||
: QAbstractTableModel(parent) {
|
||||
}
|
||||
|
||||
void BalancesTableModel::setNewData(const QMap<QString, qint64> balances,
|
||||
void BalancesTableModel::setNewData(const QMap<QString, double> balances,
|
||||
const QList<UnspentOutput> outputs)
|
||||
{
|
||||
loading = false;
|
||||
@@ -22,7 +21,7 @@ void BalancesTableModel::setNewData(const QMap<QString, qint64> balances,
|
||||
|
||||
// Process the address balances into a list
|
||||
delete modeldata;
|
||||
modeldata = new QList<std::tuple<QString, qint64>>();
|
||||
modeldata = new QList<std::tuple<QString, double>>();
|
||||
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())));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
#include "precompiled.h"
|
||||
#include "datamodel.h"
|
||||
|
||||
|
||||
class BalancesTableModel : public QAbstractTableModel
|
||||
{
|
||||
public:
|
||||
BalancesTableModel(QObject* parent);
|
||||
~BalancesTableModel();
|
||||
|
||||
void setNewData(const QMap<QString, qint64> balances, const QList<UnspentOutput> outputs);
|
||||
void setNewData(const QMap<QString, double> balances, const QList<UnspentOutput> 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<std::tuple<QString, qint64>>* modeldata = nullptr;
|
||||
QList<std::tuple<QString, double>>* modeldata = nullptr;
|
||||
QList<UnspentOutput>* utxos = nullptr;
|
||||
|
||||
bool loading = true;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<QString, qint64> emptyBalances;
|
||||
QMap<QString, double> emptyBalances;
|
||||
QList<UnspentOutput> 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<QString, qint64>* balancesMap, QList<UnspentOutput>* newUtxos) {
|
||||
bool Controller::processUnspent(const json& reply, QMap<QString, double>* balancesMap, QList<UnspentOutput>* newUtxos) {
|
||||
bool anyUnconfirmed = false;
|
||||
|
||||
auto processFn = [=](const json& array) {
|
||||
@@ -259,11 +259,11 @@ bool Controller::processUnspent(const json& reply, QMap<QString, qint64>* balanc
|
||||
QString qsAddr = QString::fromStdString(it["address"]);
|
||||
int block = it["created_in_block"].get<json::number_unsigned_t>();
|
||||
QString txid = QString::fromStdString(it["created_in_txid"]);
|
||||
QString amount = Settings::getDecimalString(it["value"].get<json::number_unsigned_t>());
|
||||
QString amount = Settings::getDecimalString(it["value"].get<json::number_float_t>());
|
||||
|
||||
newUtxos->push_back(UnspentOutput{ qsAddr, txid, amount, block, true });
|
||||
|
||||
(*balancesMap)[qsAddr] = (*balancesMap)[qsAddr] + it["value"].get<json::number_unsigned_t>();
|
||||
(*balancesMap)[qsAddr] = ((*balancesMap)[qsAddr] + it["value"].get<json::number_float_t>()) /10000000;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -279,26 +279,28 @@ void Controller::refreshBalances() {
|
||||
|
||||
// 1. Get the Balances
|
||||
zrpc->fetchBalance([=] (json reply) {
|
||||
auto balT = reply["tbalance"].get<json::number_unsigned_t>();
|
||||
auto balZ = reply["zbalance"].get<json::number_unsigned_t>();
|
||||
auto balT = reply["tbalance"].get<json::number_float_t>();
|
||||
auto balZ = reply["zbalance"].get<json::number_float_t>();
|
||||
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<UnspentOutput>();
|
||||
auto newBalances = new QMap<QString, qint64>();
|
||||
auto newBalances = new QMap<QString, double>();
|
||||
|
||||
// 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<json::array_t>()) {
|
||||
QString address;
|
||||
qint64 total_amount;
|
||||
double total_amount;
|
||||
QList<TransactionItemDetail> items;
|
||||
|
||||
// First, check if there's outgoing metadata
|
||||
@@ -331,7 +333,7 @@ void Controller::refreshTransactions() {
|
||||
|
||||
for (auto o: it["outgoing_metadata"].get<json::array_t>()) {
|
||||
QString address = QString::fromStdString(o["address"]);
|
||||
qint64 amount = -1 * o["value"].get<json::number_integer_t>(); // Sent items are -ve
|
||||
double amount = -1 * o["value"].get<json::number_float_t>() /10000000;// Sent items are -ve
|
||||
|
||||
QString memo;
|
||||
if (!o["memo"].is_null()) {
|
||||
@@ -353,7 +355,7 @@ void Controller::refreshTransactions() {
|
||||
it["datetime"].get<json::number_unsigned_t>(),
|
||||
address,
|
||||
QString::fromStdString(it["txid"]),
|
||||
model->getLatestBlock() - it["block_height"].get<json::number_unsigned_t>(),
|
||||
model->getLatestBlock() - it["block_height"].get<json::number_unsigned_t>(),
|
||||
items
|
||||
});
|
||||
} else {
|
||||
@@ -363,7 +365,7 @@ void Controller::refreshTransactions() {
|
||||
|
||||
items.push_back(TransactionItemDetail{
|
||||
address,
|
||||
it["amount"].get<json::number_integer_t>(),
|
||||
it["amount"].get<json::number_float_t>(),
|
||||
""
|
||||
});
|
||||
|
||||
@@ -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<json::object_t>();
|
||||
const json& hush = item["hush"].get<json::object_t>();
|
||||
const json& hush = item["Hush"].get<json::object_t>();
|
||||
|
||||
if (hush["usd"] >= 0) {
|
||||
qDebug() << "Found hush key in price json";
|
||||
|
||||
@@ -78,7 +78,7 @@ private:
|
||||
|
||||
void refreshTransactions();
|
||||
|
||||
bool processUnspent (const json& reply, QMap<QString, qint64>* newBalances, QList<UnspentOutput>* newUtxos);
|
||||
bool processUnspent (const json& reply, QMap<QString, double>* newBalances, QList<UnspentOutput>* newUtxos);
|
||||
void updateUI (bool anyUnconfirmed);
|
||||
|
||||
void getInfoThenRefresh(bool force);
|
||||
|
||||
@@ -7,7 +7,7 @@ DataModel::DataModel() {
|
||||
QWriteLocker locker(lock);
|
||||
|
||||
utxos = new QList<UnspentOutput>();
|
||||
balances = new QMap<QString, qint64>();
|
||||
balances = new QMap<QString, double>();
|
||||
usedAddresses = new QMap<QString, bool>();
|
||||
zaddresses = new QList<QString>();
|
||||
taddresses = new QList<QString>();
|
||||
@@ -44,7 +44,7 @@ void DataModel::replaceTaddresses(QList<QString>* newT) {
|
||||
taddresses = newT;
|
||||
}
|
||||
|
||||
void DataModel::replaceBalances(QMap<QString, qint64>* newBalances) {
|
||||
void DataModel::replaceBalances(QMap<QString, double>* newBalances) {
|
||||
QWriteLocker locker(lock);
|
||||
Q_ASSERT(newBalances);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class DataModel {
|
||||
public:
|
||||
void replaceZaddresses(QList<QString>* newZ);
|
||||
void replaceTaddresses(QList<QString>* newZ);
|
||||
void replaceBalances(QMap<QString, qint64>* newBalances);
|
||||
void replaceBalances(QMap<QString, double>* newBalances);
|
||||
void replaceUTXOs(QList<UnspentOutput>* utxos);
|
||||
|
||||
void markAddressUsed(QString address);
|
||||
@@ -29,8 +29,8 @@ public:
|
||||
const QList<QString> getAllZAddresses() { QReadLocker locker(lock); return *zaddresses; }
|
||||
const QList<QString> getAllTAddresses() { QReadLocker locker(lock); return *taddresses; }
|
||||
const QList<UnspentOutput> getUTXOs() { QReadLocker locker(lock); return *utxos; }
|
||||
const QMap<QString, qint64> getAllBalances() { QReadLocker locker(lock); return *balances; }
|
||||
const QMap<QString, bool> getUsedAddresses() { QReadLocker locker(lock); return *usedAddresses; }
|
||||
const QMap<QString, double> getAllBalances() { QReadLocker locker(lock); return *balances; }
|
||||
const QMap<QString, bool> getUsedAddresses() { QReadLocker locker(lock); return *usedAddresses; }
|
||||
|
||||
|
||||
DataModel();
|
||||
@@ -39,7 +39,7 @@ private:
|
||||
int latestBlock;
|
||||
|
||||
QList<UnspentOutput>* utxos = nullptr;
|
||||
QMap<QString, qint64>* balances = nullptr;
|
||||
QMap<QString, double>* balances = nullptr;
|
||||
QMap<QString, bool>* usedAddresses = nullptr;
|
||||
QList<QString>* zaddresses = nullptr;
|
||||
QList<QString>* taddresses = nullptr;
|
||||
|
||||
@@ -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<void(QString)>& err);
|
||||
|
||||
void fetchBalance(const std::function<void(json)>& cb);
|
||||
|
||||
|
||||
void createNewZaddr(bool sapling, const std::function<void(json)>& cb);
|
||||
void createNewTaddr(const std::function<void(json)>& cb);
|
||||
|
||||
@@ -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<ToFields> toAddrs;
|
||||
qint64 fee;
|
||||
double fee;
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
|
||||
@@ -315,7 +315,7 @@ bool Settings::removeFromhushConf(QString confLocation, QString option) {
|
||||
}
|
||||
|
||||
double Settings::getMinerFee() {
|
||||
return 10000;
|
||||
return 0.01;
|
||||
}
|
||||
|
||||
double Settings::getZboardAmount() {
|
||||
|
||||
Reference in New Issue
Block a user