wallet: use the dynamic per kB fee
This commit is contained in:
parent
e6deb8abda
commit
18f66f44ef
2 changed files with 42 additions and 4 deletions
|
@ -80,6 +80,8 @@ using namespace cryptonote;
|
||||||
#define RECENT_OUTPUT_RATIO (0.25) // 25% of outputs are from the recent zone
|
#define RECENT_OUTPUT_RATIO (0.25) // 25% of outputs are from the recent zone
|
||||||
#define RECENT_OUTPUT_ZONE (5 * 86400) // last 5 days are the recent zone
|
#define RECENT_OUTPUT_ZONE (5 * 86400) // last 5 days are the recent zone
|
||||||
|
|
||||||
|
#define FEE_ESTIMATE_GRACE_BLOCKS 10 // estimate fee valid for that many blocks
|
||||||
|
|
||||||
#define KILL_IOSERVICE() \
|
#define KILL_IOSERVICE() \
|
||||||
do { \
|
do { \
|
||||||
work.reset(); \
|
work.reset(); \
|
||||||
|
@ -2733,6 +2735,40 @@ uint64_t wallet2::get_fee_multiplier(uint32_t priority, bool use_new_fee) const
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
uint64_t wallet2::get_dynamic_per_kb_fee_estimate()
|
||||||
|
{
|
||||||
|
epee::json_rpc::request<cryptonote::COMMAND_RPC_GET_PER_KB_FEE_ESTIMATE::request> req_t = AUTO_VAL_INIT(req_t);
|
||||||
|
epee::json_rpc::response<cryptonote::COMMAND_RPC_GET_PER_KB_FEE_ESTIMATE::response, std::string> resp_t = AUTO_VAL_INIT(resp_t);
|
||||||
|
|
||||||
|
m_daemon_rpc_mutex.lock();
|
||||||
|
req_t.jsonrpc = "2.0";
|
||||||
|
req_t.id = epee::serialization::storage_entry(0);
|
||||||
|
req_t.method = "get_fee_estimate";
|
||||||
|
req_t.params.grace_blocks = FEE_ESTIMATE_GRACE_BLOCKS;
|
||||||
|
bool r = net_utils::invoke_http_json_remote_command2(m_daemon_address + "/json_rpc", req_t, resp_t, m_http_client);
|
||||||
|
m_daemon_rpc_mutex.unlock();
|
||||||
|
CHECK_AND_ASSERT_THROW_MES(r, "Failed to connect to daemon");
|
||||||
|
CHECK_AND_ASSERT_THROW_MES(resp_t.result.status != CORE_RPC_STATUS_BUSY, "Failed to connect to daemon");
|
||||||
|
CHECK_AND_ASSERT_THROW_MES(resp_t.result.status == CORE_RPC_STATUS_OK, "Failed to get fee estimate");
|
||||||
|
return resp_t.result.fee;
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
uint64_t wallet2::get_per_kb_fee()
|
||||||
|
{
|
||||||
|
bool use_dyn_fee = use_fork_rules(HF_VERSION_DYNAMIC_FEE, -720 * 14);
|
||||||
|
if (!use_dyn_fee)
|
||||||
|
return FEE_PER_KB;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return get_dynamic_per_kb_fee_estimate();
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
LOG_PRINT_L1("Failed to query per kB fee, using " << print_money(FEE_PER_KB));
|
||||||
|
return FEE_PER_KB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
// separated the call(s) to wallet2::transfer into their own function
|
// separated the call(s) to wallet2::transfer into their own function
|
||||||
//
|
//
|
||||||
// this function will make multiple calls to wallet2::transfer if multiple
|
// this function will make multiple calls to wallet2::transfer if multiple
|
||||||
|
@ -2742,7 +2778,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions(std::vector<crypto
|
||||||
const std::vector<size_t> unused_transfers_indices = select_available_outputs_from_histogram(fake_outs_count + 1, true, true, trusted_daemon);
|
const std::vector<size_t> unused_transfers_indices = select_available_outputs_from_histogram(fake_outs_count + 1, true, true, trusted_daemon);
|
||||||
|
|
||||||
const bool use_new_fee = use_fork_rules(3, -720 * 14);
|
const bool use_new_fee = use_fork_rules(3, -720 * 14);
|
||||||
const uint64_t fee_per_kb = use_new_fee ? FEE_PER_KB : FEE_PER_KB_OLD;
|
const uint64_t fee_per_kb = get_per_kb_fee();
|
||||||
const uint64_t fee_multiplier = get_fee_multiplier(priority, use_new_fee);
|
const uint64_t fee_multiplier = get_fee_multiplier(priority, use_new_fee);
|
||||||
|
|
||||||
// failsafe split attempt counter
|
// failsafe split attempt counter
|
||||||
|
@ -3463,7 +3499,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
||||||
const bool use_rct = use_fork_rules(4, 0);
|
const bool use_rct = use_fork_rules(4, 0);
|
||||||
|
|
||||||
const bool use_new_fee = use_fork_rules(3, -720 * 14);
|
const bool use_new_fee = use_fork_rules(3, -720 * 14);
|
||||||
const uint64_t fee_per_kb = use_new_fee ? FEE_PER_KB : FEE_PER_KB_OLD;
|
const uint64_t fee_per_kb = get_per_kb_fee();
|
||||||
const uint64_t fee_multiplier = get_fee_multiplier(priority, use_new_fee);
|
const uint64_t fee_multiplier = get_fee_multiplier(priority, use_new_fee);
|
||||||
|
|
||||||
// throw if attempting a transaction with no destinations
|
// throw if attempting a transaction with no destinations
|
||||||
|
@ -3745,7 +3781,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_from(const crypton
|
||||||
|
|
||||||
const bool use_rct = fake_outs_count > 0 && use_fork_rules(4, 0);
|
const bool use_rct = fake_outs_count > 0 && use_fork_rules(4, 0);
|
||||||
const bool use_new_fee = use_fork_rules(3, -720 * 14);
|
const bool use_new_fee = use_fork_rules(3, -720 * 14);
|
||||||
const uint64_t fee_per_kb = use_new_fee ? FEE_PER_KB : FEE_PER_KB_OLD;
|
const uint64_t fee_per_kb = get_per_kb_fee();
|
||||||
const uint64_t fee_multiplier = get_fee_multiplier(priority, use_new_fee);
|
const uint64_t fee_multiplier = get_fee_multiplier(priority, use_new_fee);
|
||||||
|
|
||||||
LOG_PRINT_L2("Starting with " << unused_transfers_indices.size() << " non-dust outputs and " << unused_dust_indices.size() << " dust outputs");
|
LOG_PRINT_L2("Starting with " << unused_transfers_indices.size() << " non-dust outputs and " << unused_dust_indices.size() << " dust outputs");
|
||||||
|
@ -4051,7 +4087,7 @@ std::vector<wallet2::pending_tx> wallet2::create_unmixable_sweep_transactions(bo
|
||||||
tx_dust_policy dust_policy(hf1_rules ? 0 : ::config::DEFAULT_DUST_THRESHOLD);
|
tx_dust_policy dust_policy(hf1_rules ? 0 : ::config::DEFAULT_DUST_THRESHOLD);
|
||||||
|
|
||||||
const bool use_new_fee = use_fork_rules(3, -720 * 14);
|
const bool use_new_fee = use_fork_rules(3, -720 * 14);
|
||||||
const uint64_t fee_per_kb = use_new_fee ? FEE_PER_KB : FEE_PER_KB_OLD;
|
const uint64_t fee_per_kb = get_per_kb_fee();
|
||||||
|
|
||||||
// may throw
|
// may throw
|
||||||
std::vector<size_t> unmixable_outputs = select_available_unmixable_outputs(trusted_daemon);
|
std::vector<size_t> unmixable_outputs = select_available_unmixable_outputs(trusted_daemon);
|
||||||
|
|
|
@ -517,6 +517,8 @@ namespace tools
|
||||||
uint64_t get_upper_tranaction_size_limit();
|
uint64_t get_upper_tranaction_size_limit();
|
||||||
std::vector<uint64_t> get_unspent_amounts_vector();
|
std::vector<uint64_t> get_unspent_amounts_vector();
|
||||||
uint64_t get_fee_multiplier(uint32_t priority, bool use_new_fee) const;
|
uint64_t get_fee_multiplier(uint32_t priority, bool use_new_fee) const;
|
||||||
|
uint64_t get_dynamic_per_kb_fee_estimate();
|
||||||
|
uint64_t get_per_kb_fee();
|
||||||
float get_output_relatedness(const transfer_details &td0, const transfer_details &td1) const;
|
float get_output_relatedness(const transfer_details &td0, const transfer_details &td1) const;
|
||||||
std::vector<size_t> pick_prefered_rct_inputs(uint64_t needed_money) const;
|
std::vector<size_t> pick_prefered_rct_inputs(uint64_t needed_money) const;
|
||||||
void set_spent(size_t idx, uint64_t height);
|
void set_spent(size_t idx, uint64_t height);
|
||||||
|
|
Loading…
Reference in a new issue