From fe6f38d0bd34ef998dd9474d1fd04fdfd95bebb1 Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Fri, 21 May 2021 17:04:41 -0400
Subject: [PATCH 01/20] Prevent Rust from falling victim to trailing slashitis
---
src/settings.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/settings.cpp b/src/settings.cpp
index 09f9d63..e5bed3d 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -30,6 +30,11 @@ Config Settings::getSettings() {
bool sticky = s.value("connection/stickyServer").toBool();
bool torOnly = s.value("connection/torOnly").toBool();
+ while (server.endsWith("/")) {
+ // trailing slashes make Rust sad
+ server.chop(1);
+ }
+
// Users that have old configs generated from old SDLs will have this hostname
if(server == malicious or server == (QString("https://") + malicious)) {
qDebug() << "Replacing malicious SDL server with " << server;
From d826ca8c923a8f99b8ce7477bdc5b12ba14c105d Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sat, 29 May 2021 12:06:37 -0400
Subject: [PATCH 02/20] Abort when we see corrupted ciphertext
---
src/Chat/Chat.cpp | 8 ++-
src/controller.cpp | 126 +++++++++++++++------------------------------
2 files changed, 44 insertions(+), 90 deletions(-)
diff --git a/src/Chat/Chat.cpp b/src/Chat/Chat.cpp
index f446f58..2bd7d68 100644
--- a/src/Chat/Chat.cpp
+++ b/src/Chat/Chat.cpp
@@ -22,8 +22,7 @@ void ChatMemoEdit::updateDisplayChat() {
if (lenDisplayLabelchat)
lenDisplayLabelchat->setStyleSheet("");
- }
- else {
+ } else {
// Overweight
if (sendChatButton)
sendChatButton->setEnabled(false);
@@ -62,8 +61,7 @@ void ChatMemoEditRequest::updateDisplayChatRequest() {
if (lenDisplayLabelchatRequest)
lenDisplayLabelchatRequest->setStyleSheet("");
- }
- else {
+ } else {
// Overweight
if (sendRequestButton)
sendRequestButton->setEnabled(false);
@@ -85,6 +83,7 @@ void ChatMemoEditRequest::SetSendRequestButton(QPushButton* button) {
void ChatMemoEditRequest::setLenDisplayLabelChatRequest(QLabel* label) {
this->lenDisplayLabelchatRequest = label;
}
+
void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
{
@@ -140,4 +139,3 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
}
}
-
diff --git a/src/controller.cpp b/src/controller.cpp
index edb76c5..e415084 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -980,8 +980,7 @@ void Controller::refreshTransactions() {
memo = QString::fromStdString(o["memo"].get());
if (memo.startsWith("{")) {
- try
- {
+ try {
QJsonDocument headermemo = QJsonDocument::fromJson(memo.toUtf8());
cid = headermemo["cid"].toString();
@@ -990,10 +989,8 @@ void Controller::refreshTransactions() {
chatModel->addCid(txid, cid);
chatModel->addHeader(txid, headerbytes);
- }
- catch (...)
- {
- // on any exception caught
+ } catch (...) {
+ qDebug() << "Invalid JSON in memo detected! memo=" << memo;
}
}
@@ -1002,18 +999,14 @@ void Controller::refreshTransactions() {
if (confirmations > getLag())
{
isNotarized = true;
- }
- else
- {
+ } else {
isNotarized = false;
}
if (chatModel->getCidByTx(txid) != QString("0xdeadbeef"))
{
cid = chatModel->getCidByTx(txid);
- }
- else
- {
+ } else {
cid = "";
}
@@ -1021,18 +1014,14 @@ void Controller::refreshTransactions() {
if (chatModel->getHeaderByTx(txid) != QString("0xdeadbeef"))
{
headerbytes = chatModel->getHeaderByTx(txid);
- }
- else
- {
+ } else {
headerbytes = "";
}
if (main->getPubkeyByAddress(address) != QString("0xdeadbeef"))
{
publickey = main->getPubkeyByAddress(address);
- }
- else
- {
+ } else {
publickey = "";
}
@@ -1163,9 +1152,7 @@ void Controller::refreshTransactions() {
"send", datetime, address, txid,confirmations, items
});
- }
- else
- {
+ } else {
{ // Incoming Transaction
address = (it["address"].is_null() ? "" : QString::fromStdString(it["address"]));
@@ -1175,10 +1162,9 @@ void Controller::refreshTransactions() {
if (!it["memo"].is_null()) {
memo = QString::fromStdString(it["memo"]);
}
- items.push_back(TransactionItemDetail{
- address,
+ items.push_back(TransactionItemDetail{ address,
CAmount::fromqint64(it["amount"].get()),
- memo
+ memo
});
TransactionItem tx{
@@ -1186,102 +1172,73 @@ void Controller::refreshTransactions() {
};
txdata.push_back(tx);
-
-
- QString type;
- QString publickey;
- QString headerbytes;
- QString cid;
- QString requestZaddr;
- QString contactname;
- bool isContact;
+ QString type = "";
+ QString publickey = "";
+ QString headerbytes = "";
+ QString cid = "";
+ QString requestZaddr = "";
+ QString contactname = "";
+ bool isContact = false;
if (!it["memo"].is_null()) {
if (memo.startsWith("{")) {
- try
- {
+ try {
QJsonDocument headermemo = QJsonDocument::fromJson(memo.toUtf8());
- cid = headermemo["cid"].toString();
- type = headermemo["t"].toString();
- requestZaddr = headermemo["z"].toString();
- headerbytes = headermemo["e"].toString();
- publickey = headermemo["p"].toString();
+ cid = headermemo["cid"].toString();
+ type = headermemo["t"].toString();
+ requestZaddr = headermemo["z"].toString();
+ headerbytes = headermemo["e"].toString();
+ publickey = headermemo["p"].toString();
- chatModel->addCid(txid, cid);
- chatModel->addrequestZaddr(txid, requestZaddr);
- chatModel->addHeader(txid, headerbytes);
+ chatModel->addCid(txid, cid);
+ chatModel->addrequestZaddr(txid, requestZaddr);
+ chatModel->addHeader(txid, headerbytes);
- if (publickey.length() > 10){
- main->addPubkey(requestZaddr, publickey);
- }
+ // TODO: better validation of valid public key
+ if (publickey.length() > 10){
+ main->addPubkey(requestZaddr, publickey);
+ }
+ } catch (...) {
+ qDebug() << __func__ << ": Invalid JSON in memo! memo=" << memo.toUtf8();
}
- catch (...)
- {
- // on any exception
- }
- }
+ }
if (chatModel->getCidByTx(txid) != QString("0xdeadbeef"))
{
cid = chatModel->getCidByTx(txid);
}
- else
- {
- cid = "";
- }
if (chatModel->getrequestZaddrByTx(txid) != QString("0xdeadbeef"))
{
requestZaddr = chatModel->getrequestZaddrByTx(txid);
}
- else
- {
- requestZaddr = "";
- }
if (chatModel->getHeaderByTx(txid) != QString("0xdeadbeef"))
{
headerbytes = chatModel->getHeaderByTx(txid);
}
- else
- {
- headerbytes = "";
- }
if (main->getPubkeyByAddress(requestZaddr) != QString("0xdeadbeef"))
{
publickey = main->getPubkeyByAddress(requestZaddr);
}
- else
- {
- publickey = "";
- }
if (contactModel->getContactbyAddress(requestZaddr) != QString("0xdeadbeef"))
{
isContact = true;
contactname = contactModel->getContactbyAddress(requestZaddr);
}
- else
- {
- isContact = false;
- contactname = "";
- }
- bool isNotarized;
+ bool isNotarized = false;
if (confirmations > getLag())
{
isNotarized = true;
}
- else
- {
- isNotarized = false;
- }
int position = it["position"].get();
@@ -1361,11 +1318,15 @@ void Controller::refreshTransactions() {
// crypto_secretstream_xchacha20poly1305_keygen(client_rx);
if (crypto_secretstream_xchacha20poly1305_init_pull(&state, header, client_rx) != 0) {
main->logger->write("Invalid header incoming, no need to go any further ");
+ qDebug() << "crypto_secretstream_xchacha20poly1305_init_pull error!";
+ return;
}
if (crypto_secretstream_xchacha20poly1305_pull
(&state, decrypted, NULL, tag, MESSAGE2, CIPHERTEXT1_LEN, NULL, 0) != 0) {
main->logger->write("Invalid/incomplete/corrupted ciphertext - abort");
+ qDebug() << "crypto_secretstream_xchacha20poly1305_pull error!";
+ return;
}
std::string decryptedMemo(reinterpret_cast(decrypted),MESSAGE1_LEN);
@@ -1375,8 +1336,7 @@ void Controller::refreshTransactions() {
memodecrypt = QString::fromUtf8( decryptedMemo.data(), decryptedMemo.size());
- // }
- //////////////Give us the output of the decrypted message as debug to see if it was successfully
+ ////Give us the output of the decrypted message as debug to see if it was successfully
ChatItem item = ChatItem(
datetime,
@@ -1395,15 +1355,11 @@ void Controller::refreshTransactions() {
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
- }
- else
- {
+ } else {
//
}
- }
- else
- {
+ } else {
ChatItem item = ChatItem(
datetime,
address,
From bd3a839269048e316c78e03ad3b7e6d5161f9c79 Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sat, 29 May 2021 12:11:13 -0400
Subject: [PATCH 03/20] HUSHPrice
---
src/camount.cpp | 2 +-
src/controller.cpp | 18 +++++++++---------
src/controller.h | 2 +-
src/recurring.cpp | 6 +++---
src/settings.cpp | 4 ++--
src/settings.h | 6 +++---
src/websockets.cpp | 5 ++++-
7 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/src/camount.cpp b/src/camount.cpp
index 116973d..9e67dcc 100644
--- a/src/camount.cpp
+++ b/src/camount.cpp
@@ -43,7 +43,7 @@ double CAmount::getDblAmount() const
QString CAmount::toDecimalUSDString() const
{
- double price = Settings::getInstance()->getZECPrice();
+ double price = Settings::getInstance()->getHUSHPrice();
return "$ " + QLocale(QLocale::English).toString(this->getDblAmount() * price, 'f', 2);
}
diff --git a/src/controller.cpp b/src/controller.cpp
index e415084..6f03fdd 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -42,7 +42,7 @@ Controller::Controller(MainWindow* main)
priceTimer = new QTimer(main);
QObject::connect(priceTimer, &QTimer::timeout, [=]() {
if (Settings::getInstance()->getAllowFetchPrices())
- refreshZECPrice();
+ refreshHUSHPrice();
});
priceTimer->start(Settings::priceRefreshSpeed); // Every 5 Min
@@ -89,7 +89,7 @@ void Controller::setConnection(Connection* c)
// If we're allowed to get the Hush Price, get the prices
if (Settings::getInstance()->getAllowFetchPrices()) {
- refreshZECPrice();
+ refreshHUSHPrice();
supplyUpdate();
}
@@ -369,7 +369,7 @@ void Controller::getInfoThenRefresh(bool force)
if (Settings::getInstance()->get_currency_name() == "USD")
{
- double price = Settings::getInstance()->getZECPrice();
+ double price = Settings::getInstance()->getHUSHPrice();
double volume = Settings::getInstance()->getUSDVolume();
double cap = Settings::getInstance()->getUSDCAP();
main->statusLabel->setText(
@@ -546,7 +546,7 @@ void Controller::getInfoThenRefresh(bool force)
else
{
main->statusLabel->setText(
- " HUSH/USD=$" + QString::number(Settings::getInstance()->getZECPrice(),'f',2 )
+ " HUSH/USD=$" + QString::number(Settings::getInstance()->getHUSHPrice(),'f',2 )
);
ui->volumeExchange->setText(
" $ " + QString::number((double) Settings::getInstance()->getUSDVolume() ,'f',2)
@@ -1626,7 +1626,7 @@ void Controller::checkForUpdate(bool silent)
}
// Get the hush->USD price from coinmarketcap using their API
-void Controller::refreshZECPrice()
+void Controller::refreshHUSHPrice()
{
if (!zrpc->haveConnection())
return noConnection();
@@ -1652,7 +1652,7 @@ void Controller::refreshZECPrice()
else
qDebug() << reply->errorString();
- Settings::getInstance()->setZECPrice(0);
+ Settings::getInstance()->setHUSHPrice(0);
Settings::getInstance()->setEURPrice(0);
Settings::getInstance()->setBTCPrice(0);
Settings::getInstance()->setCNYPrice(0);
@@ -1693,7 +1693,7 @@ void Controller::refreshZECPrice()
auto parsed = json::parse(all, nullptr, false);
if (parsed.is_discarded())
{
- Settings::getInstance()->setZECPrice(0);
+ Settings::getInstance()->setHUSHPrice(0);
Settings::getInstance()->setEURPrice(0);
Settings::getInstance()->setBTCPrice(0);
Settings::getInstance()->setCNYPrice(0);
@@ -1736,7 +1736,7 @@ void Controller::refreshZECPrice()
{
qDebug() << "Found hush key in price json";
qDebug() << "HUSH = $" << QString::number((double)hush["usd"]);
- Settings::getInstance()->setZECPrice( hush["usd"] );
+ Settings::getInstance()->setHUSHPrice( hush["usd"] );
}
if (hush["eur"] >= 0)
@@ -1940,7 +1940,7 @@ void Controller::refreshZECPrice()
}
// If nothing, then set the price to 0;
- Settings::getInstance()->setZECPrice(0);
+ Settings::getInstance()->setHUSHPrice(0);
Settings::getInstance()->setEURPrice(0);
Settings::getInstance()->setBTCPrice(0);
Settings::getInstance()->setCNYPrice(0);
diff --git a/src/controller.h b/src/controller.h
index c216b4e..a079bec 100644
--- a/src/controller.h
+++ b/src/controller.h
@@ -46,7 +46,7 @@ public:
int _lag;
void checkForUpdate(bool silent = true);
- void refreshZECPrice();
+ void refreshHUSHPrice();
void refreshEURPrice();
void refreshBTCPrice();
void refreshCNYPrice();
diff --git a/src/recurring.cpp b/src/recurring.cpp
index a961c14..a5f9a57 100644
--- a/src/recurring.cpp
+++ b/src/recurring.cpp
@@ -279,7 +279,7 @@ void Recurring::updateInfoWithTx(RecurringPaymentInfo* r, Tx tx) {
r->fromAddr = tx.fromAddr;
if (r->currency.isEmpty() || r->currency == "USD") {
r->currency = "USD";
- r->amt = tx.toAddrs[0].amount.toqint64() * Settings::getInstance()->getZECPrice();
+ r->amt = tx.toAddrs[0].amount.toqint64() * Settings::getInstance()->getHUSHPrice();
}
else {
r->currency = Settings::getTokenName();
@@ -547,7 +547,7 @@ void Recurring::executeRecurringPayment(MainWindow* main, RecurringPaymentInfo r
double amount = rpi.amt;
if (rpi.currency == "USD") {
// If there is no price, then fail the payment
- if (Settings::getInstance()->getZECPrice() == 0) {
+ if (Settings::getInstance()->getHUSHPrice() == 0) {
for (auto paymentNumber: paymentNumbers) {
updatePaymentItem(rpi.getHash(), paymentNumber,
"", QObject::tr("No hush price was available to convert from USD"),
@@ -559,7 +559,7 @@ void Recurring::executeRecurringPayment(MainWindow* main, RecurringPaymentInfo r
}
// Translate it into hush
- amount = rpi.amt / Settings::getInstance()->getZECPrice();
+ amount = rpi.amt / Settings::getInstance()->getHUSHPrice();
}
// Build a Tx
diff --git a/src/settings.cpp b/src/settings.cpp
index e5bed3d..5b3d18b 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -144,8 +144,8 @@ bool Settings::isSaplingActive() {
return (isTestnet() && getBlockNumber() > 0) || (!isTestnet() && getBlockNumber() > 0);
}
-double Settings::getZECPrice() {
- return ZECPrice;
+double Settings::getHUSHPrice() {
+ return HUSHPrice;
}
double Settings::getEURPrice() {
return EURPrice;
diff --git a/src/settings.h b/src/settings.h
index d8b5d4b..8343424 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -76,7 +76,7 @@ public:
bool isSaplingActive();
- void setZECPrice(double p) { ZECPrice = p; }
+ void setHUSHPrice(double p) { HUSHPrice = p; }
void setEURPrice(double p) { EURPrice = p; }
void setBTCPrice(double p) { BTCPrice = p; }
void setCNYPrice(double p) { CNYPrice = p; }
@@ -109,7 +109,7 @@ public:
void setINRCAP(double p) { INRCAP = p; }
void setGBPCAP(double p) { GBPCAP = p; }
void setAUDCAP(double p) { AUDCAP = p; }
- double getZECPrice();
+ double getHUSHPrice();
double getEURPrice();
double getBTCPrice();
double getCNYPrice();
@@ -195,7 +195,7 @@ private:
bool _useEmbedded = false;
bool _headless = false;
- double ZECPrice = 0.0;
+ double HUSHPrice = 0.0;
double BTCPrice = 0.0;
double EURPrice = 0.0;
double CNYPrice = 0.0;
diff --git a/src/websockets.cpp b/src/websockets.cpp
index ec8542f..d65c6de 100644
--- a/src/websockets.cpp
+++ b/src/websockets.cpp
@@ -904,7 +904,10 @@ void AppDataServer::processGetInfo(QJsonObject jobj, MainWindow* mainWindow, std
{"maxspendable", maxSpendable.toDecimalDouble()},
{"maxzspendable", maxZSpendable.toDecimalDouble()},
{"tokenName", Settings::getTokenName()},
- {"zecprice", Settings::getInstance()->getZECPrice()},
+ // changing this to hushprice is a backward incompatible change that requires
+ // changing SDL, litewalletd and SDA in unison, and would break older clients
+ // so we just leave it for now
+ {"zecprice", Settings::getInstance()->getHUSHPrice()},
{"serverversion", QString(APP_VERSION)}
}).toJson();
pClient->sendTextMessage(encryptOutgoing(r));
From 6fd0f808cc61aa8888d69679337859f839f285e1 Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sat, 29 May 2021 12:14:00 -0400
Subject: [PATCH 04/20] 1.5.1
---
src/version.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/version.h b/src/version.h
index da48c76..0ef80ba 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1,3 +1,3 @@
// Copyright 2019-2021 The Hush developers
// Released under the GPLv3
-#define APP_VERSION "1.5.0"
+#define APP_VERSION "1.5.1"
From 35e7072784fd51f0bfab7eea90d29ff1bc020ec0 Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sat, 29 May 2021 12:20:50 -0400
Subject: [PATCH 05/20] Send people to TG support for filing a bug, since Gitea
requires an account
---
src/mainwindow.cpp | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 35d9a3c..0074093 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -115,7 +115,7 @@ MainWindow::MainWindow(QWidget *parent) :
// File a bug
QObject::connect(ui->actionFile_a_bug, &QAction::triggered, [=]() {
- QDesktopServices::openUrl(QUrl("https://git.hush.is/hush/SilentDragonLite/issues/new"));
+ QDesktopServices::openUrl(QUrl("https://hush.is/tg_support"));
});
// Set up check for updates action
@@ -168,24 +168,13 @@ MainWindow::MainWindow(QWidget *parent) :
// Rescan
QObject::connect(ui->actionRescan, &QAction::triggered, [=]() {
- /* QFile file(dirwalletenc);
- QFile file1(dirwallet);
-
- if(fileExists(dirwalletenc))
-
- {
- file.remove();
- file1.remove();
- }*/
-
-
Ui_Restore restoreSeed;
QDialog dialog(this);
restoreSeed.setupUi(&dialog);
Settings::saveRestore(&dialog);
- rpc->fetchSeed([=](json reply) {
+ rpc->fetchSeed([=](json reply) {
if (isJsonError(reply)) {
return;
}
@@ -197,7 +186,7 @@ MainWindow::MainWindow(QWidget *parent) :
QString birthday = QString::number(reply["birthday"].get());
restoreSeed.birthday->setPlainText(birthday);
- });
+ });
QObject::connect(restoreSeed.restore, &QPushButton::clicked, [&](){
@@ -1205,11 +1194,6 @@ void MainWindow::addPubkey(QString requestZaddr, QString pubkey)
QString MainWindow::getPubkeyByAddress(QString requestZaddr)
{
- for(auto& pair : this->pubkeyMap)
- {
-
- }
-
if(this->pubkeyMap.count(requestZaddr) > 0)
{
return this->pubkeyMap[requestZaddr];
From 413cb8a92fced38c911e3d37a77b26ca82e02026 Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sat, 29 May 2021 12:22:01 -0400
Subject: [PATCH 06/20] .
---
src/mainwindow.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 0074093..05416af 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -924,7 +924,7 @@ void MainWindow::donate() {
QString key = keys->first();
QString key1 = key + QString(" ") + QString("0");
keys->pop_front();
- bool rescan = keys->isEmpty();
+ //bool rescan = keys->isEmpty();
if (key.startsWith("SK") || key.startsWith("secret")) {
rpc->importZPrivKey(key, [=] (auto) { this->doImport(keys); });
From f1fb4209b06e3c8b4902ced4596c524b2c00ada3 Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sat, 29 May 2021 12:26:43 -0400
Subject: [PATCH 07/20] clean
---
src/Chat/Chat.cpp | 13 ++++---------
src/Model/ChatItem.cpp | 39 +++++++++++++++------------------------
2 files changed, 19 insertions(+), 33 deletions(-)
diff --git a/src/Chat/Chat.cpp b/src/Chat/Chat.cpp
index 2bd7d68..1783b36 100644
--- a/src/Chat/Chat.cpp
+++ b/src/Chat/Chat.cpp
@@ -49,6 +49,8 @@ ChatMemoEditRequest::ChatMemoEditRequest(QWidget* parent) : QTextEdit(parent) {
QObject::connect(this, &QTextEdit::textChanged, this, &ChatMemoEditRequest::updateDisplayChatRequest);
}
+
+// TODO: unify this with updateDisplayChat()
void ChatMemoEditRequest::updateDisplayChatRequest() {
QString txt = this->toPlainText();
if (lenDisplayLabelchatRequest)
@@ -98,7 +100,6 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
(p.getName() == ui->contactNameMemo->text().trimmed()) &&
(p.getPartnerAddress() == c.second.getAddress()) &&
(c.second.isOutgoing() == true))
-
{
QStandardItem *Items = new QStandardItem(c.second.toChatLine());
@@ -106,11 +107,8 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
Items->setData(OUTGOING, Qt::UserRole + 1);
chat->appendRow(Items);
ui->listChat->setModel(chat);
-
- }
- else
- {
+ } else {
ui->listChat->setModel(chat);
}
@@ -129,10 +127,7 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
ui->emojiButton->setEnabled(true);
ui->sendChatButton->setEnabled(true);
- }
- else
- {
-
+ } else {
ui->listChat->setModel(chat);
}
}
diff --git a/src/Model/ChatItem.cpp b/src/Model/ChatItem.cpp
index 6f219c7..b381752 100644
--- a/src/Model/ChatItem.cpp
+++ b/src/Model/ChatItem.cpp
@@ -163,22 +163,15 @@ QString ChatItem::toChatLine()
QString moneyTextRequest;
myDateTime.setTime_t(_timestamp);
- if (_notarize == true)
-
- {
-
+ if (_notarize == true) {
lock = " ";
+ } else {
+ lock = " ";
+ }
- }else{
-
- lock = " ";
- }
- if ((_confirmations > 0) && (_notarize == false))
-
- {
-
+ if ((_confirmations > 0) && (_notarize == false)) {
lock = " ";
- }else{}
+ }
if (_memo.startsWith("Money transaction of :"))
{
@@ -210,8 +203,6 @@ QString ChatItem::toChatLine()
}else{moneyTextRequest = "";
moneyTextRequest = ""; }
-
-
QString line = QString("") + myDateTime.toString("yyyy-MM-dd hh:mm");
line += QString(lock) + QString(moneyText) + QString(moneyTextRequest) + QString("");
@@ -223,16 +214,16 @@ QString ChatItem::toChatLine()
json ChatItem::toJson()
{
json j;
- j["_timestamp"] = _timestamp;
- j["_address"] = _address.toStdString();
- j["_contact"] = _contact.toStdString();
- j["_memo"] = _memo.toStdString();
- j["_requestZaddr"] = _requestZaddr.toStdString();
- j["_type"] = _type.toStdString();
- j["_cid"] = _cid.toStdString();
- j["_txid"] = _txid.toStdString();
+ j["_timestamp"] = _timestamp;
+ j["_address"] = _address.toStdString();
+ j["_contact"] = _contact.toStdString();
+ j["_memo"] = _memo.toStdString();
+ j["_requestZaddr"] = _requestZaddr.toStdString();
+ j["_type"] = _type.toStdString();
+ j["_cid"] = _cid.toStdString();
+ j["_txid"] = _txid.toStdString();
j["_confirmations"] = _confirmations;
- j["_outgoing"] = _outgoing;
+ j["_outgoing"] = _outgoing;
return j;
}
From 92b86b3dc76d05a418f04b7f23ed2a47a29031c5 Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sat, 29 May 2021 12:32:35 -0400
Subject: [PATCH 08/20] Abort on secretstream funky stuff
---
src/controller.cpp | 42 ++++++++++++++++--------------------------
1 file changed, 16 insertions(+), 26 deletions(-)
diff --git a/src/controller.cpp b/src/controller.cpp
index 6f03fdd..1f29b1f 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -973,9 +973,9 @@ void Controller::refreshTransactions() {
}
QString memo;
- QString cid;
- QString headerbytes;
- QString publickey;
+ QString cid = "";
+ QString headerbytes = "";
+ QString publickey = "";
if (!o["memo"].is_null()) {
memo = QString::fromStdString(o["memo"].get());
@@ -994,35 +994,27 @@ void Controller::refreshTransactions() {
}
}
- bool isNotarized;
+ bool isNotarized = false;;
if (confirmations > getLag())
{
isNotarized = true;
- } else {
- isNotarized = false;
- }
+ }
if (chatModel->getCidByTx(txid) != QString("0xdeadbeef"))
{
cid = chatModel->getCidByTx(txid);
- } else {
- cid = "";
}
if (chatModel->getHeaderByTx(txid) != QString("0xdeadbeef"))
{
headerbytes = chatModel->getHeaderByTx(txid);
- } else {
- headerbytes = "";
}
if (main->getPubkeyByAddress(address) != QString("0xdeadbeef"))
{
publickey = main->getPubkeyByAddress(address);
- } else {
- publickey = "";
}
/////We need to filter out Memos smaller then the ciphertext size, or it will dump
@@ -1060,6 +1052,8 @@ void Controller::refreshTransactions() {
if (crypto_kx_server_session_keys(server_rx, server_tx, pk, sk, pubkeyBob) != 0)
{
main->logger->write("Suspicious client public outgoing key, bail out ");
+ qDebug() << "Suspicious client public outgoing key, aborting!";
+ return;
}
const QByteArray ba = QByteArray::fromHex(memo.toUtf8());
@@ -1094,20 +1088,21 @@ void Controller::refreshTransactions() {
// crypto_secretstream_xchacha20poly1305_keygen(client_rx);
if (crypto_secretstream_xchacha20poly1305_init_pull(&state, header, server_tx) != 0) {
/* Invalid header, no need to go any further */
+ qDebug() << "crypto_secretstream_xchacha20poly1305_init_pull error!";
+ return;
}
if (crypto_secretstream_xchacha20poly1305_pull
(&state, decrypted, NULL, tag, MESSAGE2, CIPHERTEXT1_LEN, NULL, 0) != 0) {
/* Invalid/incomplete/corrupted ciphertext - abort */
+ qDebug() << "crypto_secretstream_xchacha20poly1305_pull error!";
+ return;
}
std::string decryptedMemo(reinterpret_cast(decrypted),MESSAGE1_LEN);
memodecrypt = QString::fromUtf8( decryptedMemo.data(), decryptedMemo.size());
- }
- else
- {
-
+ } else {
memodecrypt = "";
}
@@ -1251,9 +1246,7 @@ void Controller::refreshTransactions() {
if (position == 1)
{
chatModel->addMemo(txid, headerbytes);
- }
- else
- {
+ } else {
//
}
@@ -1401,8 +1394,7 @@ void Controller::refreshTransactions() {
// Update model data, which updates the table view
transactionsTableModel->replaceData(txdata);
chat->renderChatBox(ui, ui->listChat,ui->memoSizeChat);
- ui->listChat->verticalScrollBar()->setValue(
- ui->listChat->verticalScrollBar()->maximum());
+ ui->listChat->verticalScrollBar()->setValue(ui->listChat->verticalScrollBar()->maximum());
});
@@ -1411,16 +1403,14 @@ void Controller::refreshTransactions() {
void Controller::refreshChat(QListView *listWidget, QLabel *label)
{
chat->renderChatBox(ui, listWidget, label);
- ui->listChat->verticalScrollBar()->setValue(
- ui->listChat->verticalScrollBar()->maximum());
+ ui->listChat->verticalScrollBar()->setValue(ui->listChat->verticalScrollBar()->maximum());
}
void Controller::refreshContacts(QListView *listWidget)
{
contactModel->renderContactList(listWidget);
- ui->listChat->verticalScrollBar()->setValue(
- ui->listChat->verticalScrollBar()->maximum());
+ ui->listChat->verticalScrollBar()->setValue(ui->listChat->verticalScrollBar()->maximum());
}
// If the wallet is encrpyted and locked, we need to unlock it
From 35593443b519e540f918b15a90f09f98b775d18b Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sat, 29 May 2021 12:50:47 -0400
Subject: [PATCH 09/20] Abort when we see funky stuff from secretstream api
---
src/chatmodel.cpp | 21 +++++++++++-------
src/mainwindow.cpp | 53 ++++++++++++++++++++++------------------------
2 files changed, 38 insertions(+), 36 deletions(-)
diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp
index c6b5663..f4cf2d7 100644
--- a/src/chatmodel.cpp
+++ b/src/chatmodel.cpp
@@ -477,20 +477,23 @@ Tx MainWindow::createTxFromChatPage() {
unsigned char pk[crypto_kx_PUBLICKEYBYTES];
unsigned char server_rx[crypto_kx_SESSIONKEYBYTES], server_tx[crypto_kx_SESSIONKEYBYTES];
- if (crypto_kx_seed_keypair(pk,sk,
- MESSAGEAS1) !=0) {
+ if (crypto_kx_seed_keypair(pk,sk, MESSAGEAS1) !=0) {
+ this->logger->write("Suspicious keypair, bail out ");
+ qDebug() << __func__<< ": Suspicious client public outgoing key from crypto_kx_seed_keypair, aborting!";
+ return;
+ }
- this->logger->write("Suspicious keypair, bail out ");
- }
////////////////Get the pubkey from Bob, so we can create the share key
const QByteArray pubkeyBobArray = QByteArray::fromHex(pubkey.toLatin1());
const unsigned char *pubkeyBob = reinterpret_cast(pubkeyBobArray.constData());
- /////Create the shared key for sending the message
- if (crypto_kx_server_session_keys(server_rx, server_tx,
- pk, sk, pubkeyBob) != 0) {
- this->logger->write("Suspicious client public send key, bail out ");
+ /////Create the shared key for sending the message
+
+ if (crypto_kx_server_session_keys(server_rx, server_tx, pk, sk, pubkeyBob) != 0) {
+ this->logger->write("Suspicious client public send key, bail out ");
+ qDebug() << __func__ << ": Suspicious client public send key from crypto_kx_server_session_keys, aborting!";
+ return;
}
@@ -821,6 +824,8 @@ Tx MainWindow::createTxForSafeContactRequest()
if (crypto_kx_seed_keypair(pk, sk, MESSAGEAS1) !=0) {
this->logger->write("Suspicious client public contact request key, bail out ");
+ qDebug() << __func__ << ": Suspicious client public send key from crypto_kx_seed_keypair, aborting!";
+ return;
}
QString publicKey = QByteArray(reinterpret_cast(pk), crypto_kx_PUBLICKEYBYTES).toHex();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 05416af..6ab621d 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1884,21 +1884,22 @@ Tx MainWindow::createTxFromSendChatPage() {
unsigned char pk[crypto_kx_PUBLICKEYBYTES];
unsigned char server_rx[crypto_kx_SESSIONKEYBYTES], server_tx[crypto_kx_SESSIONKEYBYTES];
- if (crypto_kx_seed_keypair(pk,sk,
- MESSAGEAS1) !=0) {
-
- this->logger->write("Suspicious keypair, bail out ");
- }
+ if (crypto_kx_seed_keypair(pk,sk, MESSAGEAS1) !=0) {
+ this->logger->write("Suspicious keypair, bail out ");
+ qDebug() << __func__ << ": Suspicious client public send key from crypto_kx_seed_keypair, aborting!";
+ return;
+ }
////////////////Get the pubkey from Bob, so we can create the share key
const QByteArray pubkeyBobArray = QByteArray::fromHex(pubkey.toLatin1());
const unsigned char *pubkeyBob = reinterpret_cast(pubkeyBobArray.constData());
/////Create the shared key for sending the message
- if (crypto_kx_server_session_keys(server_rx, server_tx,
- pk, sk, pubkeyBob) != 0) {
- this->logger->write("Suspicious client public send key, bail out ");
- }
+ if (crypto_kx_server_session_keys(server_rx, server_tx, pk, sk, pubkeyBob) != 0) {
+ this->logger->write("Suspicious client public send key, bail out ");
+ qDebug() << __func__ << ": Suspicious client public send key from crypto_kx_server_session_keys, aborting!";
+ return;
+ }
// Let's try to preserve Unicode characters
@@ -1937,10 +1938,8 @@ Tx MainWindow::createTxFromSendChatPage() {
/////Ciphertext Memo
QString memo = QByteArray(reinterpret_cast(ciphertext), CIPHERTEXT_LEN).toHex();
-
tx.toAddrs.push_back(ToFields{addr, amtHm, hmemo});
tx.toAddrs.push_back(ToFields{addr, amt, memo});
-
}
}
@@ -2173,21 +2172,22 @@ Tx MainWindow::createTxFromSendRequestChatPage() {
unsigned char pk[crypto_kx_PUBLICKEYBYTES];
unsigned char server_rx[crypto_kx_SESSIONKEYBYTES], server_tx[crypto_kx_SESSIONKEYBYTES];
- if (crypto_kx_seed_keypair(pk,sk,
- MESSAGEAS1) !=0) {
-
- this->logger->write("Suspicious keypair, bail out ");
- }
+ if (crypto_kx_seed_keypair(pk,sk, MESSAGEAS1) !=0) {
+ this->logger->write("Suspicious keypair, bail out ");
+ qDebug() << __func__<< ": Suspicious client public outgoing key from crypto_kx_seed_keypair, aborting!";
+ return;
+ }
////////////////Get the pubkey from Bob, so we can create the share key
const QByteArray pubkeyBobArray = QByteArray::fromHex(pubkey.toLatin1());
const unsigned char *pubkeyBob = reinterpret_cast(pubkeyBobArray.constData());
/////Create the shared key for sending the message
- if (crypto_kx_server_session_keys(server_rx, server_tx,
- pk, sk, pubkeyBob) != 0) {
- this->logger->write("Suspicious client public send key, bail out ");
- }
+ if (crypto_kx_server_session_keys(server_rx, server_tx, pk, sk, pubkeyBob) != 0) {
+ this->logger->write("Suspicious client public send key, bail out ");
+ qDebug() << __func__ << ": Suspicious client public send key from crypto_kx_server_session_keys, aborting!";
+ return;
+ }
// Let's try to preserve Unicode characters
@@ -2417,7 +2417,7 @@ void MainWindow::addNewZaddr(bool sapling) {
ui->listReceiveAddresses->insertItem(0, addr);
ui->listReceiveAddresses->setCurrentIndex(0);
- ui->statusBar->showMessage(QString::fromStdString("Created new zAddr") %
+ ui->statusBar->showMessage(QString::fromStdString("Created new zaddr") %
(sapling ? "(Sapling)" : "(Sprout)"),
10 * 1000);
}
@@ -2779,11 +2779,8 @@ void MainWindow::slot_change_currency(const QString& currency_name)
{
saved_currency_name = Settings::getInstance()->get_currency_name();
- }
- catch (...)
- {
- saved_currency_name = "USD";
-
+ } catch (...) {
+ saved_currency_name = "BTC";
}
}
@@ -2845,6 +2842,8 @@ void MainWindow::on_givemeZaddr_clicked()
});
}
+
+// TODO: The way emoji work really need to change, this is madness
void MainWindow::on_emojiButton_clicked()
{
@@ -2961,8 +2960,6 @@ QObject::connect(emoji.sd, &QPushButton::clicked, [&] () {
});
-
-
emojiDialog.exec();
}
From f3c3684f88bdad62e43296bfccdde483d006021d Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sat, 29 May 2021 12:54:25 -0400
Subject: [PATCH 10/20] Fix compile errors and warnings
---
src/chatmodel.cpp | 39 +++++----------------------------------
src/mainwindow.cpp | 8 ++++----
2 files changed, 9 insertions(+), 38 deletions(-)
diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp
index f4cf2d7..1fa80f1 100644
--- a/src/chatmodel.cpp
+++ b/src/chatmodel.cpp
@@ -65,11 +65,12 @@ void ChatModel::addMessage(QString timestamp, ChatItem item)
void ChatModel::showMessages()
{
+/*
for(auto &c : this->chatItems)
{
}
-
+ */
}
void ChatModel::addAddressbylabel(QString address, QString label)
@@ -79,11 +80,6 @@ void ChatModel::addAddressbylabel(QString address, QString label)
QString ChatModel::Addressbylabel(QString address)
{
- for(auto& pair : this->AddressbyLabelMap)
- {
-
- }
-
if(this->AddressbyLabelMap.count(address) > 0)
{
return this->AddressbyLabelMap[address];
@@ -306,11 +302,6 @@ void ChatModel::addconfirmations(QString tx, int confirmation)
QString ChatModel::getCidByTx(QString tx)
{
- for(auto& pair : this->cidMap)
- {
-
- }
-
if(this->cidMap.count(tx) > 0)
{
return this->cidMap[tx];
@@ -321,11 +312,6 @@ QString ChatModel::getCidByTx(QString tx)
QString ChatModel::getMemoByTx(QString tx)
{
- for(auto& pair : this->OldMemoByTx)
- {
-
- }
-
if(this->OldMemoByTx.count(tx) > 0)
{
return this->OldMemoByTx[tx];
@@ -339,11 +325,6 @@ QString ChatModel::getMemoByTx(QString tx)
QString ChatModel::getHeaderByTx(QString tx)
{
- for(auto& pair : this->headerMap)
- {
-
- }
-
if(this->headerMap.count(tx) > 0)
{
return this->headerMap[tx];
@@ -354,11 +335,6 @@ QString ChatModel::getHeaderByTx(QString tx)
QString ChatModel::getConfirmationByTx(QString tx)
{
- for(auto& pair : this->confirmationsMap)
- {
-
- }
-
if(this->confirmationsMap.count(tx) > 0)
{
return this->confirmationsMap[tx];
@@ -369,11 +345,6 @@ QString ChatModel::getConfirmationByTx(QString tx)
QString ChatModel::getrequestZaddrByTx(QString tx)
{
- for(auto& pair : this->requestZaddrMap)
- {
-
- }
-
if(this->requestZaddrMap.count(tx) > 0)
{
return this->requestZaddrMap[tx];
@@ -480,7 +451,7 @@ Tx MainWindow::createTxFromChatPage() {
if (crypto_kx_seed_keypair(pk,sk, MESSAGEAS1) !=0) {
this->logger->write("Suspicious keypair, bail out ");
qDebug() << __func__<< ": Suspicious client public outgoing key from crypto_kx_seed_keypair, aborting!";
- return;
+ return tx;
}
////////////////Get the pubkey from Bob, so we can create the share key
@@ -493,7 +464,7 @@ Tx MainWindow::createTxFromChatPage() {
if (crypto_kx_server_session_keys(server_rx, server_tx, pk, sk, pubkeyBob) != 0) {
this->logger->write("Suspicious client public send key, bail out ");
qDebug() << __func__ << ": Suspicious client public send key from crypto_kx_server_session_keys, aborting!";
- return;
+ return tx;
}
@@ -825,7 +796,7 @@ Tx MainWindow::createTxForSafeContactRequest()
if (crypto_kx_seed_keypair(pk, sk, MESSAGEAS1) !=0) {
this->logger->write("Suspicious client public contact request key, bail out ");
qDebug() << __func__ << ": Suspicious client public send key from crypto_kx_seed_keypair, aborting!";
- return;
+ return tx;
}
QString publicKey = QByteArray(reinterpret_cast(pk), crypto_kx_PUBLICKEYBYTES).toHex();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 6ab621d..a34c4c7 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1887,7 +1887,7 @@ Tx MainWindow::createTxFromSendChatPage() {
if (crypto_kx_seed_keypair(pk,sk, MESSAGEAS1) !=0) {
this->logger->write("Suspicious keypair, bail out ");
qDebug() << __func__ << ": Suspicious client public send key from crypto_kx_seed_keypair, aborting!";
- return;
+ return tx;
}
////////////////Get the pubkey from Bob, so we can create the share key
@@ -1898,7 +1898,7 @@ Tx MainWindow::createTxFromSendChatPage() {
if (crypto_kx_server_session_keys(server_rx, server_tx, pk, sk, pubkeyBob) != 0) {
this->logger->write("Suspicious client public send key, bail out ");
qDebug() << __func__ << ": Suspicious client public send key from crypto_kx_server_session_keys, aborting!";
- return;
+ return tx;
}
@@ -2175,7 +2175,7 @@ Tx MainWindow::createTxFromSendRequestChatPage() {
if (crypto_kx_seed_keypair(pk,sk, MESSAGEAS1) !=0) {
this->logger->write("Suspicious keypair, bail out ");
qDebug() << __func__<< ": Suspicious client public outgoing key from crypto_kx_seed_keypair, aborting!";
- return;
+ return tx;
}
////////////////Get the pubkey from Bob, so we can create the share key
@@ -2186,7 +2186,7 @@ Tx MainWindow::createTxFromSendRequestChatPage() {
if (crypto_kx_server_session_keys(server_rx, server_tx, pk, sk, pubkeyBob) != 0) {
this->logger->write("Suspicious client public send key, bail out ");
qDebug() << __func__ << ": Suspicious client public send key from crypto_kx_server_session_keys, aborting!";
- return;
+ return tx;
}
From 3ce1a8c1e8119784967af0a6ed8d8a89b7968ca5 Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sat, 29 May 2021 13:56:17 -0400
Subject: [PATCH 11/20] More details on secretstream errors and cleanups
---
src/Chat/Chat.cpp | 6 +++-
src/controller.cpp | 69 ++++++++++++++++++++++++----------------------
2 files changed, 41 insertions(+), 34 deletions(-)
diff --git a/src/Chat/Chat.cpp b/src/Chat/Chat.cpp
index 1783b36..e510291 100644
--- a/src/Chat/Chat.cpp
+++ b/src/Chat/Chat.cpp
@@ -1,5 +1,5 @@
// Copyright 2019-2021 The Hush developers
-// GPLv3
+// Released under the GPLv3
#include "Chat.h"
#include "../addressbook.h"
@@ -91,6 +91,8 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
QStandardItemModel *chat = new QStandardItemModel();
DataStore::getChatDataStore()->dump(); // test to see if the chat items in datastore are correctly dumped to json
+
+ qDebug() << __func__ << ": looking at memos...";
for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
{
for (auto &c : DataStore::getChatDataStore()->getAllMemos())
@@ -105,6 +107,7 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
QStandardItem *Items = new QStandardItem(c.second.toChatLine());
Items->setData(OUTGOING, Qt::UserRole + 1);
+ qDebug() << __func__ << ": appending row to OUTGOING chatitems to contact " << p.getName();
chat->appendRow(Items);
ui->listChat->setModel(chat);
@@ -121,6 +124,7 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
{
QStandardItem *Items1 = new QStandardItem(c.second.toChatLine());
Items1->setData(INCOMING, Qt::UserRole + 1);
+ qDebug() << __func__ << ": appending row to INCOMING chatitems to contact " << p.getName() << "with cid=" << p.getCid();
chat->appendRow(Items1);
ui->listChat->setModel(chat);
ui->memoTxtChat->setEnabled(true);
diff --git a/src/controller.cpp b/src/controller.cpp
index 1f29b1f..40f6a6d 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -1,5 +1,5 @@
-// Copyright 2019-2020 The Hush developers
-// GPLv3
+// Copyright 2019-2021 The Hush developers
+// Released under the GPLv3
#include "controller.h"
#include "mainwindow.h"
@@ -662,29 +662,29 @@ void Controller::updateUI(bool anyUnconfirmed)
void Controller::supplyUpdate() {
- qDebug()<<"Supply";
-
- // Get the total supply and render it with thousand decimal
- zrpc->fetchSupply([=] (const json& reply) {
- int supply = reply["supply"].get();
- int zfunds = reply["zfunds"].get();
- int total = reply["total"].get();;
- if (
- Settings::getInstance()->get_currency_name() == "EUR" ||
- Settings::getInstance()->get_currency_name() == "CHF" ||
- Settings::getInstance()->get_currency_name() == "RUB"
- )
- {
- ui->supply_taddr->setText((QLocale(QLocale::German).toString(supply)+ " HUSH"));
- ui->supply_zaddr->setText((QLocale(QLocale::German).toString(zfunds)+ " HUSH"));
- ui->supply_total->setText((QLocale(QLocale::German).toString(total)+ " HUSH"));
- } else {
- ui->supply_taddr->setText("HUSH " + (QLocale(QLocale::English).toString(supply)));
- ui->supply_zaddr->setText("HUSH " +(QLocale(QLocale::English).toString(zfunds)));
- ui->supply_total->setText("HUSH " +(QLocale(QLocale::English).toString(total)));
- }
+ qDebug()<< __func__ << ": updating supply";
- });
+ // Get the total supply and render it with thousand decimal
+ zrpc->fetchSupply([=] (const json& reply) {
+ int supply = reply["supply"].get();
+ int zfunds = reply["zfunds"].get();
+ int total = reply["total"].get();;
+ if (Settings::getInstance()->get_currency_name() == "EUR" ||
+ Settings::getInstance()->get_currency_name() == "CHF" ||
+ Settings::getInstance()->get_currency_name() == "RUB"
+ ) {
+ // TODO: assuming German locale is incorrect
+ ui->supply_taddr->setText((QLocale(QLocale::German).toString(supply)+ " HUSH"));
+ ui->supply_zaddr->setText((QLocale(QLocale::German).toString(zfunds)+ " HUSH"));
+ ui->supply_total->setText((QLocale(QLocale::German).toString(total)+ " HUSH"));
+ } else {
+ // TODO: assuming English locale is incorrect as well
+ ui->supply_taddr->setText("HUSH " + (QLocale(QLocale::English).toString(supply)));
+ ui->supply_zaddr->setText("HUSH " +(QLocale(QLocale::English).toString(zfunds)));
+ ui->supply_total->setText("HUSH " +(QLocale(QLocale::English).toString(total)));
+ }
+ qDebug() << __func__ << ": supply=" << supply;
+ });
}
@@ -720,9 +720,9 @@ void Controller::processUnspent(const json& reply, QMap* balan
void Controller::updateUIBalances()
{
- CAmount balT = getModel()->getBalT();
- CAmount balZ = getModel()->getBalZ();
- CAmount balVerified = getModel()->getBalVerified();
+ CAmount balT = getModel()->getBalT();
+ CAmount balZ = getModel()->getBalZ();
+ CAmount balVerified = getModel()->getBalVerified();
CAmount balSpendable = getModel()->getBalSpendable();
// Reduce the BalanceZ by the pending outgoing amount. We're adding
@@ -743,6 +743,7 @@ void Controller::updateUIBalances()
ui->balSpendable->setText(balSpendable.toDecimalhushString());
ui->balTotal->setText(balTotal.toDecimalhushString());
+ //TODO: refactor this madness into functions like SD uses, with currency as a variable
if (Settings::getInstance()->get_currency_name() == "USD")
{
ui->balSheilded->setToolTip(balZ.toDecimalUSDString());
@@ -925,6 +926,7 @@ void Controller::refreshTransactions() {
if (!zrpc->haveConnection())
return noConnection();
+ qDebug() << __func__ << ": fetchTransactions";
zrpc->fetchTransactions([=] (json reply) {
QList txdata;
@@ -1088,14 +1090,13 @@ void Controller::refreshTransactions() {
// crypto_secretstream_xchacha20poly1305_keygen(client_rx);
if (crypto_secretstream_xchacha20poly1305_init_pull(&state, header, server_tx) != 0) {
/* Invalid header, no need to go any further */
- qDebug() << "crypto_secretstream_xchacha20poly1305_init_pull error!";
+ qDebug() << __func__ << ": crypto_secretstream_xchacha20poly1305_init_pull error!";
return;
}
- if (crypto_secretstream_xchacha20poly1305_pull
- (&state, decrypted, NULL, tag, MESSAGE2, CIPHERTEXT1_LEN, NULL, 0) != 0) {
+ if (crypto_secretstream_xchacha20poly1305_pull(&state, decrypted, NULL, tag, MESSAGE2, CIPHERTEXT1_LEN, NULL, 0) != 0) {
/* Invalid/incomplete/corrupted ciphertext - abort */
- qDebug() << "crypto_secretstream_xchacha20poly1305_pull error!";
+ qDebug() << __func__ << ": crypto_secretstream_xchacha20poly1305_pull error!";
return;
}
@@ -1311,14 +1312,14 @@ void Controller::refreshTransactions() {
// crypto_secretstream_xchacha20poly1305_keygen(client_rx);
if (crypto_secretstream_xchacha20poly1305_init_pull(&state, header, client_rx) != 0) {
main->logger->write("Invalid header incoming, no need to go any further ");
- qDebug() << "crypto_secretstream_xchacha20poly1305_init_pull error!";
+ qDebug() << __func__ << ":crypto_secretstream_xchacha20poly1305_init_pull error!";
return;
}
if (crypto_secretstream_xchacha20poly1305_pull
(&state, decrypted, NULL, tag, MESSAGE2, CIPHERTEXT1_LEN, NULL, 0) != 0) {
main->logger->write("Invalid/incomplete/corrupted ciphertext - abort");
- qDebug() << "crypto_secretstream_xchacha20poly1305_pull error!";
+ qDebug() << __func__ << ":crypto_secretstream_xchacha20poly1305_pull error!";
return;
}
@@ -1393,6 +1394,7 @@ void Controller::refreshTransactions() {
// Update model data, which updates the table view
transactionsTableModel->replaceData(txdata);
+ qDebug() << __func__ << ": calling renderChatBox";
chat->renderChatBox(ui, ui->listChat,ui->memoSizeChat);
ui->listChat->verticalScrollBar()->setValue(ui->listChat->verticalScrollBar()->maximum());
@@ -1402,6 +1404,7 @@ void Controller::refreshTransactions() {
void Controller::refreshChat(QListView *listWidget, QLabel *label)
{
+ qDebug() << __func__ << ": calling renderChatBox";
chat->renderChatBox(ui, listWidget, label);
ui->listChat->verticalScrollBar()->setValue(ui->listChat->verticalScrollBar()->maximum());
From 9dce18e151f106edee4c830d5eba24fd70e9cb23 Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sat, 29 May 2021 18:07:28 -0400
Subject: [PATCH 12/20] continue instead of returning after secretstream
badness
---
src/Chat/Chat.cpp | 4 ++--
src/Chat/Helper/ChatDelegator.h | 3 ++-
src/contactmodel.cpp | 18 ++++-----------
src/controller.cpp | 40 +++++++++++++++++++--------------
4 files changed, 31 insertions(+), 34 deletions(-)
diff --git a/src/Chat/Chat.cpp b/src/Chat/Chat.cpp
index e510291..7cc06c9 100644
--- a/src/Chat/Chat.cpp
+++ b/src/Chat/Chat.cpp
@@ -107,7 +107,7 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
QStandardItem *Items = new QStandardItem(c.second.toChatLine());
Items->setData(OUTGOING, Qt::UserRole + 1);
- qDebug() << __func__ << ": appending row to OUTGOING chatitems to contact " << p.getName();
+ qDebug() << __func__ << ": appending row to OUTGOING chatitems to contact " << p.getName() << " with item " << Items;
chat->appendRow(Items);
ui->listChat->setModel(chat);
@@ -124,7 +124,7 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
{
QStandardItem *Items1 = new QStandardItem(c.second.toChatLine());
Items1->setData(INCOMING, Qt::UserRole + 1);
- qDebug() << __func__ << ": appending row to INCOMING chatitems to contact " << p.getName() << "with cid=" << p.getCid();
+ qDebug() << __func__ << ": appending row to INCOMING chatitems to contact " << p.getName() << "with cid=" << p.getCid() << " and item " << Items1;
chat->appendRow(Items1);
ui->listChat->setModel(chat);
ui->memoTxtChat->setEnabled(true);
diff --git a/src/Chat/Helper/ChatDelegator.h b/src/Chat/Helper/ChatDelegator.h
index 6f2032d..d319abb 100644
--- a/src/Chat/Helper/ChatDelegator.h
+++ b/src/Chat/Helper/ChatDelegator.h
@@ -1,4 +1,4 @@
-// Copyright 2019-2020 The Hush developers
+// Copyright 2019-2021 The Hush developers
// GPLv3
#ifndef CHATDELEGATOR_H
@@ -42,6 +42,7 @@ inline ListViewDelegate::ListViewDelegate(QObject *parent): QAbstractItemDelegat
}
+//TODO: this data must be kept in sync with sizeHint(), refactor
inline void ListViewDelegate::paint(QPainter *painter, QStyleOptionViewItem const &option, QModelIndex const &index) const
{
QTextDocument bodydoc;
diff --git a/src/contactmodel.cpp b/src/contactmodel.cpp
index f3d529f..b398f33 100644
--- a/src/contactmodel.cpp
+++ b/src/contactmodel.cpp
@@ -1,4 +1,4 @@
-// Copyright 2019-2020 The Hush developers
+// Copyright 2019-2021 The Hush developers
// GPLv3
#include "contactmodel.h"
@@ -18,11 +18,6 @@ void ContactModel::addLabel(QString addr, QString label)
QString ContactModel::getContactbyAddress(QString addr)
{
- for(auto& pair : this->AddressMap)
- {
-
- }
-
if(this->AddressMap.count(addr) > 0)
{
return this->AddressMap[addr];
@@ -65,9 +60,7 @@ void MainWindow::showRequesthush() {
for(auto &p : AddressBook::getInstance()->getAllAddressLabels())
{
- if (p.getName() == label)
-
- {
+ if (p.getName() == label) {
QString addr = p.getPartnerAddress();
QString myzaddr = p.getMyAddress();
@@ -135,7 +128,8 @@ void MainWindow::showRequesthush() {
}
}
- if (d.exec() == QDialog::Accepted) {
+
+ if (d.exec() == QDialog::Accepted) {
// Construct a hush Payment URI with the data and pay it immediately.
CAmount amount = CAmount::fromDecimalString(req.txtAmount->text());
QString memoURI = "hush:" + req.lblAddressInfo->text()
@@ -150,10 +144,6 @@ void MainWindow::showRequesthush() {
// sapling address
this->payhushURI(sendURI, req.lblAddressInfo->text());
-
-
}
}
-
-
diff --git a/src/controller.cpp b/src/controller.cpp
index 40f6a6d..e5dea64 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -950,15 +950,13 @@ void Controller::refreshTransactions() {
// First, check if there's outgoing metadata
if (!it["outgoing_metadata"].is_null()) {
- for (auto o: it["outgoing_metadata"].get())
-
- {
+ for (auto o: it["outgoing_metadata"].get()) {
// if (chatModel->getCidByTx(txid) == QString("0xdeadbeef")){
QString address;
address = QString::fromStdString(o["address"]);
- // Sent items are -ve
+ // Sent items are negative
CAmount amount = CAmount::fromqint64(-1* o["value"].get());
// Check for Memos
@@ -979,7 +977,7 @@ void Controller::refreshTransactions() {
QString headerbytes = "";
QString publickey = "";
if (!o["memo"].is_null()) {
- memo = QString::fromStdString(o["memo"].get());
+ memo = QString::fromStdString(o["memo"].get());
if (memo.startsWith("{")) {
try {
@@ -1008,7 +1006,6 @@ void Controller::refreshTransactions() {
cid = chatModel->getCidByTx(txid);
}
-
if (chatModel->getHeaderByTx(txid) != QString("0xdeadbeef"))
{
headerbytes = chatModel->getHeaderByTx(txid);
@@ -1042,6 +1039,8 @@ void Controller::refreshTransactions() {
if (crypto_kx_seed_keypair(pk, sk, MESSAGEAS1) !=0)
{
main->logger->write("Keypair outgoing error");
+ qDebug() << "refreshTransactions: crypto_kx_seed_keypair error";
+ continue;
}
unsigned char server_rx[crypto_kx_SESSIONKEYBYTES], server_tx[crypto_kx_SESSIONKEYBYTES];
@@ -1054,8 +1053,8 @@ void Controller::refreshTransactions() {
if (crypto_kx_server_session_keys(server_rx, server_tx, pk, sk, pubkeyBob) != 0)
{
main->logger->write("Suspicious client public outgoing key, bail out ");
- qDebug() << "Suspicious client public outgoing key, aborting!";
- return;
+ qDebug() << "refreshTransactions: Suspicious client public outgoing key, aborting!";
+ continue;
}
const QByteArray ba = QByteArray::fromHex(memo.toUtf8());
@@ -1090,14 +1089,14 @@ void Controller::refreshTransactions() {
// crypto_secretstream_xchacha20poly1305_keygen(client_rx);
if (crypto_secretstream_xchacha20poly1305_init_pull(&state, header, server_tx) != 0) {
/* Invalid header, no need to go any further */
- qDebug() << __func__ << ": crypto_secretstream_xchacha20poly1305_init_pull error!";
- return;
+ qDebug() << "refreshTransactions: crypto_secretstream_xchacha20poly1305_init_pull error!";
+ continue;
}
if (crypto_secretstream_xchacha20poly1305_pull(&state, decrypted, NULL, tag, MESSAGE2, CIPHERTEXT1_LEN, NULL, 0) != 0) {
/* Invalid/incomplete/corrupted ciphertext - abort */
- qDebug() << __func__ << ": crypto_secretstream_xchacha20poly1305_pull error!";
- return;
+ qDebug() << "refreshTransactions: crypto_secretstream_xchacha20poly1305_pull error!";
+ continue;
}
std::string decryptedMemo(reinterpret_cast(decrypted),MESSAGE1_LEN);
@@ -1125,6 +1124,7 @@ void Controller::refreshTransactions() {
false
);
+ qDebug() << "refreshTransactions: adding chatItem with memodecrypt=" << memodecrypt;
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
// updateUIBalances();
}
@@ -1270,6 +1270,8 @@ void Controller::refreshTransactions() {
if (crypto_kx_seed_keypair(pk, sk, MESSAGEAS1) !=0)
{
main->logger->write("Suspicious outgoing key pair, bail out ");
+ qDebug() << "refreshTransactions: (incoming) crypto_kx_seed_keypair error!";
+ continue;
}
unsigned char client_rx[crypto_kx_SESSIONKEYBYTES], client_tx[crypto_kx_SESSIONKEYBYTES];
@@ -1277,10 +1279,11 @@ void Controller::refreshTransactions() {
////////////////Get the pubkey from Bob, so we can create the share key
/////Create the shared key for sending the message
-
if (crypto_kx_client_session_keys(client_rx, client_tx, pk, sk, pubkeyBob) != 0)
{
main->logger->write("Suspicious client public incoming key, bail out ");
+ qDebug() << "refreshTransactions: (incoming) crypto_kx_client_session_keys error!";
+ continue;
}
const QByteArray ba = QByteArray::fromHex(memo.toUtf8());
@@ -1312,15 +1315,15 @@ void Controller::refreshTransactions() {
// crypto_secretstream_xchacha20poly1305_keygen(client_rx);
if (crypto_secretstream_xchacha20poly1305_init_pull(&state, header, client_rx) != 0) {
main->logger->write("Invalid header incoming, no need to go any further ");
- qDebug() << __func__ << ":crypto_secretstream_xchacha20poly1305_init_pull error!";
- return;
+ qDebug() <<"refreshTransactions: (incoming) crypto_secretstream_xchacha20poly1305_init_pull error!";
+ continue;
}
if (crypto_secretstream_xchacha20poly1305_pull
(&state, decrypted, NULL, tag, MESSAGE2, CIPHERTEXT1_LEN, NULL, 0) != 0) {
main->logger->write("Invalid/incomplete/corrupted ciphertext - abort");
- qDebug() << __func__ << ":crypto_secretstream_xchacha20poly1305_pull error!";
- return;
+ qDebug() << "refreshTransactions: (incoming) crypto_secretstream_xchacha20poly1305_pull error!";
+ continue;
}
std::string decryptedMemo(reinterpret_cast(decrypted),MESSAGE1_LEN);
@@ -1347,6 +1350,7 @@ void Controller::refreshTransactions() {
isContact
);
+ qDebug() << "refreshTransactions: adding chatItem with memodecrypt=" << memodecrypt;
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
} else {
@@ -1368,6 +1372,8 @@ void Controller::refreshTransactions() {
isNotarized,
isContact
);
+
+ qDebug() << "refreshTransactions: adding chatItem with memo=" << memo;
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
}
}
From 14ab550b768c03f781c65793764c5b2a7200c18b Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sat, 29 May 2021 18:31:16 -0400
Subject: [PATCH 13/20] .
---
src/controller.cpp | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/controller.cpp b/src/controller.cpp
index e5dea64..2ff4dd3 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -922,7 +922,7 @@ void Controller::refreshBalances()
});
}
-void Controller::refreshTransactions() {
+void Controller::refreshTransactions() {
if (!zrpc->haveConnection())
return noConnection();
@@ -1044,7 +1044,6 @@ void Controller::refreshTransactions() {
}
unsigned char server_rx[crypto_kx_SESSIONKEYBYTES], server_tx[crypto_kx_SESSIONKEYBYTES];
-
////////////////Get the pubkey from Bob, so we can create the share key
@@ -1315,14 +1314,13 @@ void Controller::refreshTransactions() {
// crypto_secretstream_xchacha20poly1305_keygen(client_rx);
if (crypto_secretstream_xchacha20poly1305_init_pull(&state, header, client_rx) != 0) {
main->logger->write("Invalid header incoming, no need to go any further ");
- qDebug() <<"refreshTransactions: (incoming) crypto_secretstream_xchacha20poly1305_init_pull error!";
+ qDebug() <<"refreshTransactions: (incoming) crypto_secretstream_xchacha20poly1305_init_pull error! memo=" << memo;
continue;
}
- if (crypto_secretstream_xchacha20poly1305_pull
- (&state, decrypted, NULL, tag, MESSAGE2, CIPHERTEXT1_LEN, NULL, 0) != 0) {
+ if (crypto_secretstream_xchacha20poly1305_pull(&state, decrypted, NULL, tag, MESSAGE2, CIPHERTEXT1_LEN, NULL, 0) != 0) {
main->logger->write("Invalid/incomplete/corrupted ciphertext - abort");
- qDebug() << "refreshTransactions: (incoming) crypto_secretstream_xchacha20poly1305_pull error!";
+ qDebug() << "refreshTransactions: (incoming) crypto_secretstream_xchacha20poly1305_pull error! memo=" << memo;
continue;
}
From a135753cef63c1192170f8dd9805f418568953a9 Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sun, 30 May 2021 15:14:05 -0400
Subject: [PATCH 14/20] logging and error handling
---
src/Chat/Chat.cpp | 35 ++++++++++++++-------------------
src/DataStore/ChatDataStore.cpp | 9 +--------
src/connection.cpp | 2 ++
src/controller.cpp | 13 +++++++-----
src/mainwindow.cpp | 27 +++++++++++--------------
5 files changed, 38 insertions(+), 48 deletions(-)
diff --git a/src/Chat/Chat.cpp b/src/Chat/Chat.cpp
index 7cc06c9..0f6fb44 100644
--- a/src/Chat/Chat.cpp
+++ b/src/Chat/Chat.cpp
@@ -93,21 +93,17 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
DataStore::getChatDataStore()->dump(); // test to see if the chat items in datastore are correctly dumped to json
qDebug() << __func__ << ": looking at memos...";
- for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
+ for (auto &contact : AddressBook::getInstance()->getAllAddressLabels())
{
- for (auto &c : DataStore::getChatDataStore()->getAllMemos())
- {
+ for (auto &memo : DataStore::getChatDataStore()->getAllMemos()) {
+ if ( (contact.getName() == ui->contactNameMemo->text().trimmed()) &&
+ (contact.getPartnerAddress() == memo.second.getAddress()) &&
+ (memo.second.isOutgoing() == true)) {
- if (
- (p.getName() == ui->contactNameMemo->text().trimmed()) &&
- (p.getPartnerAddress() == c.second.getAddress()) &&
- (c.second.isOutgoing() == true))
- {
-
- QStandardItem *Items = new QStandardItem(c.second.toChatLine());
+ QStandardItem *Items = new QStandardItem(memo.second.toChatLine());
Items->setData(OUTGOING, Qt::UserRole + 1);
- qDebug() << __func__ << ": appending row to OUTGOING chatitems to contact " << p.getName() << " with item " << Items;
+ qDebug() << __func__ << ": appending row to OUTGOING chatitems to contact " << contact.getName() << " with item " << Items;
chat->appendRow(Items);
ui->listChat->setModel(chat);
@@ -115,16 +111,15 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
ui->listChat->setModel(chat);
}
- if (
- (p.getName() == ui->contactNameMemo->text().trimmed()) &&
- (p.getMyAddress() == c.second.getAddress()) &&
- (c.second.isOutgoing() == false) &&
- (c.second.getCid() == p.getCid())
- )
- {
- QStandardItem *Items1 = new QStandardItem(c.second.toChatLine());
+ qDebug() << __func__ << ": memo.first=" << memo.first;
+ if ( (contact.getName() == ui->contactNameMemo->text().trimmed()) &&
+ (contact.getMyAddress() == memo.second.getAddress()) &&
+ (memo.second.isOutgoing() == false) &&
+ (memo.second.getCid() == contact.getCid())
+ ) {
+ QStandardItem *Items1 = new QStandardItem(memo.second.toChatLine());
Items1->setData(INCOMING, Qt::UserRole + 1);
- qDebug() << __func__ << ": appending row to INCOMING chatitems to contact " << p.getName() << "with cid=" << p.getCid() << " and item " << Items1;
+ qDebug() << __func__ << ": appending row to INCOMING chatitems to contact " << contact.getName() << "with txid=" << memo.second.getTxid() << " cid=" << contact.getCid() << " item " << Items1 << " memo=" << memo.second.getMemo();
chat->appendRow(Items1);
ui->listChat->setModel(chat);
ui->memoTxtChat->setEnabled(true);
diff --git a/src/DataStore/ChatDataStore.cpp b/src/DataStore/ChatDataStore.cpp
index dbea024..0230012 100644
--- a/src/DataStore/ChatDataStore.cpp
+++ b/src/DataStore/ChatDataStore.cpp
@@ -160,14 +160,7 @@ std::map ChatDataStore::getAllMemos()
std::map filteredItems;
for(auto &c: this->data)
{
- if (
-
- (c.second.getMemo().startsWith("{") == false) &&
- (c.second.getMemo().isEmpty() == false)
-
-
- )
- {
+ if ((c.second.getMemo().startsWith("{") == false) && (c.second.getMemo().isEmpty() == false) ) {
filteredItems[c.first] = c.second;
}
}
diff --git a/src/connection.cpp b/src/connection.cpp
index c244ee8..ad6dcd9 100644
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -267,6 +267,7 @@ void ConnectionLoader::doRPCSetConnection(Connection* conn)
try {
QFile plaintextWallet(dirwalletconnection);
main->logger->write("Path to Wallet.dat : " );
+ qDebug() << __func__ << ": wallet path =" << plaintextWallet;
plaintextWallet.remove();
} catch (...) {
@@ -286,6 +287,7 @@ void ConnectionLoader::doRPCSetConnectionShield(Connection* conn)
try {
QFile plaintextWallet(dirwalletconnection);
main->logger->write("Path to Wallet.dat : " );
+ qDebug() << __func__ << ": wallet path =" << plaintextWallet;
plaintextWallet.remove();
} catch (...) {
main->logger->write("no Plaintext wallet.dat");
diff --git a/src/controller.cpp b/src/controller.cpp
index 2ff4dd3..4d9eefd 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -1236,13 +1236,13 @@ void Controller::refreshTransactions() {
}
int position = it["position"].get();
-
int ciphercheck = memo.length() - crypto_secretstream_xchacha20poly1305_ABYTES;
+ qDebug() << __func__ << ": position=" << position << " headerbytes=" << headerbytes
+ << " ciphercheck=" << ciphercheck << " for memo=" << memo;
if ((memo.startsWith("{") == false) && (headerbytes > 0) && (ciphercheck > 0))
{
- if (chatModel->getMemoByTx(txid) == QString("0xdeadbeef"))
- {
+ if (chatModel->getMemoByTx(txid) == QString("0xdeadbeef")) {
if (position == 1)
{
chatModel->addMemo(txid, headerbytes);
@@ -1352,10 +1352,13 @@ void Controller::refreshTransactions() {
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
} else {
- //
+ qDebug() << __func__ << ": ignoring txid="<< txid;
}
+ //} else if (memo.startsWith("{")) {
+ //qDebug() << __func__ << ": ignoring a header memo";
} else {
+ // Add a chatitem for the initial CR
ChatItem item = ChatItem(
datetime,
address,
@@ -1371,7 +1374,7 @@ void Controller::refreshTransactions() {
isContact
);
- qDebug() << "refreshTransactions: adding chatItem with memo=" << memo;
+ qDebug() << "refreshTransactions: adding chatItem for initial CR with memo=" << memo;
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
}
}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index a34c4c7..1ffadb7 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -86,15 +86,17 @@ MainWindow::MainWindow(QWidget *parent) :
}else{}
logger = new Logger(this, QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite-wallet.log"));
+
// Check for encryption
-
if(fileExists(dirwalletenc))
{
+ qDebug() << __func__ << ": decrypting wallet=" << dirwalletenc;
this->removeWalletEncryptionStartUp();
}
ui->memoTxtChat->setAutoFillBackground(false);
- ui->memoTxtChat->setPlaceholderText("Send Message (you can only write messages after the initial message from your contact)");
+ // TODO: make this HTML with some emoji
+ ui->memoTxtChat->setPlaceholderText("Send Memo (you can only write memo after the initial message from your contact)");
ui->memoTxtChat->setTextColor(Qt::white);
// Status Bar
@@ -543,10 +545,8 @@ void MainWindow::removeWalletEncryption() {
QObject::connect(ed.txtConfirmPassword, &QLineEdit::textChanged, fnPasswordEdited);
QObject::connect(ed.txtPassword, &QLineEdit::textChanged, fnPasswordEdited);
- if (d.exec() == QDialog::Accepted)
- {
+ if (d.exec() == QDialog::Accepted) {
QString passphraseBlank = ed.txtPassword->text(); // data comes from user inputs
-
QString passphrase = QString("HUSH3") + passphraseBlank + QString("SDL");
int length = passphrase.length();
@@ -563,18 +563,17 @@ void MainWindow::removeWalletEncryption() {
#define hash ((const unsigned char *) sequence1)
-
#define PASSWORD sequence
#define KEY_LEN crypto_box_SEEDBYTES
unsigned char key[KEY_LEN];
- if (crypto_pwhash
- (key, sizeof key, PASSWORD, strlen(PASSWORD), hash,
- crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE,
- crypto_pwhash_ALG_DEFAULT) != 0) {
+ if (crypto_pwhash(key, sizeof key, PASSWORD, strlen(PASSWORD), hash,
+ crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE, crypto_pwhash_ALG_DEFAULT) != 0) {
/* out of memory */
-}
+ qDebug() << "crypto_pwhash failed!";
+ return;
+ }
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
@@ -587,9 +586,7 @@ void MainWindow::removeWalletEncryption() {
QFile filencrypted(dirwalletenc);
QFile wallet(dirwallet);
- if (wallet.size() > 0)
- {
-
+ if (wallet.size() > 0) {
QMessageBox::information(this, tr("Wallet decryption Success"),
QString("Successfully delete the encryption"),
QMessageBox::Ok
@@ -597,7 +594,7 @@ void MainWindow::removeWalletEncryption() {
filencrypted.remove();
- }else{
+ } else {
QMessageBox::critical(this, tr("Wallet Encryption Failed"),
QString("False password, please try again"),
From b0b39054a78fb17056c9f3e39ce820cb7b210276 Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sun, 30 May 2021 16:06:00 -0400
Subject: [PATCH 15/20] Prevent chats from being showed twice, fixes qa#1
---
src/Chat/Chat.cpp | 27 ++++++++++++++++++++++-----
src/controller.cpp | 11 ++++++-----
2 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/src/Chat/Chat.cpp b/src/Chat/Chat.cpp
index 0f6fb44..09f9199 100644
--- a/src/Chat/Chat.cpp
+++ b/src/Chat/Chat.cpp
@@ -91,6 +91,7 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
QStandardItemModel *chat = new QStandardItemModel();
DataStore::getChatDataStore()->dump(); // test to see if the chat items in datastore are correctly dumped to json
+ std::map seenTxids;
qDebug() << __func__ << ": looking at memos...";
for (auto &contact : AddressBook::getInstance()->getAllAddressLabels())
@@ -120,11 +121,27 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
QStandardItem *Items1 = new QStandardItem(memo.second.toChatLine());
Items1->setData(INCOMING, Qt::UserRole + 1);
qDebug() << __func__ << ": appending row to INCOMING chatitems to contact " << contact.getName() << "with txid=" << memo.second.getTxid() << " cid=" << contact.getCid() << " item " << Items1 << " memo=" << memo.second.getMemo();
- chat->appendRow(Items1);
- ui->listChat->setModel(chat);
- ui->memoTxtChat->setEnabled(true);
- ui->emojiButton->setEnabled(true);
- ui->sendChatButton->setEnabled(true);
+
+
+ if(seenTxids.count( memo.second.getTxid() ) > 0) {
+ // Do not render the same chat multiple times
+ // TODO: this should also look at outputindex to allow for multi-part memos, when that is supported
+ qDebug() << __func__ << ": INCOMING ignoring txid=" << memo.second.getTxid();
+ continue;
+ }
+
+ // TODO: better header memo detection
+ if (memo.second.getMemo().startsWith("{")) {
+ qDebug() << __func__ << ": ignoring header memo=" << memo.second.getMemo();
+ } else {
+ chat->appendRow(Items1);
+ ui->listChat->setModel(chat);
+ ui->memoTxtChat->setEnabled(true);
+ ui->emojiButton->setEnabled(true);
+ ui->sendChatButton->setEnabled(true);
+
+ seenTxids[ memo.second.getTxid() ] = 1;
+ }
} else {
ui->listChat->setModel(chat);
diff --git a/src/controller.cpp b/src/controller.cpp
index 4d9eefd..6388842 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -1348,8 +1348,9 @@ void Controller::refreshTransactions() {
isContact
);
- qDebug() << "refreshTransactions: adding chatItem with memodecrypt=" << memodecrypt;
- DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
+ auto iid = ChatIDGenerator::getInstance()->generateID(item);
+ qDebug() << "refreshTransactions: adding chatItem with item id=" << iid << " memodecrypt=" << memodecrypt;
+ DataStore::getChatDataStore()->setData(iid, item);
} else {
qDebug() << __func__ << ": ignoring txid="<< txid;
@@ -1373,9 +1374,9 @@ void Controller::refreshTransactions() {
isNotarized,
isContact
);
-
- qDebug() << "refreshTransactions: adding chatItem for initial CR with memo=" << memo;
- DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
+ auto iid = ChatIDGenerator::getInstance()->generateID(item);
+ qDebug() << "refreshTransactions: adding chatItem for initial CR with item id="<< iid << " memo='" << memo << "'";
+ DataStore::getChatDataStore()->setData(iid, item);
}
}
}
From 3a4b1de6c3383dc7d9de4f1d9bd58474520751e2 Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Sun, 30 May 2021 16:06:38 -0400
Subject: [PATCH 16/20] 1.5.2
---
src/version.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/version.h b/src/version.h
index 0ef80ba..ce3696d 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1,3 +1,3 @@
// Copyright 2019-2021 The Hush developers
// Released under the GPLv3
-#define APP_VERSION "1.5.1"
+#define APP_VERSION "1.5.2"
From d7c1f81a7a7ee70b0f2c761855c204ef26e292b9 Mon Sep 17 00:00:00 2001
From: jahway603
Date: Fri, 4 Jun 2021 14:20:11 -0400
Subject: [PATCH 17/20] clarified rust pre-installation from user feedback
---
README.md | 27 +++++++--------------------
1 file changed, 7 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
index fcc92d0..43bbc79 100644
--- a/README.md
+++ b/README.md
@@ -10,9 +10,6 @@
-
-
SilentDragonLite is a lightwallet for HUSH ($HUSH) runs on Linux and Windows which does not require you to download the full blockchain. This is experimental software under active development!
@@ -44,20 +41,21 @@ Go to the [releases page](https://git.hush.is/hush/SilentDragonLite/releases) an
### Option 2: Compile Release Yourself
* SilentDragonLite is written in C++ 14, and can be compiled with g++/clang++/visual c++.
-* It also depends on Qt5, which you can get from [here](https://www.qt.io/download) or install using your Linux version's package manager.
-* You'll need Rust v1.49
+* It also depends on Qt5, which you can get from [here](https://www.qt.io/download) or we recommend installing using your Linux version's package manager (if available).
+* **You'll need Rust v1.49**, so install it via [Rustup in Linux](https://rustup.rs/).
#### Building on Linux
+**Nothing below will work without rust. Check that your system has rustc 1.49. If not then you need to use [Rustup in Linux](https://rustup.rs/).**
+
+Compiling can take some time, so be patient and wait for it to finish. It will take potentially a long time for slower systems. Be Patient and please report compiler problems!
+
##### Ubuntu 18.04 and 20.04:
```shell script
sudo apt-get -y install qt5-default qt5-qmake libqt5websockets5-dev qtcreator
git clone https://git.hush.is/hush/SilentDragonLite
cd SilentDragonLite
-# sometimes have to build the translations before building the binary
./build.sh linguist
-# the next step will take potentially a long time for slower systems
-# Be Patient and please report compiler problems!
./build.sh
./SilentDragonLite
```
@@ -88,20 +86,9 @@ SilentDragonLite does automatic note and utxo management, which means it doesn't
## Support
-```
-git clone https://git.hush.is/hush/SilenDragonLite
-cd SilentDragonLite
-# the next step will take potentially a long time for slower systems
-# Be Patient and please report compiler problems!
-./build.sh
-./SilentDragonLite
-```
-
-## Support
-
For support join us on [Telegram Support](https://hush.is/telegram_support), or our [Main Telegram](https://hush.is/telegram) or tweet at [@MyHushTeam](https://twitter.com/MyHushTeam), or toot at our [Mastodon](https://fosstodon.org/@myhushteam), or [file an issue](https://git.hush.is/hush/SilentDragonLite/issues).
-You can also subscribe to our channel on [YouTube](https://hush.is/yt)
+You can also subscribe to our channels on [PeerTube](https://videos.hush.is), on [YouTube](https://hush.is/yt), or on [Odyssee/LBRY](https://odysee.com/@MyHushTeam:3).
## License
From 75cdd68711b5a2de86e1ee09ea46e80beedfe28b Mon Sep 17 00:00:00 2001
From: onryo
Date: Wed, 16 Jun 2021 13:27:31 +0000
Subject: [PATCH 18/20] Update 'src/mainwindow.cpp'
---
src/mainwindow.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 1ffadb7..b87dd91 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -826,7 +826,7 @@ void MainWindow::setupSettingsModal() {
// List of default servers
settings.cmbServer->addItem("https://lite.hush.is");
- settings.cmbServer->addItem("https://lite.hush.community");
+ settings.cmbServer->addItem("https://lite.hush.land");
settings.cmbServer->addItem("https://devo.crabdance.com");
//settings.cmbServer->addItem("https://hush.leto.net:5420");
//TODO: seperate lists of https/Tor servers, only show user or attempt
From b15cd39c5fc944a84d40db176f9017e66fe94856 Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Tue, 22 Jun 2021 23:27:30 -0400
Subject: [PATCH 19/20] Welcome To The Land Of Hush
---
src/settings.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/settings.cpp b/src/settings.cpp
index 5b3d18b..845e1e3 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -308,7 +308,7 @@ QString Settings::getRandomServer() {
//"https://thisisdown3.example.com",
//"https://thisisdown4.example.com",
//"https://thisisdown5.example.com",
- "https://lite.hush.community",
+ "https://lite.hush.land"
};
// we don't need cryptographic random-ness, but we want
From 86ce11ff2c59d4827939b0022db8478cb9e22ebf Mon Sep 17 00:00:00 2001
From: Duke Leto
Date: Tue, 29 Jun 2021 13:14:28 -0400
Subject: [PATCH 20/20] update about tab
---
application.qrc | 1 +
src/mainwindow.cpp | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/application.qrc b/application.qrc
index e364bc4..967c664 100644
--- a/application.qrc
+++ b/application.qrc
@@ -54,6 +54,7 @@
+ res/hushdlogo.png
res/hushdlogo.gif
res/silentdragonlite-animated.gif
res/silentdragonlite-animated-dark.gif
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index b87dd91..b1b4037 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1344,7 +1344,7 @@ void MainWindow::setupBalancesTab() {
}
void MainWindow::setuphushdTab() {
- ui->hushdlogo->setBasePixmap(QPixmap(":/img/res/hushdlogo.gif"));
+ ui->hushdlogo->setBasePixmap(QPixmap(":/img/res/hushdlogo.png"));
}
void MainWindow::setupTransactionsTab() {