Browse Source

replace sietch transactions with the new note automatic if spendable notes < 30

pull/139/head
Deniod 4 months ago
parent
commit
c802a55bac
  1. 89
      src/controller.cpp

89
src/controller.cpp

@ -188,40 +188,27 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
} }
// Create more Notes if spendableNotesCount < 7 // Create more Notes if spendableNotesCount < 30
bool extraTransactionAdded = false; if (spendableNotesCount < 30) {
// Create extra transaction
if (spendableNotesCount < 7) { for (size_t i = 0; i < dust.size(); ++i) {
// Create a random memo for that // Generate random memo
QString randomMemo; QString randomMemo;
for (int i = 0; i < randomStringLength; ++i) { for (int j = 0; j < randomStringLength; ++j) {
int index = QRandomGenerator::system()->bounded(0, possibleCharacters.length()); int index = QRandomGenerator::system()->bounded(0, possibleCharacters.length());
randomMemo.append(possibleCharacters.at(index)); randomMemo.append(possibleCharacters.at(index));
} }
// create the transaction dust.at(i)["address"] = addressWithMaxValue.toStdString();
json extraTransaction = json::object(); dust.at(i)["amount"] = 10000;
extraTransaction["address"] = addressWithMaxValue.toStdString(); dust.at(i)["memo"] = randomMemo.toStdString();
extraTransaction["amount"] = 12000;
extraTransaction["memo"] = randomMemo.toStdString();
// Replace one sietch transaction
if (!dust.empty()) {
dust.front() = extraTransaction;
extraTransactionAdded = true;
} else {
dust.push_back(extraTransaction);
extraTransactionAdded = true;
} }
} } else {
// Set amount for real Sietch transaction to 0
// Set amount = 0 to all sietch transactions for (auto &it : dust) {
for(auto &it: dust) {
if (!extraTransactionAdded || it["address"] != addressWithMaxValue.toStdString()) {
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 (int i=0; i < tx.toAddrs.size(); i++)
@ -231,56 +218,20 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
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);
} }
int decider = rand() % 100 + 1 ; ; // random int between 1 and 100 allRecepients.push_back(rec);
if (tx.toAddrs.size() < 2) {
if(decider % 4 == 3) { int decider = rand() % 100 + 1;
allRecepients.insert(std::begin(allRecepients), {
dust.at(0),
dust.at(1),
dust.at(2),
dust.at(3),
dust.at(4),
dust.at(5)
}) ;
} else { int dustCount = (decider % 4 == 3) ? 5 : 6;
allRecepients.insert(std::begin(allRecepients), { if (tx.toAddrs.size() < 2) {
dust.at(0), dustCount++;
dust.at(1),
dust.at(2),
dust.at(3),
dust.at(4),
dust.at(5),
dust.at(6)
}) ;
} }
} else {
if(decider % 4 == 3) { for (int i = 0; i < dustCount; ++i) {
allRecepients.insert(std::begin(allRecepients), { allRecepients.insert(allRecepients.begin(), dust.at(i));
dust.at(0),
dust.at(1),
dust.at(2),
dust.at(3),
dust.at(4)
}) ;
} else {
allRecepients.insert(std::begin(allRecepients), {
dust.at(0),
dust.at(1),
dust.at(2),
dust.at(3),
dust.at(4),
dust.at(5)
}) ;
} }
}
} }
void Controller::noConnection() void Controller::noConnection()

Loading…
Cancel
Save