From 00ea5d6be958159ba3cecb058b56bc4e23fc571d Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Tue, 8 Nov 2016 16:33:36 +0100 Subject: added Wallet::createTransactionAsync() --- src/libwalletqt/Wallet.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/libwalletqt/Wallet.cpp') diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index d281c03a..8ec8c663 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace { static const int DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS = 10; @@ -211,10 +212,29 @@ PendingTransaction *Wallet::createTransaction(const QString &dst_addr, const QSt Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createTransaction( dst_addr.toStdString(), payment_id.toStdString(), amount, mixin_count, static_cast(priority)); - PendingTransaction * result = new PendingTransaction(ptImpl, this); + PendingTransaction * result = new PendingTransaction(ptImpl, m_walletManager); return result; } + +void Wallet::createTransactionAsync(const QString &dst_addr, const QString &payment_id, + quint64 amount, quint32 mixin_count, + PendingTransaction::Priority priority) +{ + QFuture future = QtConcurrent::run(this, &Wallet::createTransaction, + dst_addr, payment_id,amount, mixin_count, priority); + QFutureWatcher * watcher = new QFutureWatcher(); + watcher->setFuture(future); + connect(watcher, &QFutureWatcher::finished, + this, [this, watcher]() { + QFuture future = watcher->future(); + watcher->deleteLater(); + emit transactionCreated(future.result()); + }); +} + + + void Wallet::disposeTransaction(PendingTransaction *t) { m_walletImpl->disposeTransaction(t->m_pimpl); @@ -287,6 +307,7 @@ Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent) { m_history = new TransactionHistory(m_walletImpl->history(), this); m_walletImpl->setListener(new WalletListenerImpl(this)); + m_walletManager = parent; } Wallet::~Wallet() -- cgit v1.2.3 From 62060e183c634ab557a028a6e083d15f6f5a06d2 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Tue, 8 Nov 2016 18:02:07 +0100 Subject: wallet::createTransactionAsync pass variables to listener --- src/libwalletqt/Wallet.cpp | 4 ++-- src/libwalletqt/Wallet.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libwalletqt/Wallet.cpp') diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 8ec8c663..9eb1aae1 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -226,10 +226,10 @@ void Wallet::createTransactionAsync(const QString &dst_addr, const QString &paym QFutureWatcher * watcher = new QFutureWatcher(); watcher->setFuture(future); connect(watcher, &QFutureWatcher::finished, - this, [this, watcher]() { + this, [this, watcher,dst_addr,payment_id,mixin_count]() { QFuture future = watcher->future(); watcher->deleteLater(); - emit transactionCreated(future.result()); + emit transactionCreated(future.result(),dst_addr,payment_id,mixin_count); }); } diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index a50a895f..e9eb71d7 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -171,7 +171,7 @@ signals: void historyModelChanged() const; // emitted when transaction is created async - void transactionCreated(PendingTransaction * transaction); + void transactionCreated(PendingTransaction * transaction, QString address, QString paymentId, quint32 mixinCount); private: Wallet(QObject * parent = nullptr); -- cgit v1.2.3 From 66692be7cf048a89c0c36af2c36de09be6fa3698 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Tue, 8 Nov 2016 19:48:41 +0100 Subject: createTransactionAsync(): removed reference to WalletManager --- src/libwalletqt/Wallet.cpp | 3 +-- src/libwalletqt/Wallet.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src/libwalletqt/Wallet.cpp') diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 9eb1aae1..552b3b8d 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -212,7 +212,7 @@ PendingTransaction *Wallet::createTransaction(const QString &dst_addr, const QSt Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createTransaction( dst_addr.toStdString(), payment_id.toStdString(), amount, mixin_count, static_cast(priority)); - PendingTransaction * result = new PendingTransaction(ptImpl, m_walletManager); + PendingTransaction * result = new PendingTransaction(ptImpl,0); return result; } @@ -307,7 +307,6 @@ Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent) { m_history = new TransactionHistory(m_walletImpl->history(), this); m_walletImpl->setListener(new WalletListenerImpl(this)); - m_walletManager = parent; } Wallet::~Wallet() diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index e9eb71d7..02cd80bb 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -194,7 +194,6 @@ private: mutable QTime m_daemonBlockChainTargetHeightTime; mutable quint64 m_daemonBlockChainTargetHeight; int m_daemonBlockChainTargetHeightTtl; - QObject * m_walletManager; }; -- cgit v1.2.3