Wallet: estimateTransactionFeeAsync - multi dest support

This commit is contained in:
xiphon 2021-02-04 11:32:30 +00:00
parent c1573c2c2a
commit b20b956e15
3 changed files with 32 additions and 16 deletions

View file

@ -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);

View file

@ -626,17 +626,32 @@ void Wallet::disposeTransaction(UnsignedTransaction *t)
delete t;
}
void Wallet::estimateTransactionFeeAsync(const QString &destination,
quint64 amount,
void Wallet::estimateTransactionFeeAsync(
const QVector<QString> &destinationAddresses,
const QVector<quint64> &amounts,
PendingTransaction::Priority priority,
const QJSValue &callback)
{
m_scheduler.run([this, destination, amount, priority] {
m_scheduler.run(
[this, destinationAddresses, amounts, priority] {
if (destinationAddresses.size() != amounts.size())
{
return QJSValueList({""});
}
std::vector<std::pair<std::string, uint64_t>> 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(
{std::make_pair(destination.toStdString(), amount)},
destinations,
static_cast<Monero::PendingTransaction::Priority>(priority));
return QJSValueList({QString::fromStdString(Monero::Wallet::displayAmount(fee))});
}, callback);
},
callback);
}
TransactionHistory *Wallet::history() const

View file

@ -255,8 +255,9 @@ public:
//! deletes unsigned transaction and frees memory
Q_INVOKABLE void disposeTransaction(UnsignedTransaction * t);
Q_INVOKABLE void estimateTransactionFeeAsync(const QString &destination,
quint64 amount,
Q_INVOKABLE void estimateTransactionFeeAsync(
const QVector<QString> &destinationAddresses,
const QVector<quint64> &amounts,
PendingTransaction::Priority priority,
const QJSValue &callback);