diff --git a/pages/Transfer.qml b/pages/Transfer.qml index 828d7b5d..9a4d8b18 100644 --- a/pages/Transfer.qml +++ b/pages/Transfer.qml @@ -361,8 +361,8 @@ Rectangle { return; } currentWallet.estimateTransactionFeeAsync( - addressLine.text, - walletManager.amountFromString(amountLine.text), + [addressLine.text], + [walletManager.amountFromString(amountLine.text)], priorityModelV5.get(priorityDropdown.currentIndex).priority, function (amount) { estimatedFee = Utils.removeTrailingZeros(amount); diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index ae0f2367..e9700143 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -641,17 +641,32 @@ void Wallet::disposeTransaction(UnsignedTransaction *t) delete t; } -void Wallet::estimateTransactionFeeAsync(const QString &destination, - quint64 amount, - PendingTransaction::Priority priority, - const QJSValue &callback) +void Wallet::estimateTransactionFeeAsync( + const QVector &destinationAddresses, + const QVector &amounts, + PendingTransaction::Priority priority, + const QJSValue &callback) { - m_scheduler.run([this, destination, amount, priority] { - const uint64_t fee = m_walletImpl->estimateTransactionFee( - {std::make_pair(destination.toStdString(), amount)}, - static_cast(priority)); - return QJSValueList({QString::fromStdString(Monero::Wallet::displayAmount(fee))}); - }, callback); + m_scheduler.run( + [this, destinationAddresses, amounts, priority] { + if (destinationAddresses.size() != amounts.size()) + { + return QJSValueList({""}); + } + + std::vector> destinations; + destinations.reserve(destinationAddresses.size()); + for (size_t index = 0; index < destinationAddresses.size(); ++index) + { + destinations.emplace_back(std::make_pair(destinationAddresses[index].toStdString(), amounts[index])); + } + + const uint64_t fee = m_walletImpl->estimateTransactionFee( + destinations, + static_cast(priority)); + return QJSValueList({QString::fromStdString(Monero::Wallet::displayAmount(fee))}); + }, + callback); } TransactionHistory *Wallet::history() const diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index 98a47f92..237ef853 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -253,10 +253,11 @@ public: //! deletes unsigned transaction and frees memory Q_INVOKABLE void disposeTransaction(UnsignedTransaction * t); - Q_INVOKABLE void estimateTransactionFeeAsync(const QString &destination, - quint64 amount, - PendingTransaction::Priority priority, - const QJSValue &callback); + Q_INVOKABLE void estimateTransactionFeeAsync( + const QVector &destinationAddresses, + const QVector &amounts, + PendingTransaction::Priority priority, + const QJSValue &callback); //! returns transaction history TransactionHistory * history() const;