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 // 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
json extraTransaction = json::object();
extraTransaction["address"] = addressWithMaxValue.toStdString();
extraTransaction["amount"] = 12000;
extraTransaction["memo"] = randomMemo.toStdString();
// Replace one sietch transaction dust.at(i)["address"] = addressWithMaxValue.toStdString();
if (!dust.empty()) { dust.at(i)["amount"] = 10000;
dust.front() = extraTransaction; dust.at(i)["memo"] = randomMemo.toStdString();
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) { it["amount"] = 0;
if (!extraTransactionAdded || it["address"] != addressWithMaxValue.toStdString()) { }
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++)
@ -230,57 +217,21 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
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 ; ; // 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()

Loading…
Cancel
Save