From 1fcaed8e724857fd65e7c9bfe15694e8b91fb887 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sun, 5 Jan 2020 11:22:32 +0100 Subject: [PATCH] add a 50% chance of another zdust --- src/controller.cpp | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index 3332ee1..da8a5b0 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -93,6 +93,7 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx) { // Construct the JSON params json rec = json::object(); json dust = json::object(); + json dust1 = json::object(); rec["address"] = toAddr.addr.toStdString(); rec["amount"] = toAddr.amount.toqint64(); @@ -101,19 +102,32 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx) { unsigned int MIN_ZOUTS=8; while (allRecepients.size() < MIN_ZOUTS) { + int decider = qrand() % ((100 + 1) - 0) + 1;// random int between 1 and 100 QString zdust1; zdust1 = randomSietchZaddr(); - - + QString zdust2; + zdust2 = randomSietchZaddr(); + dust["address"] = zdust1.toStdString(); dust["amount"] = 0; - dust["memo"] = ""; - - - allRecepients.insert(std::begin(allRecepients),{dust}) ; - - } + // dust["memo"] = ""; + dust1["address"] = zdust2.toStdString(); + dust1["amount"] = 0; + // dust1["memo"] = ""; + //50% chance of adding another zdust, shuffle. + if (decider % 2) { + + if(decider % 4 == 3) { + allRecepients.insert(std::begin(allRecepients),{dust,dust1}) ; + std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device()); + + }else { + allRecepients.insert(std::begin(allRecepients),{dust}) ; + std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device()); + }} + + } allRecepients.push_back(rec) ; } @@ -628,8 +642,9 @@ void Controller::refreshTransactions() { if (!it["outgoing_metadata"].is_null()) { for (auto o: it["outgoing_metadata"].get()) { - QString address = QString::fromStdString(o["address"]); - + + QString address = QString::fromStdString(o["address"]); + // Sent items are -ve CAmount amount = CAmount::fromqint64(-1 * o["value"].get()); @@ -647,11 +662,14 @@ void Controller::refreshTransactions() { { // Concat all the addresses + QList addresses; for (auto item : items) { - addresses.push_back(item.address); - } - address = addresses.join(","); + + + addresses.push_back(item.address); + + address = addresses.join(",");} } txdata.push_back(TransactionItem{