Browse Source

random sietch zaddr

pull/79/head
DenioD 4 years ago
parent
commit
71334360df
  1. 6
      lib/Cargo.lock
  2. 2
      lib/Cargo.toml
  3. 55
      src/controller.cpp
  4. 13
      src/controller.h
  5. 8
      src/liteinterface.cpp
  6. 3
      src/liteinterface.h

6
lib/Cargo.lock

@ -1051,7 +1051,7 @@ version = "0.1.0"
dependencies = [
"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)",
"silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=b5534d6f830b9af2e6a2992d67c99fea2ef5f21a)",
"silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=015e1617ab836481b0fd7c357ac2977191964730)",
]
[[package]]
@ -1467,7 +1467,7 @@ dependencies = [
[[package]]
name = "silentdragonlitelib"
version = "0.1.0"
source = "git+https://github.com/MyHush/silentdragonlite-cli?rev=b5534d6f830b9af2e6a2992d67c99fea2ef5f21a#b5534d6f830b9af2e6a2992d67c99fea2ef5f21a"
source = "git+https://github.com/MyHush/silentdragonlite-cli?rev=015e1617ab836481b0fd7c357ac2977191964730#015e1617ab836481b0fd7c357ac2977191964730"
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)",
@ -2481,7 +2481,7 @@ dependencies = [
"checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2"
"checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35"
"checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d"
"checksum silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=b5534d6f830b9af2e6a2992d67c99fea2ef5f21a)" = "<none>"
"checksum silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=015e1617ab836481b0fd7c357ac2977191964730)" = "<none>"
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
"checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7"
"checksum sodiumoxide 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585232e78a4fc18133eef9946d3080befdf68b906c51b621531c37e91787fa2b"

2
lib/Cargo.toml

@ -11,4 +11,4 @@ crate-type = ["staticlib"]
[dependencies]
libc = "0.2.58"
lazy_static = "1.4.0"
silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "b5534d6f830b9af2e6a2992d67c99fea2ef5f21a" }
silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "015e1617ab836481b0fd7c357ac2977191964730" }

55
src/controller.cpp

@ -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();
}

13
src/controller.h

@ -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

8
src/liteinterface.cpp

@ -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;

3
src/liteinterface.h

@ -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

Loading…
Cancel
Save