Browse Source

first implementation of Sietch in SDL

pull/69/head
DenioD 4 years ago
parent
commit
162dbf6823
  1. 64
      src/controller.cpp
  2. 26
      src/sendtab.cpp
  3. 1497
      src/sietch.h

64
src/controller.cpp

@ -5,6 +5,7 @@
#include "version.h"
#include "camount.h"
#include "websockets.h"
#include "sietch.h"
using json = nlohmann::json;
@ -83,20 +84,79 @@ void Controller::setConnection(Connection* c) {
// Build the RPC JSON Parameters for this tx
void Controller::fillTxJsonParams(json& allRecepients, Tx tx) {
Q_ASSERT(allRecepients.is_array());
// For each addr/amt/memo, construct the JSON and also build the confirm dialog box
for (int i=0; i < tx.toAddrs.size(); i++) {
auto toAddr = tx.toAddrs[i];
// auto zdust1 = randomSietchZaddr[i];
// Construct the JSON params
json rec = json::object();
json dust = json::object();
json dust1 = json::object();
json dust2 = json::object();
json dust3 = json::object();
json dust4 = json::object();
json dust5 = json::object();
json dust6 = json::object();
json dust7 = json::object();
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 = 1 + GetRandInt(100); // random int between 1 and 100
//for (int i=0; i < 7; i++) {
// auto zdust12 = zdust12[i];
QString zdust1;
zdust1 = randomSietchZaddr();
QString zdust2;
zdust2 = randomSietchZaddr1();
QString zdust3;
zdust3 = randomSietchZaddr2();
QString zdust4;
zdust4 = randomSietchZaddr3();
QString zdust5;
zdust5 = randomSietchZaddr4();
QString zdust6;
zdust6 = randomSietchZaddr5();
QString zdust7;
zdust7 = randomSietchZaddr6();
dust["address"] = zdust1.toStdString();
dust["amount"] = 0;
dust1["address"] = zdust2.toStdString();
dust1["amount"] = 0;
dust2["address"] = zdust3.toStdString();
dust2["amount"] = 0;
dust3["address"] = zdust4.toStdString();
dust3["amount"] = 0;
dust4["address"] = zdust5.toStdString();
dust4["amount"] = 0;
dust5["address"] = zdust6.toStdString();
dust5["amount"] = 0;
dust6["address"] = zdust7.toStdString();
dust6["amount"] = 0;
allRecepients.insert(std::begin(allRecepients),{dust,dust1,dust2,dust3,dust4,dust5,dust6}) ;
allRecepients.push_back(rec);
}
;
}
void Controller::noConnection() {

26
src/sendtab.cpp

@ -501,31 +501,49 @@ Tx MainWindow::createTxFromSendPage() {
// For each addr/amt in the sendTo tab
int totalItems = ui->sendToWidgets->children().size() - 2; // The last one is a spacer, so ignore that
CAmount totalAmt;
QString zdust1 = "zs1qz5rtm3wtw7amtuxardk4xzu0xdqnffch5m9egext76wm25wwfjuvwdjttun8rt4mhh2yt4pmtr";
QString zdust2 = "zs1jfduw8t0dnhqt220cjgvx5d49hnt99jcfj0tmhcdzkc0rtylex5n4m63f77dz4s684gvztv5dvs";
for (int i=0; i < totalItems; i++) {
QString addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") % QString::number(i+1))->text().trimmed();
//addr.insert(QString(addr), QString(zdust1));
// for (zdust = "zs1qfqf5l5kum5v8mpu67ddexswyyylfkx724rz3f32pqsp0p5qu3hespkmc7m04uajy7mmujtjtw8");
// addrbefore.insert("1");
// QString addr = addrbefore + dustaddr;
// Remove label if it exists
addr = AddressBook::addressFromAddressLabel(addr);
// QString dustamt = "0";
QString amtStr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Amount") % QString::number(i+1))->text().trimmed();
if (amtStr.isEmpty()) {
amtStr = "-1";; // The user didn't specify an amount
}
bool ok;
// CAmount amtbefore;
CAmount amt;
CAmount amtdust;
amtdust= CAmount::fromDecimalString(0);
// Make sure it parses
amtStr.toDouble(&ok);
if (!ok) {
amt = CAmount::fromqint64(-1);
//amtdust = 0;
} else {
amt = CAmount::fromDecimalString(amtStr);
totalAmt = totalAmt + amt;
}
QString memo = ui->sendToWidgets->findChild<QLabel*>(QString("MemoTxt") % QString::number(i+1))->text().trimmed();
tx.toAddrs.push_back( ToFields{addr, amt, memo,} );
QString memobefore = ui->sendToWidgets->findChild<QLabel*>(QString("MemoTxt") % QString::number(i+1))->text().trimmed();
QString memodust = "Hallo";
QString memo = memobefore ;
tx.toAddrs.push_back( ToFields{addr, amt, memo,zdust1,amtdust,memodust,} );
// tx.toAddrs1.push_back( tx.toAddrs(addr, amt, memo) );
}
tx.fee = Settings::getMinerFee();

1497
src/sietch.h

File diff suppressed because it is too large
Loading…
Cancel
Save