create Datastore for countedNotes over 10000 puposhis, debug for notes in send
This commit is contained in:
@@ -73,6 +73,7 @@ SOURCES += \
|
|||||||
src/DataStore/DataStore.cpp \
|
src/DataStore/DataStore.cpp \
|
||||||
src/DataStore/ChatDataStore.cpp \
|
src/DataStore/ChatDataStore.cpp \
|
||||||
src/DataStore/SietchDataStore.cpp \
|
src/DataStore/SietchDataStore.cpp \
|
||||||
|
src/DataStore/NoteCountDataStore.cpp \
|
||||||
src/DataStore/ContactDataStore.cpp \
|
src/DataStore/ContactDataStore.cpp \
|
||||||
src/Model/ChatItem.cpp \
|
src/Model/ChatItem.cpp \
|
||||||
src/Model/ContactRequestChatItem.cpp \
|
src/Model/ContactRequestChatItem.cpp \
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ 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
|
DataStore::getChatDataStore()->dump(); // test to see if the chat items in datastore are correctly dumped to json
|
||||||
std::map<QString,int> seenTxids;
|
std::map<QString,int> seenTxids;
|
||||||
|
|
||||||
qDebug() << __func__ << ": looking at memos...";
|
//qDebug() << __func__ << ": looking at memos...";
|
||||||
for (auto &contact : AddressBook::getInstance()->getAllAddressLabels())
|
for (auto &contact : AddressBook::getInstance()->getAllAddressLabels())
|
||||||
{
|
{
|
||||||
for (auto &memo : DataStore::getChatDataStore()->getAllMemos()) {
|
for (auto &memo : DataStore::getChatDataStore()->getAllMemos()) {
|
||||||
@@ -104,7 +104,7 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
|
|||||||
QStandardItem *Items = new QStandardItem(memo.second.toChatLine());
|
QStandardItem *Items = new QStandardItem(memo.second.toChatLine());
|
||||||
|
|
||||||
Items->setData(OUTGOING, Qt::UserRole + 1);
|
Items->setData(OUTGOING, Qt::UserRole + 1);
|
||||||
qDebug() << __func__ << ": appending row to OUTGOING chatitems to contact " << contact.getName() << " with item " << Items;
|
// qDebug() << __func__ << ": appending row to OUTGOING chatitems to contact " << contact.getName() << " with item " << Items;
|
||||||
chat->appendRow(Items);
|
chat->appendRow(Items);
|
||||||
ui->listChat->setModel(chat);
|
ui->listChat->setModel(chat);
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
|
|||||||
ui->listChat->setModel(chat);
|
ui->listChat->setModel(chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << __func__ << ": memo.first=" << memo.first;
|
// qDebug() << __func__ << ": memo.first=" << memo.first;
|
||||||
if ( (contact.getName() == ui->contactNameMemo->text().trimmed()) &&
|
if ( (contact.getName() == ui->contactNameMemo->text().trimmed()) &&
|
||||||
(contact.getMyAddress() == memo.second.getAddress()) &&
|
(contact.getMyAddress() == memo.second.getAddress()) &&
|
||||||
(memo.second.isOutgoing() == false) &&
|
(memo.second.isOutgoing() == false) &&
|
||||||
@@ -120,19 +120,19 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
|
|||||||
) {
|
) {
|
||||||
QStandardItem *Items1 = new QStandardItem(memo.second.toChatLine());
|
QStandardItem *Items1 = new QStandardItem(memo.second.toChatLine());
|
||||||
Items1->setData(INCOMING, Qt::UserRole + 1);
|
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();
|
// 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();
|
||||||
|
|
||||||
|
|
||||||
if(seenTxids.count( memo.second.getTxid() ) > 0) {
|
if(seenTxids.count( memo.second.getTxid() ) > 0) {
|
||||||
// Do not render the same chat multiple times
|
// 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
|
// 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();
|
// qDebug() << __func__ << ": INCOMING ignoring txid=" << memo.second.getTxid();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: better header memo detection
|
// TODO: better header memo detection
|
||||||
if (memo.second.getMemo().startsWith("{")) {
|
if (memo.second.getMemo().startsWith("{")) {
|
||||||
qDebug() << __func__ << ": ignoring header memo=" << memo.second.getMemo();
|
// qDebug() << __func__ << ": ignoring header memo=" << memo.second.getMemo();
|
||||||
} else {
|
} else {
|
||||||
chat->appendRow(Items1);
|
chat->appendRow(Items1);
|
||||||
ui->listChat->setModel(chat);
|
ui->listChat->setModel(chat);
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ SietchDataStore* DataStore::getSietchDataStore()
|
|||||||
return SietchDataStore::getInstance();
|
return SietchDataStore::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NoteCountDataStore* DataStore::getNoteCountDataStore()
|
||||||
|
{
|
||||||
|
return NoteCountDataStore::getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
ChatDataStore* DataStore::getChatDataStore()
|
ChatDataStore* DataStore::getChatDataStore()
|
||||||
{
|
{
|
||||||
return ChatDataStore::getInstance();
|
return ChatDataStore::getInstance();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#define DATASTORE_H
|
#define DATASTORE_H
|
||||||
|
|
||||||
#include "SietchDataStore.h"
|
#include "SietchDataStore.h"
|
||||||
|
#include "NoteCountDataStore.h"
|
||||||
#include "ChatDataStore.h"
|
#include "ChatDataStore.h"
|
||||||
#include "ContactDataStore.h"
|
#include "ContactDataStore.h"
|
||||||
|
|
||||||
@@ -11,6 +12,7 @@ class DataStore
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static SietchDataStore* getSietchDataStore();
|
static SietchDataStore* getSietchDataStore();
|
||||||
|
static NoteCountDataStore* getNoteCountDataStore();
|
||||||
static ChatDataStore* getChatDataStore();
|
static ChatDataStore* getChatDataStore();
|
||||||
static ContactDataStore* getContactDataStore();
|
static ContactDataStore* getContactDataStore();
|
||||||
};
|
};
|
||||||
|
|||||||
51
src/DataStore/NoteCountDataStore.cpp
Normal file
51
src/DataStore/NoteCountDataStore.cpp
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#include "NoteCountDataStore.h"
|
||||||
|
|
||||||
|
NoteCountDataStore* NoteCountDataStore::instance = nullptr;
|
||||||
|
bool NoteCountDataStore::instanced = false;
|
||||||
|
|
||||||
|
NoteCountDataStore* NoteCountDataStore::getInstance() {
|
||||||
|
if (!instanced) {
|
||||||
|
instanced = true;
|
||||||
|
instance = new NoteCountDataStore();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NoteCountDataStore::clear() {
|
||||||
|
data.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NoteCountDataStore::setData(const QString& key, const QString& value) {
|
||||||
|
data[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NoteCountDataStore::getData(const QString& key) {
|
||||||
|
return data.value(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NoteCountDataStore::dump() {
|
||||||
|
QString result;
|
||||||
|
for (const auto& key : data.keys()) {
|
||||||
|
result += key + ": " + data[key] + "\n";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NoteCountDataStore::setSpendableNotesCount(int count) {
|
||||||
|
spendableNotesCount = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int NoteCountDataStore::getSpendableNotesCount() const {
|
||||||
|
return spendableNotesCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NoteCountDataStore::setAddressWithMaxValue(const QString& address, int value) {
|
||||||
|
if (value > maxValue) {
|
||||||
|
maxValue = value;
|
||||||
|
addressWithMaxValue = address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NoteCountDataStore::getAddressWithMaxValue() const {
|
||||||
|
return addressWithMaxValue;
|
||||||
|
}
|
||||||
36
src/DataStore/NoteCountDataStore.h
Normal file
36
src/DataStore/NoteCountDataStore.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#ifndef NOTECOUNTDATASTORE_H
|
||||||
|
#define NOTECOUNTDATASTORE_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
class NoteCountDataStore {
|
||||||
|
private:
|
||||||
|
static NoteCountDataStore* instance;
|
||||||
|
static bool instanced;
|
||||||
|
QMap<QString, QString> data;
|
||||||
|
int spendableNotesCount;
|
||||||
|
QString addressWithMaxValue;
|
||||||
|
int maxValue; // Hinzugefügt, um den maximalen Wert zu speichern
|
||||||
|
|
||||||
|
NoteCountDataStore() : spendableNotesCount(0), maxValue(0) {} // Initialisiere maxValue
|
||||||
|
|
||||||
|
public:
|
||||||
|
static NoteCountDataStore* getInstance();
|
||||||
|
void clear();
|
||||||
|
void setData(const QString& key, const QString& value);
|
||||||
|
QString getData(const QString& key);
|
||||||
|
QString dump();
|
||||||
|
|
||||||
|
void setSpendableNotesCount(int count);
|
||||||
|
int getSpendableNotesCount() const;
|
||||||
|
void setAddressWithMaxValue(const QString& address, int value);
|
||||||
|
QString getAddressWithMaxValue() const;
|
||||||
|
|
||||||
|
~NoteCountDataStore() {
|
||||||
|
instanced = false;
|
||||||
|
instance = nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NOTECOUNTDATASTORE_H
|
||||||
@@ -449,7 +449,7 @@ Tx MainWindow::createTxFromChatPage() {
|
|||||||
|
|
||||||
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 ");
|
this->logger->write("Suspicious keypair, bail out ");
|
||||||
qDebug() << __func__<< ": Suspicious client public outgoing key from crypto_kx_seed_keypair, aborting!";
|
// qDebug() << __func__<< ": Suspicious client public outgoing key from crypto_kx_seed_keypair, aborting!";
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,7 +462,7 @@ Tx MainWindow::createTxFromChatPage() {
|
|||||||
|
|
||||||
if (crypto_kx_server_session_keys(server_rx, server_tx, pk, sk, pubkeyBob) != 0) {
|
if (crypto_kx_server_session_keys(server_rx, server_tx, pk, sk, pubkeyBob) != 0) {
|
||||||
this->logger->write("Suspicious client public send key, bail out ");
|
this->logger->write("Suspicious client public send key, bail out ");
|
||||||
qDebug() << __func__ << ": Suspicious client public send key from crypto_kx_server_session_keys, aborting!";
|
// << __func__ << ": Suspicious client public send key from crypto_kx_server_session_keys, aborting!";
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -371,7 +371,7 @@ void ConnectionLoader::showError(QString explanation)
|
|||||||
|
|
||||||
QString litelib_process_response(char* resp)
|
QString litelib_process_response(char* resp)
|
||||||
{
|
{
|
||||||
qDebug() << __func__ << ": " << resp;
|
//qDebug() << __func__ << ": " << resp;
|
||||||
|
|
||||||
char* resp_copy = new char[strlen(resp) + 1];
|
char* resp_copy = new char[strlen(resp) + 1];
|
||||||
//a safer version of strcpy
|
//a safer version of strcpy
|
||||||
@@ -452,7 +452,7 @@ Connection::Connection(MainWindow* m, std::shared_ptr<ConnectionConfig> conf)
|
|||||||
{
|
{
|
||||||
this->config = conf;
|
this->config = conf;
|
||||||
this->main = m;
|
this->main = m;
|
||||||
qDebug() << __func__;
|
// qDebug() << __func__;
|
||||||
// Register the JSON type as a type that can be passed between signals and slots.
|
// Register the JSON type as a type that can be passed between signals and slots.
|
||||||
qRegisterMetaType<json>("json");
|
qRegisterMetaType<json>("json");
|
||||||
}
|
}
|
||||||
@@ -464,7 +464,7 @@ void Connection::doRPC(const QString cmd, const QString args, const std::functio
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG("cmd=" << cmd << " args=" << args);
|
//DEBUG("cmd=" << cmd << " args=" << args);
|
||||||
|
|
||||||
// Create a runner.
|
// Create a runner.
|
||||||
auto runner = new Executor(cmd, args);
|
auto runner = new Executor(cmd, args);
|
||||||
@@ -479,7 +479,7 @@ void Connection::doRPC(const QString cmd, const QString args, const std::functio
|
|||||||
|
|
||||||
void Connection::doRPCWithDefaultErrorHandling(const QString cmd, const QString args, const std::function<void(json)>& cb)
|
void Connection::doRPCWithDefaultErrorHandling(const QString cmd, const QString args, const std::function<void(json)>& cb)
|
||||||
{
|
{
|
||||||
DEBUG("cmd=" << cmd << " args=" << args);
|
//DEBUG("cmd=" << cmd << " args=" << args);
|
||||||
doRPC(cmd, args, cb, [=] (QString err) {
|
doRPC(cmd, args, cb, [=] (QString err) {
|
||||||
this->showTxError(err);
|
this->showTxError(err);
|
||||||
});
|
});
|
||||||
@@ -487,7 +487,7 @@ void Connection::doRPCWithDefaultErrorHandling(const QString cmd, const QString
|
|||||||
|
|
||||||
void Connection::doRPCIgnoreError(const QString cmd, const QString args, const std::function<void(json)>& cb)
|
void Connection::doRPCIgnoreError(const QString cmd, const QString args, const std::function<void(json)>& cb)
|
||||||
{
|
{
|
||||||
DEBUG("cmd=" << cmd << " args=" << args);
|
// DEBUG("cmd=" << cmd << " args=" << args);
|
||||||
doRPC(cmd, args, cb, [=] (auto) {
|
doRPC(cmd, args, cb, [=] (auto) {
|
||||||
// Ignored error handling
|
// Ignored error handling
|
||||||
});
|
});
|
||||||
@@ -495,7 +495,7 @@ void Connection::doRPCIgnoreError(const QString cmd, const QString args, const s
|
|||||||
|
|
||||||
void Connection::showTxError(const QString& error)
|
void Connection::showTxError(const QString& error)
|
||||||
{
|
{
|
||||||
qDebug() << __func__ << ": " << error;
|
// qDebug() << __func__ << ": " << error;
|
||||||
if (error.isNull())
|
if (error.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ using json = nlohmann::json;
|
|||||||
Controller::Controller(MainWindow* main)
|
Controller::Controller(MainWindow* main)
|
||||||
{
|
{
|
||||||
auto cl = new ConnectionLoader(main, this);
|
auto cl = new ConnectionLoader(main, this);
|
||||||
qDebug() << __func__ << ": cl=" << cl << endl;
|
//qDebug() << __func__ << ": cl=" << cl << endl;
|
||||||
|
|
||||||
// Execute the load connection async, so we can set up the rest of RPC properly.
|
// Execute the load connection async, so we can set up the rest of RPC properly.
|
||||||
QTimer::singleShot(1, [=]() { cl->loadConnection(); });
|
QTimer::singleShot(1, [=]() { cl->loadConnection(); });
|
||||||
|
|
||||||
qDebug() << __func__ << "after loadConnection" << endl;
|
// qDebug() << __func__ << "after loadConnection" << endl;
|
||||||
|
|
||||||
this->main = main;
|
this->main = main;
|
||||||
this->ui = main->ui;
|
this->ui = main->ui;
|
||||||
@@ -125,131 +125,136 @@ void Controller::setConnection(Connection* c)
|
|||||||
|
|
||||||
ui->listChat->verticalScrollBar()->setValue(
|
ui->listChat->verticalScrollBar()->setValue(
|
||||||
ui->listChat->verticalScrollBar()->maximum());
|
ui->listChat->verticalScrollBar()->maximum());
|
||||||
|
|
||||||
|
fetchAndProcessUnspentNotes();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the RPC JSON Parameters for this tx
|
// Build the RPC JSON Parameters for this tx
|
||||||
void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
|
void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
|
||||||
{
|
{
|
||||||
Q_ASSERT(allRecepients.is_array());
|
Q_ASSERT(allRecepients.is_array());
|
||||||
|
|
||||||
// Variablen zur Speicherung der Adresse mit dem höchsten Gesamtwert
|
// Construct the JSON params
|
||||||
std::string addressWithMaxValue;
|
json rec = json::object();
|
||||||
int maxValue = 0;
|
|
||||||
std::map<std::string, int> addressValues;
|
|
||||||
|
|
||||||
// Zähle die Anzahl der spendablen Notizen mit einem Wert über 10.000
|
//creating the JSON dust parameters in a std::vector to iterate over there during tx
|
||||||
int spendableNotesCount = 0;
|
std::vector<json> dust(8);
|
||||||
bool replaceDustTransaction = false; // Standardmäßig keine Ersetzung
|
dust.resize(8, json::object());
|
||||||
|
|
||||||
std::promise<void> fetchPromise;
|
// Create Sietch zdust addr again to not use it twice.
|
||||||
std::future<void> fetchFuture = fetchPromise.get_future();
|
// Using DataStore singelton, to store the data outside of lambda, bing bada boom :D
|
||||||
|
for(uint8_t i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
zrpc->createNewSietchZaddr( [=] (json reply) {
|
||||||
|
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
DataStore::getSietchDataStore()->setData(QString("Sietch") + QString(i), zdust.toUtf8());
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
// Set sietch zdust addr to json.
|
||||||
|
// Using DataStore singelton, to store the data into the dust.
|
||||||
|
for(uint8_t i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
dust.at(i)["address"] = DataStore::getSietchDataStore()->getData(QString("Sietch" + QString(i))).toStdString();
|
||||||
|
}
|
||||||
|
|
||||||
zrpc->fetchUnspent([=, &spendableNotesCount, &replaceDustTransaction, &addressValues, &addressWithMaxValue, &maxValue, &fetchPromise] (json reply) {
|
DataStore::getSietchDataStore()->clear(); // clears the datastore
|
||||||
// Fehlerbehandlung hinzugefügt
|
|
||||||
if (reply.find("unspent_notes") == reply.end() || !reply["unspent_notes"].is_array()) {
|
// Debugging, um die Daten aus NoteCountDataStore zu zeigen
|
||||||
qDebug() << "Fehler: 'unspent_notes' fehlt oder ist kein Array";
|
int spendableNotesCount = NoteCountDataStore::getInstance()->getSpendableNotesCount();
|
||||||
fetchPromise.set_value();
|
QString addressWithMaxValue = NoteCountDataStore::getInstance()->getAddressWithMaxValue();
|
||||||
return;
|
|
||||||
|
qDebug() << "Anzahl der spendablen Notizen über 10000:" << spendableNotesCount;
|
||||||
|
qDebug() << "Adresse mit dem höchsten Gesamtwert:" << addressWithMaxValue;
|
||||||
|
|
||||||
|
|
||||||
|
const QString possibleCharacters("0123456789abcdef");
|
||||||
|
int sizerandomString = 512;
|
||||||
|
const int randomStringLength = sizerandomString;
|
||||||
|
|
||||||
|
for(uint8_t i = 0; i < 8; i++) {
|
||||||
|
QString randomString;
|
||||||
|
QRandomGenerator *gen = QRandomGenerator::system();
|
||||||
|
|
||||||
|
for(int i=0; i<randomStringLength; ++i) {
|
||||||
|
int index = gen->bounded(0, possibleCharacters.length() - 1);
|
||||||
|
QChar nextChar = possibleCharacters.at(index);
|
||||||
|
randomString.append(nextChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bearbeite die Antwort
|
dust.at(i)["memo"] = randomString.toStdString();
|
||||||
|
|
||||||
for (const auto& note : reply["unspent_notes"]) {
|
|
||||||
if (note.find("spendable") != note.end() && note.find("value") != note.end() &&
|
|
||||||
note["spendable"].is_boolean() && note["value"].is_number_integer()) {
|
|
||||||
|
|
||||||
if (note["spendable"] && note["value"] >= 10000) {
|
|
||||||
spendableNotesCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string address = note["address"];
|
|
||||||
int value = note["value"];
|
|
||||||
addressValues[address] += value;
|
|
||||||
if (addressValues[address] > maxValue) {
|
|
||||||
maxValue = addressValues[address];
|
|
||||||
addressWithMaxValue = address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
replaceDustTransaction = spendableNotesCount < 10;
|
|
||||||
qDebug() << "Nutzbare Notes Anzahl : " << spendableNotesCount;
|
|
||||||
fetchPromise.set_value();
|
|
||||||
});
|
|
||||||
|
|
||||||
fetchFuture.wait(); // Warte auf die Fertigstellung des fetchUnspent-Aufrufs
|
|
||||||
|
|
||||||
// Erstelle die Staubtransaktionen
|
|
||||||
std::vector<json> dust(8, json::object());
|
|
||||||
|
|
||||||
// Promises und Futures für die asynchronen Aufrufe
|
|
||||||
std::vector<std::promise<json>> promises(8);
|
|
||||||
std::vector<std::future<json>> futures;
|
|
||||||
for (int i = 0; i < 8; i++) {
|
|
||||||
futures.push_back(promises[i].get_future());
|
|
||||||
|
|
||||||
zrpc->createNewSietchZaddr([=, &promises] (json reply) {
|
|
||||||
promises[i].set_value(reply);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warte auf die Fertigstellung aller Futures
|
for(auto &it: dust)
|
||||||
for (auto& future : futures) {
|
{
|
||||||
future.wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verarbeite die Ergebnisse der Futures
|
|
||||||
for (int i = 0; i < 8; i++) {
|
|
||||||
json reply = futures[i].get(); // Hier erhalten wir das Ergebnis
|
|
||||||
std::string zdust = reply[0];
|
|
||||||
dust.at(i)["address"] = zdust;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setze Staubtransaktionen
|
|
||||||
for(auto &it: dust) {
|
|
||||||
it["amount"] = 0;
|
it["amount"] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generiere zufälliges Memo
|
// For each addr/amt/memo, construct the JSON and also build the confirm dialog box
|
||||||
const QString possibleCharacters("0123456789abcdef");
|
for (int i=0; i < tx.toAddrs.size(); i++)
|
||||||
const int randomStringLength = 512; // Länge des zufälligen Strings
|
{
|
||||||
QString randomString;
|
auto toAddr = tx.toAddrs[i];
|
||||||
|
|
||||||
for(int i = 0; i < randomStringLength; ++i) {
|
|
||||||
int index = QRandomGenerator::global()->bounded(possibleCharacters.length());
|
|
||||||
randomString.append(possibleCharacters.at(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Füge Transaktionen hinzu
|
|
||||||
json rec = json::object();
|
|
||||||
for (int i = 0; i < tx.toAddrs.size(); i++) {
|
|
||||||
auto toAddr = tx.toAddrs[i];
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entscheide, ob eine Staubtransaktion ersetzt werden soll
|
int decider = rand() % 100 + 1 ; ; // random int between 1 and 100
|
||||||
if (replaceDustTransaction) {
|
if (tx.toAddrs.size() < 2) {
|
||||||
int dustIndexToReplace = rand() % dust.size(); // Zufälliger Index
|
|
||||||
auto& dustTransactionToReplace = dust.at(dustIndexToReplace);
|
if(decider % 4 == 3) {
|
||||||
dustTransactionToReplace["address"] = addressWithMaxValue; // Adresse mit dem höchsten Gesamtwert
|
allRecepients.insert(std::begin(allRecepients), {
|
||||||
dustTransactionToReplace["amount"] = 10000;
|
dust.at(0),
|
||||||
dustTransactionToReplace["memo"] = randomString.toStdString();
|
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)
|
||||||
|
}) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Füge Staubtransaktionen einzeln hinzu
|
|
||||||
for (const auto& dustTransaction : dust) {
|
|
||||||
allRecepients.push_back(dustTransaction);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::noConnection()
|
void Controller::noConnection()
|
||||||
{
|
{
|
||||||
qDebug()<< __func__;
|
//qDebug()<< __func__;
|
||||||
QIcon i = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical);
|
QIcon i = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical);
|
||||||
main->statusIcon->setPixmap(i.pixmap(16, 16));
|
main->statusIcon->setPixmap(i.pixmap(16, 16));
|
||||||
main->statusIcon->setToolTip("");
|
main->statusIcon->setToolTip("");
|
||||||
@@ -282,7 +287,7 @@ void Controller::noConnection()
|
|||||||
/// This will refresh all the balance data from hushd
|
/// This will refresh all the balance data from hushd
|
||||||
void Controller::refresh(bool force)
|
void Controller::refresh(bool force)
|
||||||
{
|
{
|
||||||
qDebug()<< __func__;
|
//qDebug()<< __func__;
|
||||||
if (!zrpc->haveConnection())
|
if (!zrpc->haveConnection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -309,7 +314,7 @@ void Controller::processInfo(const json& info)
|
|||||||
|
|
||||||
void Controller::getInfoThenRefresh(bool force)
|
void Controller::getInfoThenRefresh(bool force)
|
||||||
{
|
{
|
||||||
qDebug()<< __func__;
|
//qDebug()<< __func__;
|
||||||
if (!zrpc->haveConnection())
|
if (!zrpc->haveConnection())
|
||||||
return noConnection();
|
return noConnection();
|
||||||
|
|
||||||
@@ -643,7 +648,7 @@ void Controller::setLag(int lag)
|
|||||||
|
|
||||||
void Controller::refreshAddresses()
|
void Controller::refreshAddresses()
|
||||||
{
|
{
|
||||||
qDebug()<< __func__;
|
//qDebug()<< __func__;
|
||||||
if (!zrpc->haveConnection())
|
if (!zrpc->haveConnection())
|
||||||
return noConnection();
|
return noConnection();
|
||||||
|
|
||||||
@@ -688,7 +693,7 @@ void Controller::updateUI(bool anyUnconfirmed)
|
|||||||
|
|
||||||
void Controller::supplyUpdate() {
|
void Controller::supplyUpdate() {
|
||||||
|
|
||||||
qDebug()<< __func__ << ": updating supply";
|
// qDebug()<< __func__ << ": updating supply";
|
||||||
|
|
||||||
// Get the total supply and render it with thousand decimal
|
// Get the total supply and render it with thousand decimal
|
||||||
zrpc->fetchSupply([=] (const json& reply) {
|
zrpc->fetchSupply([=] (const json& reply) {
|
||||||
@@ -709,7 +714,7 @@ void Controller::supplyUpdate() {
|
|||||||
ui->supply_zaddr->setText("HUSH " +(QLocale(QLocale::English).toString(zfunds)));
|
ui->supply_zaddr->setText("HUSH " +(QLocale(QLocale::English).toString(zfunds)));
|
||||||
ui->supply_total->setText("HUSH " +(QLocale(QLocale::English).toString(total)));
|
ui->supply_total->setText("HUSH " +(QLocale(QLocale::English).toString(total)));
|
||||||
}
|
}
|
||||||
qDebug() << __func__ << ": supply=" << supply;
|
//qDebug() << __func__ << ": supply=" << supply;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -898,7 +903,7 @@ void Controller::updateUIBalances()
|
|||||||
|
|
||||||
void Controller::refreshBalances()
|
void Controller::refreshBalances()
|
||||||
{
|
{
|
||||||
qDebug()<< __func__;
|
//qDebug()<< __func__;
|
||||||
if (!zrpc->haveConnection())
|
if (!zrpc->haveConnection())
|
||||||
return noConnection();
|
return noConnection();
|
||||||
|
|
||||||
@@ -971,11 +976,11 @@ void printJsonValue(QTextStream& out, const nlohmann::json& j, int depth = 0) {
|
|||||||
|
|
||||||
|
|
||||||
void Controller::refreshTransactions() {
|
void Controller::refreshTransactions() {
|
||||||
qDebug()<< __func__;
|
//qDebug()<< __func__;
|
||||||
if (!zrpc->haveConnection())
|
if (!zrpc->haveConnection())
|
||||||
return noConnection();
|
return noConnection();
|
||||||
|
|
||||||
qDebug() << __func__ << ": fetchTransactions";
|
// qDebug() << __func__ << ": fetchTransactions";
|
||||||
zrpc->fetchTransactions([=] (json reply) {
|
zrpc->fetchTransactions([=] (json reply) {
|
||||||
QList<TransactionItem> txdata;
|
QList<TransactionItem> txdata;
|
||||||
|
|
||||||
@@ -1087,7 +1092,7 @@ void Controller::refreshTransactions() {
|
|||||||
if (crypto_kx_seed_keypair(pk, sk, MESSAGEAS1) !=0)
|
if (crypto_kx_seed_keypair(pk, sk, MESSAGEAS1) !=0)
|
||||||
{
|
{
|
||||||
main->logger->write("Keypair outgoing error");
|
main->logger->write("Keypair outgoing error");
|
||||||
qDebug() << "refreshTransactions: crypto_kx_seed_keypair error";
|
// qDebug() << "refreshTransactions: crypto_kx_seed_keypair error";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1098,7 +1103,7 @@ void Controller::refreshTransactions() {
|
|||||||
if (crypto_kx_server_session_keys(server_rx, server_tx, pk, sk, pubkeyBob) != 0)
|
if (crypto_kx_server_session_keys(server_rx, server_tx, pk, sk, pubkeyBob) != 0)
|
||||||
{
|
{
|
||||||
main->logger->write("Suspicious client public outgoing key, bail out ");
|
main->logger->write("Suspicious client public outgoing key, bail out ");
|
||||||
qDebug() << "refreshTransactions: Suspicious client public outgoing key, aborting!";
|
// qDebug() << "refreshTransactions: Suspicious client public outgoing key, aborting!";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1127,13 +1132,13 @@ void Controller::refreshTransactions() {
|
|||||||
|
|
||||||
if (crypto_secretstream_xchacha20poly1305_init_pull(&state, header, server_tx) != 0) {
|
if (crypto_secretstream_xchacha20poly1305_init_pull(&state, header, server_tx) != 0) {
|
||||||
/* Invalid header, no need to go any further */
|
/* Invalid header, no need to go any further */
|
||||||
qDebug() << "refreshTransactions: crypto_secretstream_xchacha20poly1305_init_pull error! Invalid header";
|
// qDebug() << "refreshTransactions: crypto_secretstream_xchacha20poly1305_init_pull error! Invalid header";
|
||||||
continue;
|
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) {
|
||||||
/* Invalid/incomplete/corrupted ciphertext - abort */
|
/* Invalid/incomplete/corrupted ciphertext - abort */
|
||||||
qDebug() << "refreshTransactions: crypto_secretstream_xchacha20poly1305_pull error! Invalid ciphertext";
|
// qDebug() << "refreshTransactions: crypto_secretstream_xchacha20poly1305_pull error! Invalid ciphertext";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1163,7 +1168,7 @@ void Controller::refreshTransactions() {
|
|||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
qDebug() << "refreshTransactions: adding chatItem with memodecrypt=" << memodecrypt;
|
// qDebug() << "refreshTransactions: adding chatItem with memodecrypt=" << memodecrypt;
|
||||||
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
|
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
|
||||||
// updateUIBalances();
|
// updateUIBalances();
|
||||||
}
|
}
|
||||||
@@ -1277,8 +1282,8 @@ void Controller::refreshTransactions() {
|
|||||||
|
|
||||||
int position = it["position"].get<json::number_integer_t>();
|
int position = it["position"].get<json::number_integer_t>();
|
||||||
int ciphercheck = memo.length() - crypto_secretstream_xchacha20poly1305_ABYTES;
|
int ciphercheck = memo.length() - crypto_secretstream_xchacha20poly1305_ABYTES;
|
||||||
qDebug() << __func__ << ": position=" << position << " headerbytes=" << headerbytes
|
// qDebug() << __func__ << ": position=" << position << " headerbytes=" << headerbytes
|
||||||
<< " ciphercheck=" << ciphercheck << " for memo=" << memo;
|
// << " ciphercheck=" << ciphercheck << " for memo=" << memo;
|
||||||
|
|
||||||
if ((memo.startsWith("{") == false) && (headerbytes > 0) && (ciphercheck > 0))
|
if ((memo.startsWith("{") == false) && (headerbytes > 0) && (ciphercheck > 0))
|
||||||
{
|
{
|
||||||
@@ -1309,7 +1314,7 @@ void Controller::refreshTransactions() {
|
|||||||
if (crypto_kx_seed_keypair(pk, sk, MESSAGEAS1) !=0)
|
if (crypto_kx_seed_keypair(pk, sk, MESSAGEAS1) !=0)
|
||||||
{
|
{
|
||||||
main->logger->write("Suspicious outgoing key pair, bail out ");
|
main->logger->write("Suspicious outgoing key pair, bail out ");
|
||||||
qDebug() << "refreshTransactions: (incoming) crypto_kx_seed_keypair error!";
|
// qDebug() << "refreshTransactions: (incoming) crypto_kx_seed_keypair error!";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1320,7 +1325,7 @@ void Controller::refreshTransactions() {
|
|||||||
if (crypto_kx_client_session_keys(client_rx, client_tx, pk, sk, pubkeyBob) != 0)
|
if (crypto_kx_client_session_keys(client_rx, client_tx, pk, sk, pubkeyBob) != 0)
|
||||||
{
|
{
|
||||||
main->logger->write("Suspicious client public incoming key, bail out ");
|
main->logger->write("Suspicious client public incoming key, bail out ");
|
||||||
qDebug() << "refreshTransactions: (incoming) crypto_kx_client_session_keys error!";
|
// qDebug() << "refreshTransactions: (incoming) crypto_kx_client_session_keys error!";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1348,13 +1353,13 @@ void Controller::refreshTransactions() {
|
|||||||
// crypto_secretstream_xchacha20poly1305_keygen(client_rx);
|
// crypto_secretstream_xchacha20poly1305_keygen(client_rx);
|
||||||
if (crypto_secretstream_xchacha20poly1305_init_pull(&state, header, client_rx) != 0) {
|
if (crypto_secretstream_xchacha20poly1305_init_pull(&state, header, client_rx) != 0) {
|
||||||
main->logger->write("Invalid header incoming, no need to go any further ");
|
main->logger->write("Invalid header incoming, no need to go any further ");
|
||||||
qDebug() <<"refreshTransactions: (incoming) crypto_secretstream_xchacha20poly1305_init_pull error! memo=" << memo;
|
//qDebug() <<"refreshTransactions: (incoming) crypto_secretstream_xchacha20poly1305_init_pull error! memo=" << memo;
|
||||||
continue;
|
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");
|
main->logger->write("Invalid/incomplete/corrupted ciphertext - abort");
|
||||||
qDebug() << "refreshTransactions: (incoming) crypto_secretstream_xchacha20poly1305_pull error! memo=" << memo;
|
// qDebug() << "refreshTransactions: (incoming) crypto_secretstream_xchacha20poly1305_pull error! memo=" << memo;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1382,11 +1387,11 @@ void Controller::refreshTransactions() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
auto iid = ChatIDGenerator::getInstance()->generateID(item);
|
auto iid = ChatIDGenerator::getInstance()->generateID(item);
|
||||||
qDebug() << "refreshTransactions: adding chatItem with item id=" << iid << " memodecrypt=" << memodecrypt;
|
// qDebug() << "refreshTransactions: adding chatItem with item id=" << iid << " memodecrypt=" << memodecrypt;
|
||||||
DataStore::getChatDataStore()->setData(iid, item);
|
DataStore::getChatDataStore()->setData(iid, item);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << __func__ << ": ignoring txid="<< txid;
|
// qDebug() << __func__ << ": ignoring txid="<< txid;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -1406,7 +1411,7 @@ void Controller::refreshTransactions() {
|
|||||||
isContact
|
isContact
|
||||||
);
|
);
|
||||||
auto iid = ChatIDGenerator::getInstance()->generateID(item);
|
auto iid = ChatIDGenerator::getInstance()->generateID(item);
|
||||||
qDebug() << "refreshTransactions: adding chatItem for initial CR with item id="<< iid << " memo='" << memo << "'";
|
// qDebug() << "refreshTransactions: adding chatItem for initial CR with item id="<< iid << " memo='" << memo << "'";
|
||||||
DataStore::getChatDataStore()->setData(iid, item);
|
DataStore::getChatDataStore()->setData(iid, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1433,7 +1438,7 @@ void Controller::refreshTransactions() {
|
|||||||
|
|
||||||
// Update model data, which updates the table view
|
// Update model data, which updates the table view
|
||||||
transactionsTableModel->replaceData(txdata);
|
transactionsTableModel->replaceData(txdata);
|
||||||
qDebug() << __func__ << ": calling renderChatBox";
|
// qDebug() << __func__ << ": calling renderChatBox";
|
||||||
chat->renderChatBox(ui, ui->listChat,ui->memoSizeChat);
|
chat->renderChatBox(ui, ui->listChat,ui->memoSizeChat);
|
||||||
ui->listChat->verticalScrollBar()->setValue(ui->listChat->verticalScrollBar()->maximum());
|
ui->listChat->verticalScrollBar()->setValue(ui->listChat->verticalScrollBar()->maximum());
|
||||||
|
|
||||||
@@ -1443,7 +1448,7 @@ void Controller::refreshTransactions() {
|
|||||||
|
|
||||||
void Controller::refreshChat(QListView *listWidget, QLabel *label)
|
void Controller::refreshChat(QListView *listWidget, QLabel *label)
|
||||||
{
|
{
|
||||||
qDebug() << __func__ << ": calling renderChatBox";
|
// qDebug() << __func__ << ": calling renderChatBox";
|
||||||
chat->renderChatBox(ui, listWidget, label);
|
chat->renderChatBox(ui, listWidget, label);
|
||||||
ui->listChat->verticalScrollBar()->setValue(ui->listChat->verticalScrollBar()->maximum());
|
ui->listChat->verticalScrollBar()->setValue(ui->listChat->verticalScrollBar()->maximum());
|
||||||
|
|
||||||
@@ -1570,7 +1575,7 @@ void Controller::executeTransaction(Tx tx,
|
|||||||
|
|
||||||
void Controller::checkForUpdate(bool silent)
|
void Controller::checkForUpdate(bool silent)
|
||||||
{
|
{
|
||||||
qDebug()<< __func__;
|
// qDebug()<< __func__;
|
||||||
// No checking for updates, needs testing with Gitea
|
// No checking for updates, needs testing with Gitea
|
||||||
return;
|
return;
|
||||||
if (!zrpc->haveConnection())
|
if (!zrpc->haveConnection())
|
||||||
@@ -2017,7 +2022,7 @@ void Controller::shutdownhushd()
|
|||||||
// Save the wallet and exit the lightclient library cleanly.
|
// Save the wallet and exit the lightclient library cleanly.
|
||||||
if (!zrpc) {
|
if (!zrpc) {
|
||||||
zrpc = new LiteInterface();
|
zrpc = new LiteInterface();
|
||||||
qDebug() << __func__ << ": created new rpc connection zrpc=" << zrpc;
|
// qDebug() << __func__ << ": created new rpc connection zrpc=" << zrpc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zrpc && zrpc->haveConnection())
|
if (zrpc && zrpc->haveConnection())
|
||||||
@@ -2084,3 +2089,42 @@ QString Controller::getDefaultTAddress()
|
|||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::fetchAndProcessUnspentNotes() {
|
||||||
|
zrpc->fetchUnspent([=] (json reply) {
|
||||||
|
|
||||||
|
if (reply.find("unspent_notes") == reply.end() || !reply["unspent_notes"].is_array()) {
|
||||||
|
qDebug() << "Fehler: 'unspent_notes' fehlt oder ist kein Array";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int spendableNotesCount = 0;
|
||||||
|
std::map<std::string, int> addressValues;
|
||||||
|
std::string addressWithMaxValue;
|
||||||
|
int maxValue = 0;
|
||||||
|
|
||||||
|
for (const auto& note : reply["unspent_notes"]) {
|
||||||
|
if (note.find("spendable") != note.end() && note.find("value") != note.end() &&
|
||||||
|
note["spendable"].is_boolean() && note["value"].is_number_integer()) {
|
||||||
|
|
||||||
|
if (note["spendable"] && note["value"] >= 10000) {
|
||||||
|
spendableNotesCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string address = note["address"];
|
||||||
|
int value = note["value"];
|
||||||
|
addressValues[address] += value;
|
||||||
|
if (addressValues[address] > maxValue) {
|
||||||
|
maxValue = addressValues[address];
|
||||||
|
addressWithMaxValue = address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NoteCountDataStore::getInstance()->setSpendableNotesCount(spendableNotesCount);
|
||||||
|
|
||||||
|
if (!addressWithMaxValue.empty()) {
|
||||||
|
NoteCountDataStore::getInstance()->setAddressWithMaxValue(QString::fromStdString(addressWithMaxValue), maxValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -98,6 +98,8 @@ public:
|
|||||||
void noConnection();
|
void noConnection();
|
||||||
bool isEmbedded() { return ehushd != nullptr; }
|
bool isEmbedded() { return ehushd != nullptr; }
|
||||||
|
|
||||||
|
void fetchAndProcessUnspentNotes();
|
||||||
|
|
||||||
void encryptWallet(QString password, const std::function<void(json)>& cb) {
|
void encryptWallet(QString password, const std::function<void(json)>& cb) {
|
||||||
zrpc->encryptWallet(password, cb);
|
zrpc->encryptWallet(password, cb);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,12 +45,15 @@ void LiteInterface::importTPrivKey(QString addr,const std::function<void(json)>&
|
|||||||
|
|
||||||
|
|
||||||
void LiteInterface::fetchUnspent(const std::function<void(json)>& cb) {
|
void LiteInterface::fetchUnspent(const std::function<void(json)>& cb) {
|
||||||
if (conn == nullptr)
|
if (conn == nullptr) {
|
||||||
|
qDebug() << "fetchUnspent: conn ist nullptr, breche ab";
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
conn->doRPCWithDefaultErrorHandling("notes", "", cb);
|
conn->doRPCWithDefaultErrorHandling("notes", "", cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LiteInterface::createNewZaddr(bool, const std::function<void(json)>& cb) {
|
void LiteInterface::createNewZaddr(bool, const std::function<void(json)>& cb) {
|
||||||
if (conn == nullptr)
|
if (conn == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
qDebug() << __func__ << endl;
|
// qDebug() << __func__ << endl;
|
||||||
|
|
||||||
// Include css
|
// Include css
|
||||||
QString theme_name;
|
QString theme_name;
|
||||||
|
|||||||
Reference in New Issue
Block a user