Browse Source

seperate dust and normal transaction

pull/139/head
Deniod 4 months ago
parent
commit
618625bc00
  1. 35
      src/controller.cpp

35
src/controller.cpp

@ -140,8 +140,10 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
json rec = json::object(); json rec = json::object();
//creating the JSON dust parameters in a std::vector to iterate over there during tx //creating the JSON dust parameters in a std::vector to iterate over there during tx
std::vector<json> dust(8); std::vector<json> dustTransactions(8);
dust.resize(8, json::object()); for (auto& dust : dustTransactions) {
dust = json::object();
}
// Create Sietch zdust addr again to not use it twice. // Create Sietch zdust addr again to not use it twice.
// Using DataStore singelton, to store the data outside of lambda, bing bada boom :D // Using DataStore singelton, to store the data outside of lambda, bing bada boom :D
@ -156,7 +158,7 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
// Using DataStore singelton, to store the data into the dust. // Using DataStore singelton, to store the data into the dust.
for(uint8_t i = 0; i < 8; i++) for(uint8_t i = 0; i < 8; i++)
{ {
dust.at(i)["address"] = DataStore::getSietchDataStore()->getData(QString("Sietch" + QString(i))).toStdString(); dustTransactions.at(i)["address"] = DataStore::getSietchDataStore()->getData(QString("Sietch" + QString(i))).toStdString();
} }
DataStore::getSietchDataStore()->clear(); // clears the datastore DataStore::getSietchDataStore()->clear(); // clears the datastore
@ -184,15 +186,15 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
randomString.append(nextChar); randomString.append(nextChar);
} }
dust.at(i)["memo"] = randomString.toStdString(); dustTransactions.at(i)["memo"] = randomString.toStdString();
} }
CAmount balanceAvailable = getModel()->getBalVerified(); CAmount balanceAvailable = getModel()->getBalVerified();
// Create more Notes if spendableNotesCount < 30 and enough funds are available // Create more Notes if spendableNotesCount < 30 and enough funds are available
if (spendableNotesCount < 30 && balanceAvailable.toDecimalString().toDouble() > (dust.size() * 0.0001)) { if (spendableNotesCount < 30 && balanceAvailable.toDecimalString().toDouble() > (dustTransactions.size() * 0.0001)) {
// Create extra transaction // Create extra transaction
for (size_t i = 0; i < dust.size(); ++i) { for (size_t i = 0; i < dustTransactions.size(); ++i) {
// Generate random memo // Generate random memo
QString randomMemo; QString randomMemo;
for (int j = 0; j < randomStringLength; ++j) { for (int j = 0; j < randomStringLength; ++j) {
@ -200,28 +202,27 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
randomMemo.append(possibleCharacters.at(index)); randomMemo.append(possibleCharacters.at(index));
} }
dust.at(i)["address"] = addressWithMaxValue.toStdString(); dustTransactions.at(i)["address"] = addressWithMaxValue.toStdString();
dust.at(i)["amount"] = 10000; dustTransactions.at(i)["amount"] = 10000;
dust.at(i)["memo"] = randomMemo.toStdString(); dustTransactions.at(i)["memo"] = randomMemo.toStdString();
} }
} else { } else {
// Set amount for real Sietch transaction to 0 // Set amount for real Sietch transaction to 0
for (auto &it : dust) { for (auto &it : dustTransactions) {
it["amount"] = 0; it["amount"] = 0;
} }
} }
// For each addr/amt/memo, construct the JSON and also build the confirm dialog box // For each addr/amt/memo, construct the JSON and also build the confirm dialog box
for (int i=0; i < tx.toAddrs.size(); i++) for (const auto& toAddr : tx.toAddrs) {
{ json rec = json::object();
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();
}
allRecepients.push_back(rec); allRecepients.push_back(rec);
}
int decider = rand() % 100 + 1; int decider = rand() % 100 + 1;
@ -231,7 +232,7 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
} }
for (int i = 0; i < dustCount; ++i) { for (int i = 0; i < dustCount; ++i) {
allRecepients.insert(allRecepients.begin(), dust.at(i)); allRecepients.insert(allRecepients.begin(), dustTransactions.at(i));
} }
} }

Loading…
Cancel
Save