aboutsummaryrefslogtreecommitdiff
path: root/src/libwalletqt
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2019-06-21 14:39:20 -0500
committerluigi1111 <luigi1111w@gmail.com>2019-06-21 14:39:20 -0500
commitf6a797fcb5548b5074582d2a5e9fcc67b4a0977d (patch)
tree05d478822e01cca8d8599915b3f7ec3e15652dc4 /src/libwalletqt
parent934ca28e2c64e94a5b02986e3f6408cfd87f3e21 (diff)
parent6d03d63c88af2e8ee0c52f77836bd3c018f55fe4 (diff)
downloadmonzero-gui-f6a797fcb5548b5074582d2a5e9fcc67b4a0977d.tar.gz
monzero-gui-f6a797fcb5548b5074582d2a5e9fcc67b4a0977d.tar.xz
monzero-gui-f6a797fcb5548b5074582d2a5e9fcc67b4a0977d.zip
Merge pull request #2220
8d49ad9 tx_key not displayed by default, click to reveal (ph4r05) 6d03d63 get_tx_key, get_tx_proof, tx_spend_proof async (ph4r05)
Diffstat (limited to 'src/libwalletqt')
-rw-r--r--src/libwalletqt/Wallet.cpp57
-rw-r--r--src/libwalletqt/Wallet.h4
2 files changed, 61 insertions, 0 deletions
diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp
index 629106da..ff0ada14 100644
--- a/src/libwalletqt/Wallet.cpp
+++ b/src/libwalletqt/Wallet.cpp
@@ -662,6 +662,25 @@ QString Wallet::getTxKey(const QString &txid) const
return QString::fromStdString(m_walletImpl->getTxKey(txid.toStdString()));
}
+void Wallet::getTxKeyAsync(const QString &txid, const QJSValue &ref)
+{
+ QFuture<QString> future = QtConcurrent::run(this, &Wallet::getTxKey, txid);
+ auto watcher = new QFutureWatcher<QString>(this);
+
+ connect(watcher, &QFutureWatcher<QString>::finished,
+ this, [watcher, txid, ref]() {
+ QFuture<QString> future = watcher->future();
+ watcher->deleteLater();
+
+ auto txKey = future.result();
+ if (ref.isCallable()){
+ QJSValue cb(ref);
+ cb.call(QJSValueList {txid, txKey});
+ }
+ });
+ watcher->setFuture(future);
+}
+
QString Wallet::checkTxKey(const QString &txid, const QString &tx_key, const QString &address)
{
uint64_t received;
@@ -680,6 +699,25 @@ QString Wallet::getTxProof(const QString &txid, const QString &address, const QS
return QString::fromStdString(result);
}
+void Wallet::getTxProofAsync(const QString &txid, const QString &address, const QString &message, const QJSValue &ref)
+{
+ QFuture<QString> future = QtConcurrent::run(this, &Wallet::getTxProof, txid, address, message);
+ auto watcher = new QFutureWatcher<QString>(this);
+
+ connect(watcher, &QFutureWatcher<QString>::finished,
+ this, [watcher, txid, ref]() {
+ QFuture<QString> future = watcher->future();
+ watcher->deleteLater();
+
+ auto proof = future.result();
+ if (ref.isCallable()){
+ QJSValue cb(ref);
+ cb.call(QJSValueList {txid, proof});
+ }
+ });
+ watcher->setFuture(future);
+}
+
QString Wallet::checkTxProof(const QString &txid, const QString &address, const QString &message, const QString &signature)
{
bool good;
@@ -699,6 +737,25 @@ Q_INVOKABLE QString Wallet::getSpendProof(const QString &txid, const QString &me
return QString::fromStdString(result);
}
+void Wallet::getSpendProofAsync(const QString &txid, const QString &message, const QJSValue &ref)
+{
+ QFuture<QString> future = QtConcurrent::run(this, &Wallet::getSpendProof, txid, message);
+ auto watcher = new QFutureWatcher<QString>(this);
+
+ connect(watcher, &QFutureWatcher<QString>::finished,
+ this, [watcher, txid, ref]() {
+ QFuture<QString> future = watcher->future();
+ watcher->deleteLater();
+
+ auto proof = future.result();
+ if (ref.isCallable()){
+ QJSValue cb(ref);
+ cb.call(QJSValueList {txid, proof});
+ }
+ });
+ watcher->setFuture(future);
+}
+
Q_INVOKABLE QString Wallet::checkSpendProof(const QString &txid, const QString &message, const QString &signature) const
{
bool good;
diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h
index ba12d1de..f3726e91 100644
--- a/src/libwalletqt/Wallet.h
+++ b/src/libwalletqt/Wallet.h
@@ -33,6 +33,7 @@
#include <QTime>
#include <QMutex>
#include <QList>
+#include <QJSValue>
#include <QtConcurrent/QtConcurrent>
#include "wallet/api/wallet2_api.h" // we need to have an access to the Monero::Wallet::Status enum here;
@@ -289,10 +290,13 @@ public:
Q_INVOKABLE bool setUserNote(const QString &txid, const QString &note);
Q_INVOKABLE QString getUserNote(const QString &txid) const;
Q_INVOKABLE QString getTxKey(const QString &txid) const;
+ Q_INVOKABLE void getTxKeyAsync(const QString &txid, const QJSValue &ref);
Q_INVOKABLE QString checkTxKey(const QString &txid, const QString &tx_key, const QString &address);
Q_INVOKABLE QString getTxProof(const QString &txid, const QString &address, const QString &message) const;
+ Q_INVOKABLE void getTxProofAsync(const QString &txid, const QString &address, const QString &message, const QJSValue &ref);
Q_INVOKABLE QString checkTxProof(const QString &txid, const QString &address, const QString &message, const QString &signature);
Q_INVOKABLE QString getSpendProof(const QString &txid, const QString &message) const;
+ Q_INVOKABLE void getSpendProofAsync(const QString &txid, const QString &message, const QJSValue &ref);
Q_INVOKABLE QString checkSpendProof(const QString &txid, const QString &message, const QString &signature) const;
// Rescan spent outputs
Q_INVOKABLE bool rescanSpent();