Merge pull request #79 from MyHush/denio
create random Sietch zaddr with sdl-cli lib
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)",
|
||||||
"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]]
|
[[package]]
|
||||||
@@ -1467,7 +1467,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "silentdragonlitelib"
|
name = "silentdragonlitelib"
|
||||||
version = "0.1.0"
|
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 = [
|
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/DenioD/librustzcash.git?rev=caaee693c47c2ee9ecd1e1546b8fe3c714f342bc)",
|
"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_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 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 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 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 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"
|
"checksum sodiumoxide 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585232e78a4fc18133eef9946d3080befdf68b906c51b621531c37e91787fa2b"
|
||||||
|
|||||||
@@ -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"
|
||||||
silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "b5534d6f830b9af2e6a2992d67c99fea2ef5f21a" }
|
silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "015e1617ab836481b0fd7c357ac2977191964730" }
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
#include "addressbook.h"
|
#include "addressbook.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "camount.h"
|
#include "camount.h"
|
||||||
#include "websockets.h"
|
#include "websockets.h"
|
||||||
#include "sietch.h"
|
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
@@ -60,6 +60,7 @@ Controller::~Controller() {
|
|||||||
delete zrpc;
|
delete zrpc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Called when a connection to hushd is available.
|
// Called when a connection to hushd is available.
|
||||||
void Controller::setConnection(Connection* c) {
|
void Controller::setConnection(Connection* c) {
|
||||||
if (c == nullptr) return;
|
if (c == nullptr) return;
|
||||||
@@ -79,60 +80,480 @@ void Controller::setConnection(Connection* c) {
|
|||||||
// Force update, because this might be coming from a settings update
|
// Force update, because this might be coming from a settings update
|
||||||
// where we need to immediately refresh
|
// where we need to immediately refresh
|
||||||
refresh(true);
|
refresh(true);
|
||||||
|
|
||||||
|
// Create Sietch zdust addr at startup.
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch.txt");
|
||||||
|
QFile file(path);
|
||||||
|
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch1.txt");
|
||||||
|
QFile file(path);
|
||||||
|
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch2.txt");
|
||||||
|
QFile file(path);
|
||||||
|
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch3.txt");
|
||||||
|
QFile file(path);
|
||||||
|
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch4.txt");
|
||||||
|
QFile file(path);
|
||||||
|
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch5.txt");
|
||||||
|
QFile file(path);
|
||||||
|
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch6.txt");
|
||||||
|
QFile file(path);
|
||||||
|
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch7.txt");
|
||||||
|
QFile file(path);
|
||||||
|
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch8.txt");
|
||||||
|
QFile file(path);
|
||||||
|
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch9.txt");
|
||||||
|
QFile file(path);
|
||||||
|
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the RPC JSON Parameters for this tx
|
// Build the RPC JSON Parameters for this tx
|
||||||
void Controller::fillTxJsonParams(json& allRecepients, Tx tx) {
|
void Controller::fillTxJsonParams(json& allRecepients, Tx tx) {
|
||||||
Q_ASSERT(allRecepients.is_array());
|
Q_ASSERT(allRecepients.is_array());
|
||||||
|
|
||||||
|
|
||||||
// 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];
|
|
||||||
|
|
||||||
// Construct the JSON params
|
// Construct the JSON params
|
||||||
json rec = json::object();
|
json rec = json::object();
|
||||||
json dust = json::object();
|
json dust = json::object();
|
||||||
json dust1 = json::object();
|
json dust1 = json::object();
|
||||||
|
json dust2 = json::object();
|
||||||
|
json dust3 = json::object();
|
||||||
|
json dust4 = json::object();
|
||||||
|
json dust5 = json::object();
|
||||||
|
json dust6 = json::object();
|
||||||
|
json dust7 = json::object();
|
||||||
|
json dust8 = json::object();
|
||||||
|
json dust9 = json::object();
|
||||||
|
// Create Sietch zdust addr again to not use it twice.
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch.txt");
|
||||||
|
QFile file(path);
|
||||||
|
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch1.txt");
|
||||||
|
QFile file(path);
|
||||||
|
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch2.txt");
|
||||||
|
QFile file(path);
|
||||||
|
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch3.txt");
|
||||||
|
QFile file(path);
|
||||||
|
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch4.txt");
|
||||||
|
QFile file(path);
|
||||||
|
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch5.txt");
|
||||||
|
QFile file(path);
|
||||||
|
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch6.txt");
|
||||||
|
QFile file(path);
|
||||||
|
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch7.txt");
|
||||||
|
QFile file(path);
|
||||||
|
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch8.txt");
|
||||||
|
QFile file(path);
|
||||||
|
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
|
||||||
|
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch9.txt");
|
||||||
|
QFile file(path);
|
||||||
|
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
if(!file.open(QIODevice::WriteOnly)){
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QTextStream out(&file); out << zdust.toUtf8();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
// Set sietch zdust addr to json.
|
||||||
|
|
||||||
|
QString path= (QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)) + QString("/Sietch.txt");
|
||||||
|
QFile inputFile(path);
|
||||||
|
|
||||||
|
|
||||||
|
if (inputFile.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
QTextStream in(&inputFile);
|
||||||
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine();
|
||||||
|
dust["address"] = line.toStdString();
|
||||||
|
}
|
||||||
|
inputFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString path1= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch1.txt");
|
||||||
|
QFile inputFile1(path1);
|
||||||
|
|
||||||
|
if (inputFile1.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
QTextStream in(&inputFile1);
|
||||||
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine();
|
||||||
|
QString zdust = line;
|
||||||
|
|
||||||
|
dust1["address"] = zdust.toStdString();
|
||||||
|
}
|
||||||
|
inputFile1.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString path2= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch2.txt");
|
||||||
|
QFile inputFile2(path2);
|
||||||
|
if (inputFile2.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
QTextStream in(&inputFile2);
|
||||||
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine();
|
||||||
|
dust2["address"] = line.toStdString();
|
||||||
|
}
|
||||||
|
inputFile2.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString path3= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch3.txt");
|
||||||
|
QFile inputFile3(path3);
|
||||||
|
if (inputFile3.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
QTextStream in(&inputFile3);
|
||||||
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine();
|
||||||
|
dust3["address"] = line.toStdString();
|
||||||
|
}
|
||||||
|
inputFile3.close();
|
||||||
|
}
|
||||||
|
QString path4= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch4.txt");
|
||||||
|
QFile inputFile4(path4);
|
||||||
|
if (inputFile4.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
QTextStream in(&inputFile4);
|
||||||
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine();
|
||||||
|
dust4["address"] = line.toStdString();
|
||||||
|
}
|
||||||
|
inputFile4.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString path5= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch5.txt");
|
||||||
|
QFile inputFile5(path5);
|
||||||
|
if (inputFile5.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
QTextStream in(&inputFile5);
|
||||||
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine();
|
||||||
|
dust5["address"] = line.toStdString();
|
||||||
|
}
|
||||||
|
inputFile5.close();
|
||||||
|
}
|
||||||
|
QString path6= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch6.txt");
|
||||||
|
QFile inputFile6(path6);
|
||||||
|
if (inputFile6.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
QTextStream in(&inputFile6);
|
||||||
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine();
|
||||||
|
dust6["address"] = line.toStdString();
|
||||||
|
}
|
||||||
|
inputFile6.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString path7= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch7.txt");
|
||||||
|
QFile inputFile7(path7);
|
||||||
|
if (inputFile7.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
QTextStream in(&inputFile7);
|
||||||
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine();
|
||||||
|
dust7["address"] = line.toStdString();
|
||||||
|
}
|
||||||
|
inputFile7.close();
|
||||||
|
}
|
||||||
|
QString path8= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch8.txt");
|
||||||
|
QFile inputFile8(path8);
|
||||||
|
if (inputFile8.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
QTextStream in(&inputFile8);
|
||||||
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine();
|
||||||
|
dust8["address"] = line.toStdString();
|
||||||
|
}
|
||||||
|
inputFile.close();
|
||||||
|
}
|
||||||
|
QString path9= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch9.txt");
|
||||||
|
QFile inputFile9(path9);
|
||||||
|
if (inputFile9.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
QTextStream in(&inputFile9);
|
||||||
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine();
|
||||||
|
dust9["address"] = line.toStdString();
|
||||||
|
}
|
||||||
|
inputFile9.close();
|
||||||
|
}
|
||||||
|
// 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];
|
||||||
|
|
||||||
rec["address"] = toAddr.addr.toStdString();
|
rec["address"] = toAddr.addr.toStdString();
|
||||||
rec["amount"] = toAddr.amount.toqint64();
|
rec["amount"] = toAddr.amount.toqint64();
|
||||||
if (Settings::isZAddress(toAddr.addr) && !toAddr.memo.trimmed().isEmpty())
|
if (Settings::isZAddress(toAddr.addr) && !toAddr.memo.trimmed().isEmpty())
|
||||||
rec["memo"] = toAddr.memo.toStdString();
|
rec["memo"] = toAddr.memo.toStdString();
|
||||||
|
|
||||||
unsigned int MIN_ZOUTS=8;
|
dust["amount"] = 0;
|
||||||
while (allRecepients.size() < MIN_ZOUTS) {
|
dust["memo"] = "";
|
||||||
int decider = qrand() % ((100 + 1) - 1) + 1;// random int between 1 and 100
|
dust1["amount"] = 0;
|
||||||
QString zdust1;
|
dust1["memo"] = "";
|
||||||
zdust1 = randomSietchZaddr();
|
dust2["amount"] = 0;
|
||||||
QString zdust2;
|
dust2["memo"] = "";
|
||||||
zdust2 = randomSietchZaddr();
|
dust3["amount"] = 0;
|
||||||
|
dust3["memo"] = "";
|
||||||
|
dust4["amount"] = 0;
|
||||||
|
dust4["memo"] = "";
|
||||||
|
dust5["amount"] = 0;
|
||||||
|
dust5["memo"] = "";
|
||||||
|
dust6["amount"] = 0;
|
||||||
|
dust6["memo"] = "";
|
||||||
|
dust7["amount"] = 0;
|
||||||
|
dust7["memo"] = "";
|
||||||
|
dust8["amount"] = 0;
|
||||||
|
dust8["memo"] = "";
|
||||||
|
dust9["amount"] = 0;
|
||||||
|
dust9["memo"] = "";
|
||||||
|
|
||||||
dust["address"] = zdust1.toStdString();
|
int decider = qrand() % ((100 + 1)-1)+ 1;// random int between 1 and 100
|
||||||
dust["amount"] = 0;
|
|
||||||
// dust["memo"] = "";
|
|
||||||
dust1["address"] = zdust2.toStdString();
|
|
||||||
dust1["amount"] = 0;
|
|
||||||
// dust1["memo"] = "";
|
|
||||||
|
|
||||||
//50% chance of adding another zdust, shuffle.
|
//50% chance of adding another zdust, shuffle.
|
||||||
if (decider % 2) {
|
|
||||||
|
|
||||||
if(decider % 4 == 3) {
|
if(decider % 4 == 3) {
|
||||||
allRecepients.insert(std::begin(allRecepients),{dust,dust1}) ;
|
allRecepients.insert(std::begin(allRecepients),{dust,dust1,dust2,dust3,dust4,dust5,dust6,dust7,dust8}) ;
|
||||||
std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device());
|
std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device());
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
allRecepients.insert(std::begin(allRecepients),{dust}) ;
|
allRecepients.insert(std::begin(allRecepients),{dust,dust1,dust2,dust3,dust4,dust5,dust6,dust7,dust8,dust9}) ;
|
||||||
std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device());
|
std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device());
|
||||||
}}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
allRecepients.push_back(rec) ;
|
allRecepients.push_back(rec) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Controller::noConnection() {
|
void Controller::noConnection() {
|
||||||
QIcon i = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical);
|
QIcon i = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical);
|
||||||
@@ -393,6 +814,7 @@ void Controller::refreshAddresses() {
|
|||||||
auto newzaddresses = new QList<QString>();
|
auto newzaddresses = new QList<QString>();
|
||||||
auto newtaddresses = new QList<QString>();
|
auto newtaddresses = new QList<QString>();
|
||||||
|
|
||||||
|
|
||||||
zrpc->fetchAddresses([=] (json reply) {
|
zrpc->fetchAddresses([=] (json reply) {
|
||||||
auto zaddrs = reply["z_addresses"].get<json::array_t>();
|
auto zaddrs = reply["z_addresses"].get<json::array_t>();
|
||||||
for (auto& it : zaddrs) {
|
for (auto& it : zaddrs) {
|
||||||
@@ -1277,3 +1699,7 @@ QString Controller::getDefaultTAddress() {
|
|||||||
else
|
else
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -101,12 +101,18 @@ public:
|
|||||||
zrpc->createNewZaddr(sapling, cb);
|
zrpc->createNewZaddr(sapling, cb);
|
||||||
}, [=](){});
|
}, [=](){});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void createNewTaddr(const std::function<void(json)>& cb) {
|
void createNewTaddr(const std::function<void(json)>& cb) {
|
||||||
unlockIfEncrypted([=] () {
|
unlockIfEncrypted([=] () {
|
||||||
zrpc->createNewTaddr(cb);
|
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) {
|
void fetchPrivKey(QString addr, const std::function<void(json)>& cb) {
|
||||||
unlockIfEncrypted([=] () {
|
unlockIfEncrypted([=] () {
|
||||||
zrpc->fetchPrivKey(addr, cb);
|
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 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); }
|
// void importTPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb) { zrpc->importTPrivKey(addr, rescan, cb); }
|
||||||
|
|
||||||
QString getDefaultSaplingAddress();
|
QString getDefaultSaplingAddress();
|
||||||
QString getDefaultTAddress();
|
QString getDefaultTAddress();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void processInfo(const json&);
|
void processInfo(const json&);
|
||||||
void refreshBalances();
|
void refreshBalances();
|
||||||
@@ -154,6 +162,7 @@ private:
|
|||||||
|
|
||||||
void unlockIfEncrypted (std::function<void(void)> cb, std::function<void(void)> error);
|
void unlockIfEncrypted (std::function<void(void)> cb, std::function<void(void)> error);
|
||||||
|
|
||||||
|
|
||||||
QProcess* ehushd = nullptr;
|
QProcess* ehushd = nullptr;
|
||||||
|
|
||||||
TxTableModel* transactionsTableModel = nullptr;
|
TxTableModel* transactionsTableModel = nullptr;
|
||||||
@@ -172,6 +181,8 @@ private:
|
|||||||
|
|
||||||
// Current balance in the UI. If this number updates, then refresh the UI
|
// Current balance in the UI. If this number updates, then refresh the UI
|
||||||
QString currentBalance;
|
QString currentBalance;
|
||||||
|
QString sietch;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // RPCCLIENT_H
|
#endif // RPCCLIENT_H
|
||||||
|
|||||||
@@ -42,6 +42,14 @@ void LiteInterface::createNewZaddr(bool, const std::function<void(json)>& cb) {
|
|||||||
conn->doRPCWithDefaultErrorHandling("new", "zs", 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) {
|
void LiteInterface::createNewTaddr(const std::function<void(json)>& cb) {
|
||||||
if (conn == nullptr)
|
if (conn == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public:
|
|||||||
|
|
||||||
void createNewZaddr(bool sapling, const std::function<void(json)>& cb);
|
void createNewZaddr(bool sapling, const std::function<void(json)>& cb);
|
||||||
void createNewTaddr(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 fetchPrivKey(QString addr, const std::function<void(json)>& cb);
|
||||||
void fetchAllPrivKeys(const std::function<void(json)>);
|
void fetchAllPrivKeys(const std::function<void(json)>);
|
||||||
@@ -72,10 +73,12 @@ public:
|
|||||||
//void importZPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb);
|
//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 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);
|
void sendTransaction(QString params, const std::function<void(json)>& cb, const std::function<void(QString)>& err);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Connection* conn = nullptr;
|
Connection* conn = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hushDRPC_H
|
#endif // hushDRPC_H
|
||||||
|
|||||||
10702
src/sietch.h
10702
src/sietch.h
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user