mirror of
https://github.com/monero-project/monero-gui
synced 2024-12-01 08:11:54 +01:00
get_tx_key, get_tx_proof, tx_spend_proof async
This commit is contained in:
parent
8d49ad9ba4
commit
6d03d63c88
18
main.qml
18
main.qml
@ -1003,11 +1003,21 @@ ApplicationWindow {
|
|||||||
", address: ", address,
|
", address: ", address,
|
||||||
", message: ", message);
|
", message: ", message);
|
||||||
|
|
||||||
var result;
|
function spendProofFallback(txid, result){
|
||||||
|
if (!result || result.indexOf("error|") === 0) {
|
||||||
|
currentWallet.getSpendProofAsync(txid, message, txProofComputed);
|
||||||
|
} else {
|
||||||
|
txProofComputed(txid, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (address.length > 0)
|
if (address.length > 0)
|
||||||
result = currentWallet.getTxProof(txid, address, message);
|
currentWallet.getTxProofAsync(txid, address, message, spendProofFallback);
|
||||||
if (!result || result.indexOf("error|") === 0)
|
else
|
||||||
result = currentWallet.getSpendProof(txid, message);
|
spendProofFallback(txid, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function txProofComputed(txid, result){
|
||||||
informationPopup.title = qsTr("Payment proof") + translationManager.emptyString;
|
informationPopup.title = qsTr("Payment proof") + translationManager.emptyString;
|
||||||
if (result.indexOf("error|") === 0) {
|
if (result.indexOf("error|") === 0) {
|
||||||
var errorString = result.split("|")[1];
|
var errorString = result.split("|")[1];
|
||||||
|
@ -1576,16 +1576,16 @@ Rectangle {
|
|||||||
|
|
||||||
function getTxKey(hash, elem){
|
function getTxKey(hash, elem){
|
||||||
if (elem.parent.state != 'ready'){
|
if (elem.parent.state != 'ready'){
|
||||||
var txKey = currentWallet.getTxKey(hash)
|
currentWallet.getTxKeyAsync(hash, function(hash, txKey) {
|
||||||
elem.parent.text = txKey ? txKey : '-';
|
elem.parent.text = txKey ? txKey : '-';
|
||||||
elem.parent.state = 'ready';
|
elem.parent.state = 'ready';
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toClipboard(elem.parent.text);
|
toClipboard(elem.parent.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showTxDetails(hash, paymentId, destinations, subaddrAccount, subaddrIndex){
|
function showTxDetails(hash, paymentId, destinations, subaddrAccount, subaddrIndex){
|
||||||
var tx_key = currentWallet.getTxKey(hash)
|
|
||||||
var tx_note = currentWallet.getUserNote(hash)
|
var tx_note = currentWallet.getUserNote(hash)
|
||||||
var rings = currentWallet.getRings(hash)
|
var rings = currentWallet.getRings(hash)
|
||||||
var address_label = subaddrIndex == 0 ? (qsTr("Primary address") + translationManager.emptyString) : currentWallet.getSubaddressLabel(subaddrAccount, subaddrIndex)
|
var address_label = subaddrIndex == 0 ? (qsTr("Primary address") + translationManager.emptyString) : currentWallet.getSubaddressLabel(subaddrAccount, subaddrIndex)
|
||||||
@ -1593,10 +1593,12 @@ Rectangle {
|
|||||||
if (rings)
|
if (rings)
|
||||||
rings = rings.replace(/\|/g, '\n')
|
rings = rings.replace(/\|/g, '\n')
|
||||||
|
|
||||||
|
currentWallet.getTxKeyAsync(hash, function(hash, tx_key) {
|
||||||
informationPopup.title = qsTr("Transaction details") + translationManager.emptyString;
|
informationPopup.title = qsTr("Transaction details") + translationManager.emptyString;
|
||||||
informationPopup.content = buildTxDetailsString(hash, paymentId, tx_key, tx_note, destinations, rings, address, address_label);
|
informationPopup.content = buildTxDetailsString(hash, paymentId, tx_key, tx_note, destinations, rings, address, address_label);
|
||||||
informationPopup.onCloseCallback = null
|
informationPopup.onCloseCallback = null
|
||||||
informationPopup.open();
|
informationPopup.open();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showTxProof(hash, paymentId, destinations, subaddrAccount, subaddrIndex){
|
function showTxProof(hash, paymentId, destinations, subaddrAccount, subaddrIndex){
|
||||||
|
@ -662,6 +662,25 @@ QString Wallet::getTxKey(const QString &txid) const
|
|||||||
return QString::fromStdString(m_walletImpl->getTxKey(txid.toStdString()));
|
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)
|
QString Wallet::checkTxKey(const QString &txid, const QString &tx_key, const QString &address)
|
||||||
{
|
{
|
||||||
uint64_t received;
|
uint64_t received;
|
||||||
@ -680,6 +699,25 @@ QString Wallet::getTxProof(const QString &txid, const QString &address, const QS
|
|||||||
return QString::fromStdString(result);
|
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)
|
QString Wallet::checkTxProof(const QString &txid, const QString &address, const QString &message, const QString &signature)
|
||||||
{
|
{
|
||||||
bool good;
|
bool good;
|
||||||
@ -699,6 +737,25 @@ Q_INVOKABLE QString Wallet::getSpendProof(const QString &txid, const QString &me
|
|||||||
return QString::fromStdString(result);
|
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
|
Q_INVOKABLE QString Wallet::checkSpendProof(const QString &txid, const QString &message, const QString &signature) const
|
||||||
{
|
{
|
||||||
bool good;
|
bool good;
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QJSValue>
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
#include "wallet/api/wallet2_api.h" // we need to have an access to the Monero::Wallet::Status enum here;
|
#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 ¬e);
|
Q_INVOKABLE bool setUserNote(const QString &txid, const QString ¬e);
|
||||||
Q_INVOKABLE QString getUserNote(const QString &txid) const;
|
Q_INVOKABLE QString getUserNote(const QString &txid) const;
|
||||||
Q_INVOKABLE QString getTxKey(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 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 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 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 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;
|
Q_INVOKABLE QString checkSpendProof(const QString &txid, const QString &message, const QString &signature) const;
|
||||||
// Rescan spent outputs
|
// Rescan spent outputs
|
||||||
Q_INVOKABLE bool rescanSpent();
|
Q_INVOKABLE bool rescanSpent();
|
||||||
|
Loading…
Reference in New Issue
Block a user