diff options
| author | Jacob Brydolf <jacob@brydolf.net> | 2016-11-08 16:33:36 +0100 |
|---|---|---|
| committer | Jacob Brydolf <jacob@brydolf.net> | 2016-11-10 16:11:58 +0100 |
| commit | 00ea5d6be958159ba3cecb058b56bc4e23fc571d (patch) | |
| tree | 79ce8d7f52dd0e33c609a72e3e92b5445056e621 /src/libwalletqt/Wallet.cpp | |
| parent | 68736ab834533db50cb5eaebf9a751ad0f2fa5a6 (diff) | |
| download | monzero-gui-00ea5d6be958159ba3cecb058b56bc4e23fc571d.tar.gz monzero-gui-00ea5d6be958159ba3cecb058b56bc4e23fc571d.tar.xz monzero-gui-00ea5d6be958159ba3cecb058b56bc4e23fc571d.zip | |
added Wallet::createTransactionAsync()
Diffstat (limited to 'src/libwalletqt/Wallet.cpp')
| -rw-r--r-- | src/libwalletqt/Wallet.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
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 <QDebug> #include <QUrl> #include <QTimer> +#include <QtConcurrent/QtConcurrent> 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<Bitmonero::PendingTransaction::Priority>(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<PendingTransaction*> future = QtConcurrent::run(this, &Wallet::createTransaction, + dst_addr, payment_id,amount, mixin_count, priority); + QFutureWatcher<PendingTransaction*> * watcher = new QFutureWatcher<PendingTransaction*>(); + watcher->setFuture(future); + connect(watcher, &QFutureWatcher<PendingTransaction*>::finished, + this, [this, watcher]() { + QFuture<PendingTransaction*> 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() |
