mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 17:32:33 +00:00
Merge pull request #6302
dab604e
wallet2_api: implement estimateTransactionFee (xiphon)
This commit is contained in:
commit
d0065f3063
5 changed files with 45 additions and 14 deletions
|
@ -1671,6 +1671,26 @@ void WalletImpl::disposeTransaction(PendingTransaction *t)
|
||||||
delete 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()
|
TransactionHistory *WalletImpl::history()
|
||||||
{
|
{
|
||||||
return m_history.get();
|
return m_history.get();
|
||||||
|
|
|
@ -166,6 +166,8 @@ public:
|
||||||
bool importKeyImages(const std::string &filename) override;
|
bool importKeyImages(const std::string &filename) override;
|
||||||
|
|
||||||
virtual void disposeTransaction(PendingTransaction * t) 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 TransactionHistory * history() override;
|
||||||
virtual AddressBook * addressBook() override;
|
virtual AddressBook * addressBook() override;
|
||||||
virtual Subaddress * subaddress() override;
|
virtual Subaddress * subaddress() override;
|
||||||
|
|
|
@ -879,6 +879,14 @@ struct Wallet
|
||||||
*/
|
*/
|
||||||
virtual void disposeTransaction(PendingTransaction * t) = 0;
|
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
|
* \brief exportKeyImages - exports key images to file
|
||||||
* \param filename
|
* \param filename
|
||||||
|
|
|
@ -896,20 +896,6 @@ uint8_t get_bulletproof_fork()
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t estimate_fee(bool use_per_byte_fee, bool use_rct, int n_inputs, int mixin, int n_outputs, size_t extra_size, bool bulletproof, uint64_t base_fee, uint64_t fee_multiplier, uint64_t fee_quantization_mask)
|
|
||||||
{
|
|
||||||
if (use_per_byte_fee)
|
|
||||||
{
|
|
||||||
const size_t estimated_tx_weight = estimate_tx_weight(use_rct, n_inputs, mixin, n_outputs, extra_size, bulletproof);
|
|
||||||
return calculate_fee_from_weight(base_fee, estimated_tx_weight, fee_multiplier, fee_quantization_mask);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const size_t estimated_tx_size = estimate_tx_size(use_rct, n_inputs, mixin, n_outputs, extra_size, bulletproof);
|
|
||||||
return calculate_fee(base_fee, estimated_tx_size, fee_multiplier);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t calculate_fee(bool use_per_byte_fee, const cryptonote::transaction &tx, size_t blob_size, uint64_t base_fee, uint64_t fee_multiplier, uint64_t fee_quantization_mask)
|
uint64_t calculate_fee(bool use_per_byte_fee, const cryptonote::transaction &tx, size_t blob_size, uint64_t base_fee, uint64_t fee_multiplier, uint64_t fee_quantization_mask)
|
||||||
{
|
{
|
||||||
if (use_per_byte_fee)
|
if (use_per_byte_fee)
|
||||||
|
@ -7157,6 +7143,20 @@ bool wallet2::sign_multisig_tx_from_file(const std::string &filename, std::vecto
|
||||||
return sign_multisig_tx_to_file(exported_txs, filename, txids);
|
return sign_multisig_tx_to_file(exported_txs, filename, txids);
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
uint64_t wallet2::estimate_fee(bool use_per_byte_fee, bool use_rct, int n_inputs, int mixin, int n_outputs, size_t extra_size, bool bulletproof, uint64_t base_fee, uint64_t fee_multiplier, uint64_t fee_quantization_mask) const
|
||||||
|
{
|
||||||
|
if (use_per_byte_fee)
|
||||||
|
{
|
||||||
|
const size_t estimated_tx_weight = estimate_tx_weight(use_rct, n_inputs, mixin, n_outputs, extra_size, bulletproof);
|
||||||
|
return calculate_fee_from_weight(base_fee, estimated_tx_weight, fee_multiplier, fee_quantization_mask);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const size_t estimated_tx_size = estimate_tx_size(use_rct, n_inputs, mixin, n_outputs, extra_size, bulletproof);
|
||||||
|
return calculate_fee(base_fee, estimated_tx_size, fee_multiplier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t wallet2::get_fee_multiplier(uint32_t priority, int fee_algorithm)
|
uint64_t wallet2::get_fee_multiplier(uint32_t priority, int fee_algorithm)
|
||||||
{
|
{
|
||||||
static const struct
|
static const struct
|
||||||
|
|
|
@ -1246,6 +1246,7 @@ private:
|
||||||
std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(const std::vector<std::pair<double, double>> &fee_levels);
|
std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(const std::vector<std::pair<double, double>> &fee_levels);
|
||||||
std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(uint64_t min_tx_weight, uint64_t max_tx_weight, const std::vector<uint64_t> &fees);
|
std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(uint64_t min_tx_weight, uint64_t max_tx_weight, const std::vector<uint64_t> &fees);
|
||||||
|
|
||||||
|
uint64_t estimate_fee(bool use_per_byte_fee, bool use_rct, int n_inputs, int mixin, int n_outputs, size_t extra_size, bool bulletproof, uint64_t base_fee, uint64_t fee_multiplier, uint64_t fee_quantization_mask) const;
|
||||||
uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1);
|
uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1);
|
||||||
uint64_t get_base_fee();
|
uint64_t get_base_fee();
|
||||||
uint64_t get_fee_quantization_mask();
|
uint64_t get_fee_quantization_mask();
|
||||||
|
|
Loading…
Reference in a new issue