aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/api
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2020-03-31 15:12:48 -0500
committerluigi1111 <luigi1111w@gmail.com>2020-03-31 15:12:48 -0500
commitd0065f3063c365ac9a65a655f145382408033c4f (patch)
tree160d7bcf555df0ecba8ee925bbdb5e1ba4ace964 /src/wallet/api
parentMerge pull request #6301 (diff)
parentwallet2_api: implement estimateTransactionFee (diff)
downloadmonero-d0065f3063c365ac9a65a655f145382408033c4f.tar.xz
Merge pull request #6302
dab604e wallet2_api: implement estimateTransactionFee (xiphon)
Diffstat (limited to 'src/wallet/api')
-rw-r--r--src/wallet/api/wallet.cpp20
-rw-r--r--src/wallet/api/wallet.h2
-rw-r--r--src/wallet/api/wallet2_api.h8
3 files changed, 30 insertions, 0 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 6200c7a1f..33047f703 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -1671,6 +1671,26 @@ void WalletImpl::disposeTransaction(PendingTransaction *t)
delete t;
}
+uint64_t WalletImpl::estimateTransactionFee(const std::vector<std::pair<std::string, uint64_t>> &destinations,
+ PendingTransaction::Priority priority) const
+{
+ const size_t pubkey_size = 33;
+ const size_t encrypted_paymentid_size = 11;
+ const size_t extra_size = pubkey_size + encrypted_paymentid_size;
+
+ return m_wallet->estimate_fee(
+ m_wallet->use_fork_rules(HF_VERSION_PER_BYTE_FEE, 0),
+ m_wallet->use_fork_rules(4, 0),
+ 1,
+ m_wallet->get_min_ring_size() - 1,
+ destinations.size() + 1,
+ extra_size,
+ m_wallet->use_fork_rules(8, 0),
+ m_wallet->get_base_fee(),
+ m_wallet->get_fee_multiplier(m_wallet->adjust_priority(static_cast<uint32_t>(priority))),
+ m_wallet->get_fee_quantization_mask());
+}
+
TransactionHistory *WalletImpl::history()
{
return m_history.get();
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index 331bf4b38..e46a62340 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -166,6 +166,8 @@ public:
bool importKeyImages(const std::string &filename) override;
virtual void disposeTransaction(PendingTransaction * t) override;
+ virtual uint64_t estimateTransactionFee(const std::vector<std::pair<std::string, uint64_t>> &destinations,
+ PendingTransaction::Priority priority) const override;
virtual TransactionHistory * history() override;
virtual AddressBook * addressBook() override;
virtual Subaddress * subaddress() override;
diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h
index e543a115b..3945e55c9 100644
--- a/src/wallet/api/wallet2_api.h
+++ b/src/wallet/api/wallet2_api.h
@@ -879,6 +879,14 @@ struct Wallet
*/
virtual void disposeTransaction(PendingTransaction * t) = 0;
+ /*!
+ * \brief Estimates transaction fee.
+ * \param destinations Vector consisting of <address, amount> pairs.
+ * \return Estimated fee.
+ */
+ virtual uint64_t estimateTransactionFee(const std::vector<std::pair<std::string, uint64_t>> &destinations,
+ PendingTransaction::Priority priority) const = 0;
+
/*!
* \brief exportKeyImages - exports key images to file
* \param filename