Qtification "lite" - first round

This commit is contained in:
miodragpop
2020-06-15 13:11:39 +02:00
parent efa216a131
commit e20efde2ed
29 changed files with 859 additions and 19772 deletions

View File

@@ -94,7 +94,6 @@ HEADERS += \
src/3rdparty/qrcode/BitBuffer.hpp \ src/3rdparty/qrcode/BitBuffer.hpp \
src/3rdparty/qrcode/QrCode.hpp \ src/3rdparty/qrcode/QrCode.hpp \
src/3rdparty/qrcode/QrSegment.hpp \ src/3rdparty/qrcode/QrSegment.hpp \
src/3rdparty/json/json.hpp \
src/settings.h \ src/settings.h \
src/txtablemodel.h \ src/txtablemodel.h \
src/qrcodelabel.h \ src/qrcodelabel.h \

File diff suppressed because it is too large Load Diff

View File

@@ -59,15 +59,16 @@ void ChatDataStore::setPassword(QString password)
QString ChatDataStore::dump() QString ChatDataStore::dump()
{ {
json chats; QJsonObject chats;
chats["count"] = this->data.size(); chats["count"] = (qint64)this->data.size();
json j = {}; QJsonArray j;
for (auto &c: this->data) for (auto &c: this->data)
{ {
j.push_back(c.second.toJson()); j.push_back(c.second.toJson());
} }
chats["chatitems"] = j; chats["chatitems"] = j;
return QString::fromStdString(chats.dump()); QJsonDocument jd_chats = QJsonDocument(chats);
return QLatin1String(jd_chats.toJson(QJsonDocument::Compact));
} }
std::map<QString, ChatItem> ChatDataStore::getAllRawChatItems() std::map<QString, ChatItem> ChatDataStore::getAllRawChatItems()

View File

