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

This commit is contained in:
Deniod
2024-01-12 11:11:00 +01:00
parent fb1626d11d
commit c802a55bac

View File

@@ -188,39 +188,26 @@ 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 { } else {
dust.push_back(extraTransaction); // Set amount for real Sietch transaction to 0
extraTransactionAdded = true;
}
}
// 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
@@ -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); 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 (tx.toAddrs.size() < 2) {
dustCount++;
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)
}) ;
}
} }
for (int i = 0; i < dustCount; ++i) {
allRecepients.insert(allRecepients.begin(), dust.at(i));
}
} }
void Controller::noConnection() void Controller::noConnection()