random sietch zaddr

This commit is contained in:
DenioD
2020-01-25 19:21:13 +01:00
parent c525b44a6c
commit 71334360df
6 changed files with 69 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
#include "controller.h"
#include "mainwindow.h"
#include "addressbook.h"
#include "settings.h"
#include "version.h"
@@ -59,7 +59,8 @@ Controller::~Controller() {
delete model;
delete zrpc;
}
// Called when a connection to hushd is available.
void Controller::setConnection(Connection* c) {
if (c == nullptr) return;
@@ -86,9 +87,28 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx) {
Q_ASSERT(allRecepients.is_array());
zrpc->createNewSietchZaddr( [=] (json reply) {
QString zdust = QString::fromStdString(reply[0].get<json::string_t>());
sietch.push_back(zdust);
qDebug()<<sietch;
});
qDebug()<<sietch;
// auto zdust1 = tozdust.addr.toStdString();
// For each addr/amt/memo, construct the JSON and also build the confirm dialog box
for (int i=0; i < tx.toAddrs.size(); i++) {
auto toAddr = tx.toAddrs[i];
/// auto tozdust = tx.toZdust;
// Construct the JSON params
json rec = json::object();
@@ -103,16 +123,21 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx) {
unsigned int MIN_ZOUTS=8;
while (allRecepients.size() < MIN_ZOUTS) {
int decider = qrand() % ((100 + 1) - 1) + 1;// random int between 1 and 100
QString zdust1;
zdust1 = randomSietchZaddr();
QString zdust2;
zdust2 = randomSietchZaddr();
dust["address"] = zdust1.toStdString();
dust["amount"] = 0;
// zdust1 = randomSietchZaddr();
// zdust2 = randomSietchZaddr();
// QString addr = zrpc->createNewSietchZaddr(cb);
//}
// dust["address"] = sietch->toStdString();
// dust["amount"] = 0;
// dust["memo"] = "";
dust1["address"] = zdust2.toStdString();
dust1["amount"] = 0;
//dust1["address"] = zdust2.toStdString();
// dust1["amount"] = 0;
// dust1["memo"] = "";
//50% chance of adding another zdust, shuffle.
@@ -129,9 +154,11 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx) {
}
allRecepients.push_back(rec) ;
}
}
void Controller::noConnection() {
@@ -393,6 +420,7 @@ void Controller::refreshAddresses() {
auto newzaddresses = new QList<QString>();
auto newtaddresses = new QList<QString>();
zrpc->fetchAddresses([=] (json reply) {
auto zaddrs = reply["z_addresses"].get<json::array_t>();
for (auto& it : zaddrs) {
@@ -1277,3 +1305,4 @@ QString Controller::getDefaultTAddress() {
else
return QString();
}

View File

@@ -101,12 +101,18 @@ public:
zrpc->createNewZaddr(sapling, cb);
}, [=](){});
}
void createNewTaddr(const std::function<void(json)>& cb) {
unlockIfEncrypted([=] () {
zrpc->createNewTaddr(cb);
}, [=](){});
}
void createNewSietchZaddr(const std::function<void(json)>& cb) {
unlockIfEncrypted([=] () {
zrpc->createNewSietchZaddr(cb);
}, [=](){});
}
void fetchPrivKey(QString addr, const std::function<void(json)>& cb) {
unlockIfEncrypted([=] () {
zrpc->fetchPrivKey(addr, cb);
@@ -134,12 +140,14 @@ public:
});
}
// void importZPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb) { zrpc->importZPrivKey(addr, rescan, cb); }
// void importTPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb) { zrpc->importTPrivKey(addr, rescan, cb); }
QString getDefaultSaplingAddress();
QString getDefaultTAddress();
private:
void processInfo(const json&);
void refreshBalances();
@@ -154,6 +162,7 @@ private:
void unlockIfEncrypted (std::function<void(void)> cb, std::function<void(void)> error);
QProcess* ehushd = nullptr;
TxTableModel* transactionsTableModel = nullptr;
@@ -172,6 +181,8 @@ private:
// Current balance in the UI. If this number updates, then refresh the UI
QString currentBalance;
QString sietch;
};
#endif // RPCCLIENT_H

View File

@@ -42,6 +42,14 @@ void LiteInterface::createNewZaddr(bool, const std::function<void(json)>& cb) {
conn->doRPCWithDefaultErrorHandling("new", "zs", cb);
}
void LiteInterface::createNewSietchZaddr(const std::function<void(json)>& cb) {
if (conn == nullptr)
return;
conn->doRPCWithDefaultErrorHandling("sietch", "zs", cb);
}
void LiteInterface::createNewTaddr(const std::function<void(json)>& cb) {
if (conn == nullptr)
return;

View File

@@ -55,6 +55,7 @@ public:
void createNewZaddr(bool sapling, const std::function<void(json)>& cb);
void createNewTaddr(const std::function<void(json)>& cb);
void createNewSietchZaddr(const std::function<void(json)>& cb);
void fetchPrivKey(QString addr, const std::function<void(json)>& cb);
void fetchAllPrivKeys(const std::function<void(json)>);
@@ -71,11 +72,13 @@ public:
//void importZPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb);
//void importTPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb);
void sendTransaction(QString params, const std::function<void(json)>& cb, const std::function<void(QString)>& err);
private:
Connection* conn = nullptr;
};
#endif // hushDRPC_H