Make the new sweep functions use async transactions

This commit is contained in:
moneromooo.monero 2016-11-11 21:54:17 +00:00
parent c779b376fc
commit 111248f410
3 changed files with 47 additions and 3 deletions

View File

@ -386,6 +386,14 @@ ApplicationWindow {
// deleting transaction object, we don't want memleaks // deleting transaction object, we don't want memleaks
currentWallet.disposeTransaction(transaction); currentWallet.disposeTransaction(transaction);
} else if (transaction.txCount == 0) {
informationPopup.title = qsTr("No unmixable outputs to sweep") + translationManager.emptyString
informationPopup.text = qsTr("No unmixable outputs to sweep") + translationManager.emptyString
informationPopup.icon = StandardIcon.Information
informationPopup.onCloseCallback = null
informationPopup.open()
// deleting transaction object, we don't want memleaks
currentWallet.disposeTransaction(transaction);
} else { } else {
console.log("Transaction created, amount: " + walletManager.displayAmount(transaction.amount) console.log("Transaction created, amount: " + walletManager.displayAmount(transaction.amount)
+ ", fee: " + walletManager.displayAmount(transaction.fee)); + ", fee: " + walletManager.displayAmount(transaction.fee));
@ -394,13 +402,13 @@ ApplicationWindow {
transactionConfirmationPopup.title = qsTr("Confirmation") + translationManager.emptyString transactionConfirmationPopup.title = qsTr("Confirmation") + translationManager.emptyString
transactionConfirmationPopup.text = qsTr("Please confirm transaction:\n") transactionConfirmationPopup.text = qsTr("Please confirm transaction:\n")
+ qsTr("\nAddress: ") + address + (address === "" ? "" : (qsTr("\nAddress: ") + address))
+ qsTr("\nPayment ID: ") + paymentId + (paymentId === "" ? "" : (qsTr("\nPayment ID: ") + paymentId))
+ qsTr("\n\nAmount: ") + walletManager.displayAmount(transaction.amount) + qsTr("\n\nAmount: ") + walletManager.displayAmount(transaction.amount)
+ qsTr("\nFee: ") + walletManager.displayAmount(transaction.fee) + qsTr("\nFee: ") + walletManager.displayAmount(transaction.fee)
+ qsTr("\n\nMixin: ") + mixinCount + qsTr("\n\nMixin: ") + mixinCount
+ qsTr("\n\Number of transactions: ") + transaction.txCount + qsTr("\n\Number of transactions: ") + transaction.txCount
+ qsTr("\n\nDescription: ") + transactionDescription + (transactionDescription === "" ? "" : (qsTr("\n\nDescription: ") + transactionDescription))
+ translationManager.emptyString + translationManager.emptyString
transactionConfirmationPopup.icon = StandardIcon.Question transactionConfirmationPopup.icon = StandardIcon.Question
transactionConfirmationPopup.open() transactionConfirmationPopup.open()

View File

@ -242,6 +242,22 @@ PendingTransaction *Wallet::createTransactionAll(const QString &dst_addr, const
return result; return result;
} }
void Wallet::createTransactionAllAsync(const QString &dst_addr, const QString &payment_id,
quint32 mixin_count,
PendingTransaction::Priority priority)
{
QFuture<PendingTransaction*> future = QtConcurrent::run(this, &Wallet::createTransactionAll,
dst_addr, payment_id, mixin_count, priority);
QFutureWatcher<PendingTransaction*> * watcher = new QFutureWatcher<PendingTransaction*>();
watcher->setFuture(future);
connect(watcher, &QFutureWatcher<PendingTransaction*>::finished,
this, [this, watcher,dst_addr,payment_id,mixin_count]() {
QFuture<PendingTransaction*> future = watcher->future();
watcher->deleteLater();
emit transactionCreated(future.result(),dst_addr,payment_id,mixin_count);
});
}
PendingTransaction *Wallet::createSweepUnmixableTransaction() PendingTransaction *Wallet::createSweepUnmixableTransaction()
{ {
Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createSweepUnmixableTransaction(); Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createSweepUnmixableTransaction();
@ -249,6 +265,19 @@ PendingTransaction *Wallet::createSweepUnmixableTransaction()
return result; return result;
} }
void Wallet::createSweepUnmixableTransactionAsync()
{
QFuture<PendingTransaction*> future = QtConcurrent::run(this, &Wallet::createSweepUnmixableTransaction);
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(),"","",0);
});
}
void Wallet::disposeTransaction(PendingTransaction *t) void Wallet::disposeTransaction(PendingTransaction *t)
{ {
m_walletImpl->disposeTransaction(t->m_pimpl); m_walletImpl->disposeTransaction(t->m_pimpl);

View File

@ -136,9 +136,16 @@ public:
Q_INVOKABLE PendingTransaction * createTransactionAll(const QString &dst_addr, const QString &payment_id, Q_INVOKABLE PendingTransaction * createTransactionAll(const QString &dst_addr, const QString &payment_id,
quint32 mixin_count, PendingTransaction::Priority priority); quint32 mixin_count, PendingTransaction::Priority priority);
//! creates async transaction with all outputs
Q_INVOKABLE void createTransactionAllAsync(const QString &dst_addr, const QString &payment_id,
quint32 mixin_count, PendingTransaction::Priority priority);
//! creates sweep unmixable transaction //! creates sweep unmixable transaction
Q_INVOKABLE PendingTransaction * createSweepUnmixableTransaction(); Q_INVOKABLE PendingTransaction * createSweepUnmixableTransaction();
//! creates async sweep unmixable transaction
Q_INVOKABLE void createSweepUnmixableTransactionAsync();
//! deletes transaction and frees memory //! deletes transaction and frees memory
Q_INVOKABLE void disposeTransaction(PendingTransaction * t); Q_INVOKABLE void disposeTransaction(PendingTransaction * t);