@@ -1,7 +1,6 @@
#ifndef CHATDATASTORE_H #ifndef CHATDATASTORE_H
#define CHATDATASTORE_H #define CHATDATASTORE_H
#include "../chatmodel.h" #include "../chatmodel.h"
using json = nlohmann::json;
class ChatDataStore class ChatDataStore
{ {

View File

@@ -33,9 +33,9 @@ ContactItem ContactDataStore::getData(QString key)
QString ContactDataStore::dump() QString ContactDataStore::dump()
{ {
json contacts; QJsonObject contacts;
contacts["count"] = this->data.size(); contacts["count"] = (qint64)this->data.size();
json j = {}; QJsonArray j = {};
for (auto &c: this->data) for (auto &c: this->data)
{ {
qDebug() << c.second.toQTString(); qDebug() << c.second.toQTString();
@@ -43,7 +43,10 @@ QString ContactDataStore::dump()
j.push_back(c.second.toJson()); j.push_back(c.second.toJson());
} }
contacts["contacts"] = j; contacts["contacts"] = j;
return QString::fromStdString(contacts.dump(4)); QJsonDocument jd_contacts = QJsonDocument(contacts);
return QLatin1String(jd_contacts.toJson(QJsonDocument::Compact));
// return QString::fromStdString(contacts.dump(4));
} }
ContactDataStore* ContactDataStore::instance = nullptr; ContactDataStore* ContactDataStore::instance = nullptr;

View File

@@ -2,7 +2,6 @@
#define CONTACTDATASTORE_H #define CONTACTDATASTORE_H
#include "../Model/ContactItem.h" #include "../Model/ContactItem.h"
#include <string> #include <string>
using json = nlohmann::json;
class ContactDataStore class ContactDataStore
{ {

View File

@@ -1,8 +1,6 @@
#ifndef SIETCHDATASTORE_H #ifndef SIETCHDATASTORE_H
#define SIETCHDATASTORE_H #define SIETCHDATASTORE_H
using json = nlohmann::json;
class SietchDataStore class SietchDataStore
{ {
private: private:

View File

@@ -8,7 +8,7 @@
#include "../Model/ContactItem.h" #include "../Model/ContactItem.h"
#include "../Crypto/FileEncryption.h" #include "../Crypto/FileEncryption.h"
#include <fstream> #include <fstream>
using json = nlohmann::json;
class FileSystem class FileSystem
{ {
private: private:

View File

@@ -184,17 +184,17 @@ QString ChatItem::toChatLine()
return line; return line;
} }
json ChatItem::toJson() QJsonValue ChatItem::toJson()
{ {
json j; QJsonObject j;
j["_timestamp"] = _timestamp; j["_timestamp"] = (qint64)_timestamp;
j["_address"] = _address.toStdString(); j["_address"] = _address;
j["_contact"] = _contact.toStdString(); j["_contact"] = _contact;
j["_memo"] = _memo.toStdString(); j["_memo"] = _memo;
j["_requestZaddr"] = _requestZaddr.toStdString(); j["_requestZaddr"] = _requestZaddr;
j["_type"] = _type.toStdString(); j["_type"] = _type;
j["_cid"] = _cid.toStdString(); j["_cid"] = _cid;
j["_txid"] = _txid.toStdString(); j["_txid"] = _txid;
j["_confirmations"] = _confirmations; j["_confirmations"] = _confirmations;
j["_outgoing"] = _outgoing; j["_outgoing"] = _outgoing;
return j; return j;

View File

@@ -5,7 +5,6 @@
#define CHATITEM_H #define CHATITEM_H
#include <QString> #include <QString>
using json = nlohmann::json;
class ChatItem class ChatItem
{ {
@@ -53,7 +52,7 @@ class ChatItem
void notarized(); void notarized();
void contact(bool iscontact); void contact(bool iscontact);
QString toChatLine(); QString toChatLine();
json toJson(); QJsonValue toJson();
~ChatItem(); ~ChatItem();
}; };

View File

@@ -86,13 +86,13 @@ QString ContactItem::toQTString()
return _name + "|" + _partnerAddress + "|" + _myAddress + "|" + _cid + "|" + _avatar; return _name + "|" + _partnerAddress + "|" + _myAddress + "|" + _cid + "|" + _avatar;
} }
json ContactItem::toJson() QJsonValue ContactItem::toJson()
{ {
json j; QJsonObject j;
j["_myAddress"] = _myAddress.toStdString(); j["_myAddress"] = _myAddress;
j["_partnerAddress"] = _partnerAddress.toStdString(); j["_partnerAddress"] = _partnerAddress;
j["_name"] = _name.toStdString(); j["_name"] = _name;
j["_cid"] = _cid.toStdString(); j["_cid"] = _cid;
j["_avatar"] = _avatar.toStdString(); j["_avatar"] = _avatar;
return j; return j;
} }

View File

@@ -6,7 +6,6 @@
#include <vector> #include <vector>
#include <QString> #include <QString>
#include "mainwindow.h" #include "mainwindow.h"
using json = nlohmann::json;
class ContactItem class ContactItem
{ {
@@ -34,7 +33,7 @@ public:
void setcid(QString cid); void setcid(QString cid);
void setAvatar(QString avatar); void setAvatar(QString avatar);
QString toQTString(); QString toQTString();
json toJson(); QJsonValue toJson();
}; };
#endif #endif

View File

@@ -5,7 +5,6 @@
#define CONTACTREQUEST_H #define CONTACTREQUEST_H
#include <QString> #include <QString>
using json = nlohmann::json;
class ContactRequest class ContactRequest
{ {

View File

@@ -153,8 +153,8 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
bool sapling = true; bool sapling = true;
try try
{ {
rpc->createNewZaddr(sapling, [=] (json reply) { rpc->createNewZaddr(sapling, [=] (QJsonValue reply) {
QString myAddr = QString::fromStdString(reply.get<json::array_t>()[0]); QString myAddr = reply.toArray()[0].toString();
QString message = QString("New Chat Address for your partner: ") + myAddr; QString message = QString("New Chat Address for your partner: ") + myAddr;
QString cid = QUuid::createUuid().toString(QUuid::WithoutBraces); QString cid = QUuid::createUuid().toString(QUuid::WithoutBraces);

View File

@@ -696,96 +696,84 @@ void::MainWindow::addContact()
request.setupUi(&dialog); request.setupUi(&dialog);
Settings::saveRestore(&dialog); Settings::saveRestore(&dialog);
try
try
{ {
bool sapling = true; bool sapling = true;
rpc->createNewZaddr(sapling, [=] (json reply) { rpc->createNewZaddr(sapling, [=] (QJsonValue reply) {
QString myAddr = QString::fromStdString(reply.get<json::array_t>()[0]); QString myAddr = reply.toArray()[0].toString();
rpc->refreshAddresses(); rpc->refreshAddresses();
request.myzaddr->setText(myAddr); request.myzaddr->setText(myAddr);
ui->listReceiveAddresses->insertItem(0, myAddr); ui->listReceiveAddresses->insertItem(0, myAddr);
ui->listReceiveAddresses->setCurrentIndex(0); ui->listReceiveAddresses->setCurrentIndex(0);
DataStore::getChatDataStore()->setSendZaddr(myAddr); DataStore::getChatDataStore()->setSendZaddr(myAddr);
qDebug()<<"Zaddr: "<<myAddr; qDebug()<<"Zaddr: "<<myAddr;
}); });
}
catch (...)
{
qDebug() << QString("Caught something nasty with myZaddr Contact");
}
}catch(...) QString cid = QUuid::createUuid().toString(QUuid::WithoutBraces);
{
QObject::connect(request.sendRequestButton, &QPushButton::clicked, this, &MainWindow::saveandsendContact);
qDebug() << QString("Caught something nasty with myZaddr Contact"); // QObject::connect(request.onlyAdd, &QPushButton::clicked, this, &MainWindow::saveContact);
}
QString cid = QUuid::createUuid().toString(QUuid::WithoutBraces);
QObject::connect(request.sendRequestButton, &QPushButton::clicked, this, &MainWindow::saveandsendContact);
// QObject::connect(request.onlyAdd, &QPushButton::clicked, this, &MainWindow::saveContact);
dialog.exec(); dialog.exec();
rpc->refreshContacts(ui->listContactWidget); rpc->refreshContacts(ui->listContactWidget);
} }
void MainWindow::saveandsendContact() void MainWindow::saveandsendContact()
{ {
this->ContactRequest(); this->ContactRequest();
} }
// Create a Tx for a contact Request // Create a Tx for a contact Request
Tx MainWindow::createTxForSafeContactRequest() Tx MainWindow::createTxForSafeContactRequest()
{ {
Tx tx; Tx tx;
{ {
CAmount totalAmt; CAmount totalAmt;
QString amtStr = "0"; QString amtStr = "0";
CAmount amt; CAmount amt;
QString headerbytes = ""; QString headerbytes = "";
amt = CAmount::fromDecimalString("0"); amt = CAmount::fromDecimalString("0");
totalAmt = totalAmt + amt; totalAmt = totalAmt + amt;
QString cid = contactRequest.getCid(); QString cid = contactRequest.getCid();
QString myAddr = DataStore::getChatDataStore()->getSendZaddr(); QString myAddr = DataStore::getChatDataStore()->getSendZaddr();
QString type = "Cont"; QString type = "Cont";
QString addr = contactRequest.getReceiverAddress(); QString addr = contactRequest.getReceiverAddress();
QString memo = contactRequest.getMemo(); QString memo = contactRequest.getMemo();
QString passphrase = DataStore::getChatDataStore()->getPassword(); QString passphrase = DataStore::getChatDataStore()->getPassword();
int length = passphrase.length(); int length = passphrase.length();
////////////////Generate the secretkey for our message encryption ////////////////Generate the secretkey for our message encryption
char *hashEncryptionKeyraw = NULL; char *hashEncryptionKeyraw = NULL;
hashEncryptionKeyraw = new char[length+1]; hashEncryptionKeyraw = new char[length+1];
strncpy(hashEncryptionKeyraw, passphrase.toUtf8(), length +1); strncpy(hashEncryptionKeyraw, passphrase.toUtf8(), length +1);
#define MESSAGEAS1 ((const unsigned char *) hashEncryptionKeyraw) #define MESSAGEAS1 ((const unsigned char *) hashEncryptionKeyraw)
#define MESSAGEAS1_LEN length #define MESSAGEAS1_LEN length
unsigned char sk[crypto_kx_SECRETKEYBYTES]; unsigned char sk[crypto_kx_SECRETKEYBYTES];
unsigned char pk[crypto_kx_PUBLICKEYBYTES]; unsigned char pk[crypto_kx_PUBLICKEYBYTES];
if (crypto_kx_seed_keypair(pk,sk, if (crypto_kx_seed_keypair(pk, sk, MESSAGEAS1) !=0) {
MESSAGEAS1) !=0) { //
} }
QString publicKey = QByteArray(reinterpret_cast<const char*>(pk), crypto_kx_PUBLICKEYBYTES).toHex(); QString publicKey = QByteArray(reinterpret_cast<const char*>(pk), crypto_kx_PUBLICKEYBYTES).toHex();
QString hmemo= createHeaderMemo(type,cid,myAddr,"", publicKey);
QString hmemo= createHeaderMemo(type,cid,myAddr,"", publicKey); tx.toAddrs.push_back(ToFields{addr, amt, hmemo});
tx.toAddrs.push_back(ToFields{addr, amt, memo});
tx.fee = Settings::getMinerFee();
tx.toAddrs.push_back(ToFields{addr, amt, hmemo}); }
tx.toAddrs.push_back(ToFields{addr, amt, memo});
tx.fee = Settings::getMinerFee();
}
return tx; return tx;
} }

View File

@@ -8,8 +8,6 @@
#include "../lib/silentdragonlitelib.h" #include "../lib/silentdragonlitelib.h"
#include "precompiled.h" #include "precompiled.h"
using json = nlohmann::json;
ConnectionLoader::ConnectionLoader(MainWindow* main, Controller* rpc) ConnectionLoader::ConnectionLoader(MainWindow* main, Controller* rpc)
{ {
this->main = main; this->main = main;
@@ -93,17 +91,17 @@ void ConnectionLoader::doAutoConnect()
auto me = this; auto me = this;
// After the lib is initialized, try to do get info // After the lib is initialized, try to do get info
connection->doRPC("info", "", [=](auto reply) { connection->doRPC("info", "", [=](QJsonValue reply) {
// If success, set the connection // If success, set the connection
main->logger->write("Connection is online."); main->logger->write("Connection is online.");
connection->setInfo(reply); connection->setInfo(reply);
isSyncing = new QAtomicInteger<bool>(); isSyncing = new QAtomicInteger<bool>();
isSyncing->store(true); isSyncing->storeRelaxed(true);
// Do a sync at startup // Do a sync at startup
syncTimer = new QTimer(main); syncTimer = new QTimer(main);
connection->doRPCWithDefaultErrorHandling("sync", "", [=](auto) { connection->doRPCWithDefaultErrorHandling("sync", "", [=](QJsonValue) {
isSyncing->store(false); isSyncing->storeRelaxed(false);
// Cancel the timer // Cancel the timer
syncTimer->deleteLater(); syncTimer->deleteLater();
// When sync is done, set the connection // When sync is done, set the connection
@@ -113,13 +111,13 @@ void ConnectionLoader::doAutoConnect()
// While it is syncing, we'll show the status updates while it is alive. // While it is syncing, we'll show the status updates while it is alive.
QObject::connect(syncTimer, &QTimer::timeout, [=]() { QObject::connect(syncTimer, &QTimer::timeout, [=]() {
// Check the sync status // Check the sync status
if (isSyncing != nullptr && isSyncing->load()) { if (isSyncing != nullptr && isSyncing->loadRelaxed()) {
// Get the sync status // Get the sync status
connection->doRPC("syncstatus", "", [=](json reply) { connection->doRPC("syncstatus", "", [=](QJsonValue reply) {
if (isSyncing != nullptr && reply.find("synced_blocks") != reply.end()) if (isSyncing != nullptr && !reply.toObject()["synced_blocks"].isUndefined())
{ {
qint64 synced = reply["synced_blocks"].get<json::number_unsigned_t>(); qint64 synced = reply["synced_blocks"].toInt();
qint64 total = reply["total_blocks"].get<json::number_unsigned_t>(); qint64 total = reply["total_blocks"].toInt();
me->showInformation( me->showInformation(
"Synced " + QString::number(synced) + " / " + QString::number(total) "Synced " + QString::number(synced) + " / " + QString::number(total)
); );
@@ -202,21 +200,26 @@ void Executor::run()
{ {
char* resp = litelib_execute(this->cmd.toStdString().c_str(), this->args.toStdString().c_str()); char* resp = litelib_execute(this->cmd.toStdString().c_str(), this->args.toStdString().c_str());
QString reply = litelib_process_response(resp); QString reply = litelib_process_response(resp);
//qDebug() << "RPC Reply=" << reply; QJsonDocument parsed = QJsonDocument::fromJson(reply.toUtf8());
auto parsed = json::parse(
reply.toStdString().c_str(), if (parsed.isEmpty() || parsed.isNull())
nullptr,
false
);
if (parsed.is_discarded() || parsed.is_null())
emit handleError(reply); emit handleError(reply);
else else
emit responseReady(parsed); {
QJsonValue retval;
if (parsed.isObject())
retval = QJsonValue(parsed.object());
else if (parsed.isArray())
retval = QJsonValue(parsed.array());
emit responseReady(retval);
}
} }
void Callback::processRPCCallback(json resp) void Callback::processRPCCallback(QJsonValue resp)
{ {
this->cb(resp); this->cb(resp);
// Destroy self // Destroy self
@@ -235,10 +238,10 @@ Connection::Connection(MainWindow* m, std::shared_ptr<ConnectionConfig> conf)
this->config = conf; this->config = conf;
this->main = m; this->main = m;
// 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<QJsonValue>("QJsonValue");
} }
void Connection::doRPC(const QString cmd, const QString args, const std::function<void(json)>& cb, const std::function<void(QString)>& errCb) void Connection::doRPC(const QString cmd, const QString args, const std::function<void(QJsonValue)>& cb, const std::function<void(QString)>& errCb)
{ {
if (shutdownInProgress) if (shutdownInProgress)
// Ignoring RPC because shutdown in progress // Ignoring RPC because shutdown in progress
@@ -257,14 +260,14 @@ void Connection::doRPC(const QString cmd, const QString args, const std::functio
QThreadPool::globalInstance()->start(runner); QThreadPool::globalInstance()->start(runner);
} }
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(QJsonValue)>& cb)
{ {
doRPC(cmd, args, cb, [=] (QString err) { doRPC(cmd, args, cb, [=] (QString err) {
this->showTxError(err); this->showTxError(err);
}); });
} }
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(QJsonValue)>& cb)
{ {
doRPC(cmd, args, cb, [=] (auto) { doRPC(cmd, args, cb, [=] (auto) {
// Ignored error handling // Ignored error handling

View File

@@ -6,8 +6,6 @@
#include "precompiled.h" #include "precompiled.h"
using json = nlohmann::json;
class Controller; class Controller;
struct ConnectionConfig { struct ConnectionConfig {
@@ -57,15 +55,15 @@ private:
class Callback: public QObject { class Callback: public QObject {
Q_OBJECT Q_OBJECT
public: public:
Callback(const std::function<void(json)> cb, const std::function<void(QString)> errCb) { this->cb = cb; this->errCb = errCb;} Callback(const std::function<void(QJsonValue)> cb, const std::function<void(QString)> errCb) { this->cb = cb; this->errCb = errCb;}
~Callback() = default; ~Callback() = default;
public slots: public slots:
void processRPCCallback(json resp); void processRPCCallback(QJsonValue resp);
void processError(QString error); void processError(QString error);
private: private:
std::function<void(json)> cb; std::function<void(QJsonValue)> cb;
std::function<void(QString)> errCb; std::function<void(QString)> errCb;
}; };
@@ -92,7 +90,7 @@ public:
virtual void run(); virtual void run();
signals: signals:
void responseReady(json); void responseReady(QJsonValue);
void handleError(QString); void handleError(QString);
private: private:
@@ -117,19 +115,19 @@ public:
void shutdown(); void shutdown();
void doRPC(const QString cmd, const QString args, const std::function<void(json)>& cb, void doRPC(const QString cmd, const QString args, const std::function<void(QJsonValue)>& cb,
const std::function<void(QString)>& errCb); const std::function<void(QString)>& errCb);
void doRPCWithDefaultErrorHandling(const QString cmd, const QString args, const std::function<void(json)>& cb); void doRPCWithDefaultErrorHandling(const QString cmd, const QString args, const std::function<void(QJsonValue)>& cb);
void doRPCIgnoreError(const QString cmd, const QString args, const std::function<void(json)>& cb) ; void doRPCIgnoreError(const QString cmd, const QString args, const std::function<void(QJsonValue)>& cb) ;
void showTxError(const QString& error); void showTxError(const QString& error);
json getInfo() { return serverInfo; } QJsonValue getInfo() { return serverInfo; }
void setInfo(const json& info) { serverInfo = info; } void setInfo(const QJsonValue& info) { serverInfo = info; }
private: private:
bool shutdownInProgress = false; bool shutdownInProgress = false;
json serverInfo; QJsonValue serverInfo;
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@@ -19,7 +19,6 @@
#include "Model/ContactRequestChatItem.h" #include "Model/ContactRequestChatItem.h"
#include "Model/ContactItem.h" #include "Model/ContactItem.h"
#include "contactmodel.h" #include "contactmodel.h"
using json = nlohmann::json;
struct WatchedTx { struct WatchedTx {
QString opid; QString opid;
@@ -91,7 +90,7 @@ public:
const std::function<void(QString txid)> submitted, const std::function<void(QString txid)> submitted,
const std::function<void(QString txid, QString errStr)> error); const std::function<void(QString txid, QString errStr)> error);
void fillTxJsonParams(json& params, Tx tx); void fillTxJsonParams(QJsonArray &params, Tx tx);
const TxTableModel* getTransactionsModel() { return transactionsTableModel; } const TxTableModel* getTransactionsModel() { return transactionsTableModel; }
@@ -99,58 +98,58 @@ public:
void noConnection(); void noConnection();
bool isEmbedded() { return ehushd != nullptr; } bool isEmbedded() { return ehushd != nullptr; }
void encryptWallet(QString password, const std::function<void(json)>& cb) { void encryptWallet(QString password, const std::function<void(QJsonValue)>& cb) {
zrpc->encryptWallet(password, cb); zrpc->encryptWallet(password, cb);
} }
void removeWalletEncryption(QString password, const std::function<void(json)>& cb) { void removeWalletEncryption(QString password, const std::function<void(QJsonValue)>& cb) {
zrpc->removeWalletEncryption(password, cb); } zrpc->removeWalletEncryption(password, cb); }
void saveWallet(const std::function<void(json)>& cb) { zrpc->saveWallet(cb); } void saveWallet(const std::function<void(QJsonValue)>& cb) { zrpc->saveWallet(cb); }
void clearWallet(const std::function<void(json)>& cb) { zrpc->clearWallet(cb); } void clearWallet(const std::function<void(QJsonValue)>& cb) { zrpc->clearWallet(cb); }
void createNewZaddr(bool sapling, const std::function<void(json)>& cb) { void createNewZaddr(bool sapling, const std::function<void(QJsonValue)>& cb) {
unlockIfEncrypted([=] () { unlockIfEncrypted([=] () {
zrpc->createNewZaddr(sapling, cb); zrpc->createNewZaddr(sapling, cb);
}, [=](){}); }, [=](){});
} }
void createNewTaddr(const std::function<void(json)>& cb) { void createNewTaddr(const std::function<void(QJsonValue)>& cb) {
unlockIfEncrypted([=] () { unlockIfEncrypted([=] () {
zrpc->createNewTaddr(cb); zrpc->createNewTaddr(cb);
}, [=](){}); }, [=](){});
} }
void createNewSietchZaddr(const std::function<void(json)>& cb) { void createNewSietchZaddr(const std::function<void(QJsonValue)>& cb) {
unlockIfEncrypted([=] () { unlockIfEncrypted([=] () {
zrpc->createNewSietchZaddr(cb); zrpc->createNewSietchZaddr(cb);
}, [=](){}); }, [=](){});
} }
void fetchPrivKey(QString addr, const std::function<void(json)>& cb) { void fetchPrivKey(QString addr, const std::function<void(QJsonValue)>& cb) {
unlockIfEncrypted([=] () { unlockIfEncrypted([=] () {
zrpc->fetchPrivKey(addr, cb); zrpc->fetchPrivKey(addr, cb);
}, },
[=]() { [=]() {
cb({ {"error", "Failed to unlock wallet"} }); cb(QJsonObject({ {"error", "Failed to unlock wallet"} }) );
}); });
} }
void fetchAllPrivKeys(const std::function<void(json)> cb) { void fetchAllPrivKeys(const std::function<void(QJsonValue)> cb) {
unlockIfEncrypted([=] () { unlockIfEncrypted([=] () {
zrpc->fetchAllPrivKeys(cb); zrpc->fetchAllPrivKeys(cb);
}, },
[=]() { [=]() {
cb({ {"error", "Failed to unlock wallet"} }); cb(QJsonObject({ {"error", "Failed to unlock wallet"} }));
}); });
} }
void fetchSeed(const std::function<void(json)> cb) { void fetchSeed(const std::function<void(QJsonValue)> cb) {
unlockIfEncrypted([=] () { unlockIfEncrypted([=] () {
zrpc->fetchSeed(cb); zrpc->fetchSeed(cb);
}, },
[=]() { [=]() {
cb({ {"error", "Failed to unlock wallet"} }); cb(QJsonObject({ {"error", "Failed to unlock wallet"} }));
}); });
} }
@@ -163,12 +162,12 @@ public:
private: private:
void processInfo(const json&); void processInfo(const QJsonValue&);
void refreshBalances(); void refreshBalances();
void refreshTransactions(); void refreshTransactions();
void processUnspent (const json& reply, QMap<QString, CAmount>* newBalances, QList<UnspentOutput>* newUnspentOutputs); void processUnspent (const QJsonValue& reply, QMap<QString, CAmount>* newBalances, QList<UnspentOutput>* newUnspentOutputs);
void updateUI (bool anyUnconfirmed); void updateUI (bool anyUnconfirmed);
void updateUIBalances (); void updateUIBalances ();

View File

@@ -8,7 +8,6 @@
#include "../lib/silentdragonlitelib.h" #include "../lib/silentdragonlitelib.h"
using json = nlohmann::json;
FirstTimeWizard::FirstTimeWizard(bool dangerous, QString server) FirstTimeWizard::FirstTimeWizard(bool dangerous, QString server)
{ {
@@ -173,14 +172,15 @@ void NewSeedPage::initializePage() {
char* resp = litelib_initialize_new(parent->dangerous, parent->server.toStdString().c_str()); char* resp = litelib_initialize_new(parent->dangerous, parent->server.toStdString().c_str());
QString reply = litelib_process_response(resp); QString reply = litelib_process_response(resp);
auto parsed = json::parse(reply.toStdString().c_str(), nullptr, false); QByteArray ba_reply = reply.toUtf8();
if (parsed.is_discarded() || parsed.is_null() || parsed.find("seed") == parsed.end()) { QJsonDocument jd_reply = QJsonDocument::fromJson(ba_reply);
QJsonObject parsed = jd_reply.object();
if (parsed.isEmpty() || parsed["seed"].isNull()) {
form.txtSeed->setPlainText(tr("Error creating a wallet") + "\n" + reply); form.txtSeed->setPlainText(tr("Error creating a wallet") + "\n" + reply);
} else { } else {
QString seed = QString::fromStdString(parsed["seed"].get<json::string_t>()); QString seed = parsed["seed"].toString();
form.txtSeed->setPlainText(seed); form.txtSeed->setPlainText(seed);
} }
@@ -192,8 +192,11 @@ bool NewSeedPage::validatePage() {
char* resp = litelib_execute("save", ""); char* resp = litelib_execute("save", "");
QString reply = litelib_process_response(resp); QString reply = litelib_process_response(resp);
auto parsed = json::parse(reply.toStdString().c_str(), nullptr, false); QByteArray ba_reply = reply.toUtf8();
if (parsed.is_discarded() || parsed.is_null() || parsed.find("result") == parsed.end()) { QJsonDocument jd_reply = QJsonDocument::fromJson(ba_reply);
QJsonObject parsed = jd_reply.object();
if (parsed.isEmpty() || parsed["result"].isNull()) {
QMessageBox::warning(this, tr("Failed to save wallet"), QMessageBox::warning(this, tr("Failed to save wallet"),
tr("Couldn't save the wallet") + "\n" + reply, tr("Couldn't save the wallet") + "\n" + reply,
QMessageBox::Ok); QMessageBox::Ok);
@@ -258,8 +261,11 @@ bool RestoreSeedPage::validatePage() {
char* resp = litelib_execute("save", ""); char* resp = litelib_execute("save", "");
QString reply = litelib_process_response(resp); QString reply = litelib_process_response(resp);
auto parsed = json::parse(reply.toStdString().c_str(), nullptr, false); QByteArray ba_reply = reply.toUtf8();
if (parsed.is_discarded() || parsed.is_null() || parsed.find("result") == parsed.end()) { QJsonDocument jd_reply = QJsonDocument::fromJson(ba_reply);
QJsonObject parsed = jd_reply.object();
if (parsed.isEmpty() || parsed["result"].isNull()) {
QMessageBox::warning(this, tr("Failed to save wallet"), QMessageBox::warning(this, tr("Failed to save wallet"),
tr("Couldn't save the wallet") + "\n" + reply, tr("Couldn't save the wallet") + "\n" + reply,
QMessageBox::Ok); QMessageBox::Ok);

View File

@@ -20,7 +20,7 @@ bool LiteInterface::haveConnection() {
return conn != nullptr; return conn != nullptr;
} }
void LiteInterface::fetchAddresses(const std::function<void(json)>& cb) { void LiteInterface::fetchAddresses(const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
@@ -28,21 +28,21 @@ void LiteInterface::fetchAddresses(const std::function<void(json)>& cb) {
} }
void LiteInterface::fetchUnspent(const std::function<void(json)>& cb) { void LiteInterface::fetchUnspent(const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
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(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
conn->doRPCWithDefaultErrorHandling("new", "zs", cb); conn->doRPCWithDefaultErrorHandling("new", "zs", cb);
} }
void LiteInterface::createNewSietchZaddr(const std::function<void(json)>& cb) { void LiteInterface::createNewSietchZaddr(const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
@@ -50,70 +50,70 @@ void LiteInterface::createNewSietchZaddr(const std::function<void(json)>& cb) {
} }
void LiteInterface::createNewTaddr(const std::function<void(json)>& cb) { void LiteInterface::createNewTaddr(const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
conn->doRPCWithDefaultErrorHandling("new", "R", cb); conn->doRPCWithDefaultErrorHandling("new", "R", cb);
} }
void LiteInterface::fetchPrivKey(QString addr, const std::function<void(json)>& cb) { void LiteInterface::fetchPrivKey(QString addr, const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
conn->doRPCWithDefaultErrorHandling("export", addr, cb); conn->doRPCWithDefaultErrorHandling("export", addr, cb);
} }
void LiteInterface::fetchSeed(const std::function<void(json)>& cb) { void LiteInterface::fetchSeed(const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
conn->doRPCWithDefaultErrorHandling("seed", "", cb); conn->doRPCWithDefaultErrorHandling("seed", "", cb);
} }
void LiteInterface::fetchBalance(const std::function<void(json)>& cb) { void LiteInterface::fetchBalance(const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
conn->doRPCWithDefaultErrorHandling("balance", "", cb); conn->doRPCWithDefaultErrorHandling("balance", "", cb);
} }
void LiteInterface::fetchTransactions(const std::function<void(json)>& cb) { void LiteInterface::fetchTransactions(const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
conn->doRPCWithDefaultErrorHandling("list", "", cb); conn->doRPCWithDefaultErrorHandling("list", "", cb);
} }
void LiteInterface::saveWallet(const std::function<void(json)>& cb) { void LiteInterface::saveWallet(const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
conn->doRPCWithDefaultErrorHandling("save", "", cb); conn->doRPCWithDefaultErrorHandling("save", "", cb);
} }
void LiteInterface::clearWallet(const std::function<void(json)>& cb) { void LiteInterface::clearWallet(const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
conn->doRPCWithDefaultErrorHandling("clear", "", cb); conn->doRPCWithDefaultErrorHandling("clear", "", cb);
} }
void LiteInterface::unlockWallet(QString password, const std::function<void(json)>& cb) { void LiteInterface::unlockWallet(QString password, const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
conn->doRPCWithDefaultErrorHandling("unlock", password, cb); conn->doRPCWithDefaultErrorHandling("unlock", password, cb);
} }
void LiteInterface::fetchWalletEncryptionStatus(const std::function<void(json)>& cb) { void LiteInterface::fetchWalletEncryptionStatus(const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
conn->doRPCWithDefaultErrorHandling("encryptionstatus", "", cb); conn->doRPCWithDefaultErrorHandling("encryptionstatus", "", cb);
} }
void LiteInterface::encryptWallet(QString password, const std::function<void(json)>& cb) { void LiteInterface::encryptWallet(QString password, const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
@@ -121,7 +121,7 @@ void LiteInterface::encryptWallet(QString password, const std::function<void(jso
} }
void LiteInterface::removeWalletEncryption(QString password, const std::function<void(json)>& cb) { void LiteInterface::removeWalletEncryption(QString password, const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
@@ -129,7 +129,7 @@ void LiteInterface::removeWalletEncryption(QString password, const std::function
} }
void LiteInterface::sendTransaction(QString params, const std::function<void(json)>& cb, void LiteInterface::sendTransaction(QString params, const std::function<void(QJsonValue)>& cb,
const std::function<void(QString)>& err) { const std::function<void(QString)>& err) {
if (conn == nullptr) if (conn == nullptr)
return; return;
@@ -137,7 +137,7 @@ void LiteInterface::sendTransaction(QString params, const std::function<void(jso
conn->doRPC("send", params, cb, err); conn->doRPC("send", params, cb, err);
} }
void LiteInterface::fetchInfo(const std::function<void(json)>& cb, void LiteInterface::fetchInfo(const std::function<void(QJsonValue)>& cb,
const std::function<void(QString)>& err) { const std::function<void(QString)>& err) {
if (conn == nullptr) if (conn == nullptr)
return; return;
@@ -145,7 +145,7 @@ void LiteInterface::fetchInfo(const std::function<void(json)>& cb,
conn->doRPC("info", "", cb, err); conn->doRPC("info", "", cb, err);
} }
void LiteInterface::fetchSupply(const std::function<void(json)>& cb) { void LiteInterface::fetchSupply(const std::function<void(QJsonValue)>& cb) {
if (conn == nullptr) if (conn == nullptr)
return; return;
@@ -153,7 +153,7 @@ void LiteInterface::fetchSupply(const std::function<void(json)>& cb) {
} }
void LiteInterface::fetchLatestBlock(const std::function<void(json)>& cb, void LiteInterface::fetchLatestBlock(const std::function<void(QJsonValue)>& cb,
const std::function<void(QString)>& err) { const std::function<void(QString)>& err) {
if (conn == nullptr) if (conn == nullptr)
return; return;
@@ -166,7 +166,7 @@ void LiteInterface::fetchLatestBlock(const std::function<void(json)>& cb,
* combine the result, and call the callback with a single list containing both the t-addr and z-addr * combine the result, and call the callback with a single list containing both the t-addr and z-addr
* private keys * private keys
*/ */
void LiteInterface::fetchAllPrivKeys(const std::function<void(json)> cb) { void LiteInterface::fetchAllPrivKeys(const std::function<void(QJsonValue)> cb) {
if (conn == nullptr) { if (conn == nullptr) {
// No connection, just return // No connection, just return
return; return;

View File

@@ -6,8 +6,6 @@
#include "camount.h" #include "camount.h"
#include "connection.h" #include "connection.h"
using json = nlohmann::json;
// Since each transaction can contain multiple outputs, we separate them out individually // Since each transaction can contain multiple outputs, we separate them out individually
// into a struct with address, amount, memo // into a struct with address, amount, memo
struct TransactionItemDetail { struct TransactionItemDetail {
@@ -38,43 +36,43 @@ public:
void setConnection(Connection* c); void setConnection(Connection* c);
Connection* getConnection() { return conn; } Connection* getConnection() { return conn; }
void fetchUnspent (const std::function<void(json)>& cb); void fetchUnspent (const std::function<void(QJsonValue)>& cb);
void fetchTransactions (const std::function<void(json)>& cb); void fetchTransactions (const std::function<void(QJsonValue)>& cb);
void fetchAddresses (const std::function<void(json)>& cb); void fetchAddresses (const std::function<void(QJsonValue)>& cb);
void fetchInfo(const std::function<void(json)>& cb, void fetchInfo(const std::function<void(QJsonValue)>& cb,
const std::function<void(QString)>& err); const std::function<void(QString)>& err);
void fetchLatestBlock(const std::function<void(json)>& cb, void fetchLatestBlock(const std::function<void(QJsonValue)>& cb,
const std::function<void(QString)>& err); const std::function<void(QString)>& err);
void fetchBalance(const std::function<void(json)>& cb); void fetchBalance(const std::function<void(QJsonValue)>& cb);
void createNewZaddr(bool sapling, const std::function<void(json)>& cb); void createNewZaddr(bool sapling, const std::function<void(QJsonValue)>& cb);
void createNewTaddr(const std::function<void(json)>& cb); void createNewTaddr(const std::function<void(QJsonValue)>& cb);
void createNewSietchZaddr(const std::function<void(json)>& cb); void createNewSietchZaddr(const std::function<void(QJsonValue)>& cb);
void fetchPrivKey(QString addr, const std::function<void(json)>& cb); void fetchPrivKey(QString addr, const std::function<void(QJsonValue)>& cb);
void fetchAllPrivKeys(const std::function<void(json)>); void fetchAllPrivKeys(const std::function<void(QJsonValue)>);
void fetchSeed(const std::function<void(json)>&); void fetchSeed(const std::function<void(QJsonValue)>&);
void saveWallet(const std::function<void(json)>& cb); void saveWallet(const std::function<void(QJsonValue)>& cb);
void clearWallet(const std::function<void(json)>& cb); void clearWallet(const std::function<void(QJsonValue)>& cb);
void fetchWalletEncryptionStatus(const std::function<void(json)>& cb); void fetchWalletEncryptionStatus(const std::function<void(QJsonValue)>& cb);
void fetchSupply(const std::function<void(json)>& cb); void fetchSupply(const std::function<void(QJsonValue)>& cb);
void encryptWallet(QString password, const std::function<void(json)>& cb); void encryptWallet(QString password, const std::function<void(QJsonValue)>& cb);
void unlockWallet(QString password, const std::function<void(json)>& cb); void unlockWallet(QString password, const std::function<void(QJsonValue)>& cb);
void removeWalletEncryption(QString password, const std::function<void(json)>& cb); void removeWalletEncryption(QString password, const std::function<void(QJsonValue)>& cb);
//void importZPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb); //void importZPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb);
//void importTPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb); //void importTPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb);
void sendTransaction(QString params, const std::function<void(json)>& cb, const std::function<void(QString)>& err); void sendTransaction(QString params, const std::function<void(QJsonValue)>& cb, const std::function<void(QString)>& err);
private: private:
Connection* conn = nullptr; Connection* conn = nullptr;

View File

@@ -35,9 +35,6 @@
#include "firsttimewizard.h" #include "firsttimewizard.h"
#include "../lib/silentdragonlitelib.h" #include "../lib/silentdragonlitelib.h"
using json = nlohmann::json;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
auto dirwallet = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite/silentdragonlite-wallet.dat"); auto dirwallet = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite/silentdragonlite-wallet.dat");
@@ -989,7 +986,7 @@ void MainWindow::exportSeed() {
rpc->fetchSeed([=](json reply) { rpc->fetchSeed([=](QJsonValue reply) {
if (isJsonError(reply)) { if (isJsonError(reply)) {
return; return;
} }
@@ -1007,7 +1004,7 @@ void MainWindow::exportSeed() {
pui.privKeyTxt->setReadOnly(true); pui.privKeyTxt->setReadOnly(true);
pui.privKeyTxt->setLineWrapMode(QPlainTextEdit::LineWrapMode::NoWrap); pui.privKeyTxt->setLineWrapMode(QPlainTextEdit::LineWrapMode::NoWrap);
pui.privKeyTxt->setPlainText(QString::fromStdString(reply.dump())); pui.privKeyTxt->setPlainText(QLatin1String(QJsonDocument(reply.toObject()).toJson(QJsonDocument::Compact)));
pui.helpLbl->setText(tr("This is your wallet seed. Please back it up carefully and safely.")); pui.helpLbl->setText(tr("This is your wallet seed. Please back it up carefully and safely."));
@@ -1061,14 +1058,14 @@ void MainWindow::exportKeys(QString addr) {
bool allKeys = addr.isEmpty() ? true : false; bool allKeys = addr.isEmpty() ? true : false;
auto fnUpdateUIWithKeys = [=](json reply) { auto fnUpdateUIWithKeys = [=](QJsonValue reply) {
if (isJsonError(reply)) { if (isJsonError(reply)) {
return; return;
} }
if (reply.is_discarded() || !reply.is_array()) { if (reply.isNull() || !reply.isArray()) {
QMessageBox::critical(this, tr("Error getting private keys"), QMessageBox::critical(this, tr("Error getting private keys"),
tr("Error loading private keys: ") + QString::fromStdString(reply.dump()), tr("Error loading private keys: ") + QLatin1String(QJsonDocument(reply.toObject()).toJson(QJsonDocument::Compact)),
QMessageBox::Ok); QMessageBox::Ok);
return; return;
} }
@@ -1107,8 +1104,8 @@ void MainWindow::exportKeys(QString addr) {
}); });
QString allKeysTxt; QString allKeysTxt;
for (auto i : reply.get<json::array_t>()) { for (auto i : reply.toArray()) {
allKeysTxt = allKeysTxt % QString::fromStdString(i["private_key"]) % " # addr=" % QString::fromStdString(i["address"]) % "\n"; allKeysTxt = allKeysTxt % i.toObject()["private_key"].toString() % " # addr=" % i.toObject()["address"].toString() % "\n";
} }
pui.privKeyTxt->setPlainText(allKeysTxt); pui.privKeyTxt->setPlainText(allKeysTxt);
@@ -1565,8 +1562,8 @@ void MainWindow::updateContacts()
} }
void MainWindow::addNewZaddr(bool sapling) { void MainWindow::addNewZaddr(bool sapling) {
rpc->createNewZaddr(sapling, [=] (json reply) { rpc->createNewZaddr(sapling, [=] (QJsonValue reply) {
QString addr = QString::fromStdString(reply.get<json::array_t>()[0]); QString addr = reply.toArray()[0].toString();
// Make sure the RPC class reloads the z-addrs for future use // Make sure the RPC class reloads the z-addrs for future use
rpc->refreshAddresses(); rpc->refreshAddresses();
@@ -1616,8 +1613,8 @@ std::function<void(bool)> MainWindow::addZAddrsToComboList(bool sapling) {
void MainWindow::setupReceiveTab() { void MainWindow::setupReceiveTab() {
auto addNewTAddr = [=] () { auto addNewTAddr = [=] () {
rpc->createNewTaddr([=] (json reply) { rpc->createNewTaddr([=] (QJsonValue reply) {
QString addr = QString::fromStdString(reply.get<json::array_t>()[0]); QString addr = reply.toArray()[0].toString();
// Make sure the RPC class reloads the t-addrs for future use // Make sure the RPC class reloads the t-addrs for future use
rpc->refreshAddresses(); rpc->refreshAddresses();
@@ -1992,8 +1989,8 @@ void MainWindow::on_givemeZaddr_clicked()
{ {
bool sapling = true; bool sapling = true;
rpc->createNewZaddr(sapling, [=] (json reply) { rpc->createNewZaddr(sapling, [=] (QJsonValue reply) {
QString hushchataddr = QString::fromStdString(reply.get<json::array_t>()[0]); QString hushchataddr = reply.toArray()[0].toString();
QClipboard *zaddr_Clipboard = QApplication::clipboard(); QClipboard *zaddr_Clipboard = QApplication::clipboard();
zaddr_Clipboard ->setText(hushchataddr); zaddr_Clipboard ->setText(hushchataddr);
QMessageBox::information(this, "Your new HushChat address was copied to your clipboard!",hushchataddr); QMessageBox::information(this, "Your new HushChat address was copied to your clipboard!",hushchataddr);

View File

@@ -14,7 +14,6 @@ class WSServer;
class WormholeClient; class WormholeClient;
class ChatModel; class ChatModel;
using json = nlohmann::json;
// Struct used to hold destination info when sending a Tx. // Struct used to hold destination info when sending a Tx.
struct ToFields { struct ToFields {

View File

@@ -71,8 +71,8 @@
#include <QObject> #include <QObject>
#include <QApplication> #include <QApplication>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QPainterPath>
#include "3rdparty/json/json.hpp"
#include "3rdparty/qrcode/QrCode.hpp" #include "3rdparty/qrcode/QrCode.hpp"
#define SODIUM_STATIC #define SODIUM_STATIC

View File

@@ -9,8 +9,6 @@
#include "recurring.h" #include "recurring.h"
using json = nlohmann::json;
void MainWindow::setupSendTab() { void MainWindow::setupSendTab() {
// Create the validator for send to/amount fields // Create the validator for send to/amount fields
amtValidator = new QRegExpValidator(QRegExp("[0-9]{0,8}\\.?[0-9]{0,8}")); amtValidator = new QRegExpValidator(QRegExp("[0-9]{0,8}\\.?[0-9]{0,8}"));

View File

@@ -4,8 +4,6 @@
#include "precompiled.h" #include "precompiled.h"
#include "camount.h" #include "camount.h"
using json = nlohmann::json;
struct Config { struct Config {
QString server; QString server;
}; };
@@ -67,8 +65,6 @@ public:
void set_currency_name(QString currency_name); void set_currency_name(QString currency_name);
bool isSaplingActive(); bool isSaplingActive();
void setZECPrice(double p) { ZECPrice = p; } void setZECPrice(double p) { ZECPrice = p; }
@@ -225,13 +221,12 @@ private:
}; };
inline bool isJsonResultSuccess(const json& res) { inline bool isJsonResultSuccess(const QJsonValue& res) {
return res.find("result") != res.end() && return res.toObject()["result"].toString() == "success";
QString::fromStdString(res["result"].get<json::string_t>()) == "success";
} }
inline bool isJsonError(const json& res) { inline bool isJsonError(const QJsonValue& res) {
return res.find("error") != res.end(); return !res.toObject()["error"].isNull();
} }

View File

@@ -735,9 +735,9 @@ void AppDataServer::processSendTx(QJsonObject sendTx, MainWindow* mainwindow, st
return; return;
} }
json params = json::array(); QJsonArray params;
mainwindow->getRPC()->fillTxJsonParams(params, tx); mainwindow->getRPC()->fillTxJsonParams(params, tx);
std::cout << std::setw(2) << params << std::endl; //std::cout << std::setw(2) << params << std::endl;
// And send the Tx // And send the Tx
mainwindow->getRPC()->executeTransaction(tx, mainwindow->getRPC()->executeTransaction(tx,
@@ -835,9 +835,9 @@ void AppDataServer::processSendManyTx(QJsonObject sendmanyTx, MainWindow* mainwi
return; return;
} }
json params = json::array(); QJsonArray params;
mainwindow->getRPC()->fillTxJsonParams(params, tx); mainwindow->getRPC()->fillTxJsonParams(params, tx);
std::cout << std::setw(2) << params << std::endl; //std::cout << std::setw(2) << params << std::endl;
// And send the Tx // And send the Tx
mainwindow->getRPC()->executeTransaction(tx, mainwindow->getRPC()->executeTransaction(tx,