@@ -5,6 +5,7 @@
|
||||
#include "version.h"
|
||||
#include "camount.h"
|
||||
#include "websockets.h"
|
||||
#include "sietch.h"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -84,19 +85,53 @@ void Controller::setConnection(Connection* c) {
|
||||
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];
|
||||
|
||||
// Construct the JSON params
|
||||
json rec = json::object();
|
||||
json dust = json::object();
|
||||
json dust1 = 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);
|
||||
unsigned int MIN_ZOUTS=8;
|
||||
while (allRecepients.size() < MIN_ZOUTS) {
|
||||
int decider = qrand() % ((100 + 1) - 1) + 1;// random int between 1 and 100
|
||||
QString zdust1;
|
||||
zdust1 = randomSietchZaddr();
|
||||
QString zdust2;
|
||||
zdust2 = randomSietchZaddr();
|
||||
|
||||
dust["address"] = zdust1.toStdString();
|
||||
dust["amount"] = 0;
|
||||
// dust["memo"] = "";
|
||||
dust1["address"] = zdust2.toStdString();
|
||||
dust1["amount"] = 0;
|
||||
// dust1["memo"] = "";
|
||||
|
||||
//50% chance of adding another zdust, shuffle.
|
||||
if (decider % 2) {
|
||||
|
||||
if(decider % 4 == 3) {
|
||||
allRecepients.insert(std::begin(allRecepients),{dust,dust1}) ;
|
||||
std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device());
|
||||
|
||||
}else {
|
||||
allRecepients.insert(std::begin(allRecepients),{dust}) ;
|
||||
std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device());
|
||||
}}
|
||||
|
||||
}
|
||||
allRecepients.push_back(rec) ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Controller::noConnection() {
|
||||
@@ -607,17 +642,19 @@ void Controller::refreshTransactions() {
|
||||
if (!it["outgoing_metadata"].is_null()) {
|
||||
|
||||
for (auto o: it["outgoing_metadata"].get<json::array_t>()) {
|
||||
QString address = QString::fromStdString(o["address"]);
|
||||
|
||||
QString address;
|
||||
|
||||
address = QString::fromStdString(o["address"]);
|
||||
|
||||
// Sent items are -ve
|
||||
CAmount amount = CAmount::fromqint64(-1 * o["value"].get<json::number_unsigned_t>());
|
||||
CAmount amount = CAmount::fromqint64(-1* o["value"].get<json::number_unsigned_t>());
|
||||
|
||||
// Check for Memos
|
||||
|
||||
QString memo;
|
||||
if (!o["memo"].is_null()) {
|
||||
memo = QString::fromStdString(o["memo"]);
|
||||
|
||||
}
|
||||
|
||||
items.push_back(TransactionItemDetail{address, amount, memo});
|
||||
@@ -626,13 +663,21 @@ void Controller::refreshTransactions() {
|
||||
|
||||
{
|
||||
// Concat all the addresses
|
||||
|
||||
QList<QString> addresses;
|
||||
for (auto item : items) {
|
||||
addresses.push_back(item.address);
|
||||
}
|
||||
address = addresses.join(",");
|
||||
|
||||
if (item.amount == 0 ) {
|
||||
|
||||
} else {
|
||||
addresses.push_back(item.address);
|
||||
|
||||
address = addresses.join(","); }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
txdata.push_back(TransactionItem{
|
||||
"send", datetime, address, txid,confirmations, items
|
||||
});
|
||||
|
||||
@@ -383,6 +383,11 @@ void MainWindow::setupStatusBar() {
|
||||
menu.addAction(tr("Copy txid"), [=]() {
|
||||
QGuiApplication::clipboard()->setText(txid);
|
||||
});
|
||||
menu.addAction(tr("Copy block explorer link"), [=]() {
|
||||
// auto explorer = Settings::getInstance()->getExplorer();
|
||||
QGuiApplication::clipboard()->setText("https://explorer.myhush.org/tx/" + txid);
|
||||
});
|
||||
|
||||
menu.addAction(tr("View tx on block explorer"), [=]() {
|
||||
Settings::openTxInExplorer(txid);
|
||||
});
|
||||
@@ -919,6 +924,10 @@ void MainWindow::setupTransactionsTab() {
|
||||
ui->statusBar->showMessage(tr("Copied to clipboard"), 3 * 1000);
|
||||
});
|
||||
}
|
||||
menu.addAction(tr("Copy block explorer link"), [=]() {
|
||||
// auto explorer = Settings::getInstance()->getExplorer();
|
||||
QGuiApplication::clipboard()->setText("https://explorer.myhush.org/tx/" + txid);
|
||||
});
|
||||
|
||||
menu.addAction(tr("View on block explorer"), [=] () {
|
||||
Settings::openTxInExplorer(txid);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "controller.h"
|
||||
#include "recurring.h"
|
||||
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
void MainWindow::setupSendTab() {
|
||||
@@ -501,32 +502,44 @@ 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;
|
||||
|
||||
for (int i=0; i < totalItems; i++) {
|
||||
QString addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") % QString::number(i+1))->text().trimmed();
|
||||
|
||||
// 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 amt;
|
||||
|
||||
|
||||
// Make sure it parses
|
||||
amtStr.toDouble(&ok);
|
||||
if (!ok) {
|
||||
amt = CAmount::fromqint64(-1);
|
||||
|
||||
} 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,} );
|
||||
|
||||
tx.toAddrs.push_back( ToFields{addr, amt, memo} );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
tx.fee = Settings::getMinerFee();
|
||||
|
||||
|
||||
10702
src/sietch.h
Normal file
10702
src/sietch.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1 +1 @@
|
||||
#define APP_VERSION "1.1.4"
|
||||
#define APP_VERSION "1.2.0"
|
||||
|
||||
Reference in New Issue
Block a user