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. 105
      src/controller.cpp

105
src/controller.cpp

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

Loading…
Cancel
Save