Merge pull request #1079
9c7b0cb
wallet: change priority/fee to ArticMine's recommendation (moneromooo-monero)
This commit is contained in:
commit
0edcbf6716
|
@ -502,10 +502,10 @@ bool simple_wallet::set_default_mixin(const std::vector<std::string> &args/* = s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool simple_wallet::set_default_fee_multiplier(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
|
bool simple_wallet::set_default_priority(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
int fee_multiplier = 0;
|
int priority = 0;
|
||||||
if (m_wallet->watch_only())
|
if (m_wallet->watch_only())
|
||||||
{
|
{
|
||||||
fail_msg_writer() << tr("wallet is watch-only and cannot transfer");
|
fail_msg_writer() << tr("wallet is watch-only and cannot transfer");
|
||||||
|
@ -515,19 +515,19 @@ bool simple_wallet::set_default_fee_multiplier(const std::vector<std::string> &a
|
||||||
{
|
{
|
||||||
if (strchr(args[1].c_str(), '-'))
|
if (strchr(args[1].c_str(), '-'))
|
||||||
{
|
{
|
||||||
fail_msg_writer() << tr("fee multiplier must be 0, 1, 2, or 3 ");
|
fail_msg_writer() << tr("priority must be 0, 1, 2, or 3 ");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args[1] == "0")
|
if (args[1] == "0")
|
||||||
{
|
{
|
||||||
fee_multiplier = 0;
|
priority = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fee_multiplier = boost::lexical_cast<int>(args[1]);
|
priority = boost::lexical_cast<int>(args[1]);
|
||||||
if (fee_multiplier != 1 && fee_multiplier != 2 && fee_multiplier != 3)
|
if (priority != 1 && priority != 2 && priority != 3)
|
||||||
{
|
{
|
||||||
fail_msg_writer() << tr("fee multiplier must be 0, 1, 2, or 3");
|
fail_msg_writer() << tr("priority must be 0, 1, 2, or 3");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -548,18 +548,18 @@ bool simple_wallet::set_default_fee_multiplier(const std::vector<std::string> &a
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_wallet->set_default_fee_multiplier(fee_multiplier);
|
m_wallet->set_default_priority(priority);
|
||||||
m_wallet->rewrite(m_wallet_file, pwd_container.password());
|
m_wallet->rewrite(m_wallet_file, pwd_container.password());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(const boost::bad_lexical_cast &)
|
catch(const boost::bad_lexical_cast &)
|
||||||
{
|
{
|
||||||
fail_msg_writer() << tr("fee multiplier must be 0, 1, 2 or 3");
|
fail_msg_writer() << tr("priority must be 0, 1, 2 or 3");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
fail_msg_writer() << tr("could not change default fee multiplier");
|
fail_msg_writer() << tr("could not change default priority");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -662,7 +662,7 @@ simple_wallet::simple_wallet()
|
||||||
m_cmd_binder.set_handler("viewkey", boost::bind(&simple_wallet::viewkey, this, _1), tr("Display private view key"));
|
m_cmd_binder.set_handler("viewkey", boost::bind(&simple_wallet::viewkey, this, _1), tr("Display private view key"));
|
||||||
m_cmd_binder.set_handler("spendkey", boost::bind(&simple_wallet::spendkey, this, _1), tr("Display private spend key"));
|
m_cmd_binder.set_handler("spendkey", boost::bind(&simple_wallet::spendkey, this, _1), tr("Display private spend key"));
|
||||||
m_cmd_binder.set_handler("seed", boost::bind(&simple_wallet::seed, this, _1), tr("Display Electrum-style mnemonic seed"));
|
m_cmd_binder.set_handler("seed", boost::bind(&simple_wallet::seed, this, _1), tr("Display Electrum-style mnemonic seed"));
|
||||||
m_cmd_binder.set_handler("set", boost::bind(&simple_wallet::set_variable, this, _1), tr("Available options: seed language - set wallet seed language; always-confirm-transfers <1|0> - whether to confirm unsplit txes; store-tx-info <1|0> - whether to store outgoing tx info (destination address, payment ID, tx secret key) for future reference; default-mixin <n> - set default mixin (default default is 4); auto-refresh <1|0> - whether to automatically sync new blocks from the daemon; refresh-type <full|optimize-coinbase|no-coinbase|default> - set wallet refresh behaviour; fee-multiplier [1|2|3] - normal/elevated/priority fee"));
|
m_cmd_binder.set_handler("set", boost::bind(&simple_wallet::set_variable, this, _1), tr("Available options: seed language - set wallet seed language; always-confirm-transfers <1|0> - whether to confirm unsplit txes; store-tx-info <1|0> - whether to store outgoing tx info (destination address, payment ID, tx secret key) for future reference; default-mixin <n> - set default mixin (default default is 4); auto-refresh <1|0> - whether to automatically sync new blocks from the daemon; refresh-type <full|optimize-coinbase|no-coinbase|default> - set wallet refresh behaviour; priority [1|2|3] - normal/elevated/priority fee"));
|
||||||
m_cmd_binder.set_handler("rescan_spent", boost::bind(&simple_wallet::rescan_spent, this, _1), tr("Rescan blockchain for spent outputs"));
|
m_cmd_binder.set_handler("rescan_spent", boost::bind(&simple_wallet::rescan_spent, this, _1), tr("Rescan blockchain for spent outputs"));
|
||||||
m_cmd_binder.set_handler("get_tx_key", boost::bind(&simple_wallet::get_tx_key, this, _1), tr("Get transaction key (r) for a given <txid>"));
|
m_cmd_binder.set_handler("get_tx_key", boost::bind(&simple_wallet::get_tx_key, this, _1), tr("Get transaction key (r) for a given <txid>"));
|
||||||
m_cmd_binder.set_handler("check_tx_key", boost::bind(&simple_wallet::check_tx_key, this, _1), tr("Check amount going to <address> in <txid>"));
|
m_cmd_binder.set_handler("check_tx_key", boost::bind(&simple_wallet::check_tx_key, this, _1), tr("Check amount going to <address> in <txid>"));
|
||||||
|
@ -688,7 +688,7 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
|
||||||
success_msg_writer() << "default-mixin = " << m_wallet->default_mixin();
|
success_msg_writer() << "default-mixin = " << m_wallet->default_mixin();
|
||||||
success_msg_writer() << "auto-refresh = " << m_wallet->auto_refresh();
|
success_msg_writer() << "auto-refresh = " << m_wallet->auto_refresh();
|
||||||
success_msg_writer() << "refresh-type = " << get_refresh_type_name(m_wallet->get_refresh_type());
|
success_msg_writer() << "refresh-type = " << get_refresh_type_name(m_wallet->get_refresh_type());
|
||||||
success_msg_writer() << "fee-multiplier = " << m_wallet->get_default_fee_multiplier();
|
success_msg_writer() << "priority = " << m_wallet->get_default_priority();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -784,18 +784,18 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args[0] == "fee-multiplier")
|
else if (args[0] == "priority")
|
||||||
{
|
{
|
||||||
if (args.size() <= 1)
|
if (args.size() <= 1)
|
||||||
{
|
{
|
||||||
fail_msg_writer() << tr("set fee-multiplier: needs an argument: 0, 1, 2, or 3");
|
fail_msg_writer() << tr("set priority: needs an argument: 0, 1, 2, or 3");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::vector<std::string> local_args = args;
|
std::vector<std::string> local_args = args;
|
||||||
local_args.erase(local_args.begin(), local_args.begin()+2);
|
local_args.erase(local_args.begin(), local_args.begin()+2);
|
||||||
set_default_fee_multiplier(local_args);
|
set_default_priority(local_args);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ namespace cryptonote
|
||||||
bool set_tx_note(const std::vector<std::string> &args);
|
bool set_tx_note(const std::vector<std::string> &args);
|
||||||
bool get_tx_note(const std::vector<std::string> &args);
|
bool get_tx_note(const std::vector<std::string> &args);
|
||||||
bool status(const std::vector<std::string> &args);
|
bool status(const std::vector<std::string> &args);
|
||||||
bool set_default_fee_multiplier(const std::vector<std::string> &args);
|
bool set_default_priority(const std::vector<std::string> &args);
|
||||||
bool sign(const std::vector<std::string> &args);
|
bool sign(const std::vector<std::string> &args);
|
||||||
bool verify(const std::vector<std::string> &args);
|
bool verify(const std::vector<std::string> &args);
|
||||||
bool export_key_images(const std::vector<std::string> &args);
|
bool export_key_images(const std::vector<std::string> &args);
|
||||||
|
|
|
@ -493,9 +493,8 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const
|
||||||
//std::vector<tools::wallet2::pending_tx> ptx_vector;
|
//std::vector<tools::wallet2::pending_tx> ptx_vector;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// priority called "fee_multiplied in terms of underlying wallet interface
|
|
||||||
transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, fake_outs_count, 0 /* unlock_time */,
|
transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, fake_outs_count, 0 /* unlock_time */,
|
||||||
static_cast<uint64_t>(priority),
|
static_cast<uint32_t>(priority),
|
||||||
extra, m_trustedDaemon);
|
extra, m_trustedDaemon);
|
||||||
|
|
||||||
} catch (const tools::error::daemon_busy&) {
|
} catch (const tools::error::daemon_busy&) {
|
||||||
|
|
|
@ -100,7 +100,6 @@ void do_prepare_file_names(const std::string& file_path, std::string& keys_file,
|
||||||
|
|
||||||
uint64_t calculate_fee(uint64_t fee_per_kb, size_t bytes, uint64_t fee_multiplier)
|
uint64_t calculate_fee(uint64_t fee_per_kb, size_t bytes, uint64_t fee_multiplier)
|
||||||
{
|
{
|
||||||
THROW_WALLET_EXCEPTION_IF(fee_multiplier <= 0 || fee_multiplier > 3, tools::error::invalid_fee_multiplier);
|
|
||||||
uint64_t kB = (bytes + 1023) / 1024;
|
uint64_t kB = (bytes + 1023) / 1024;
|
||||||
return kB * fee_per_kb * fee_multiplier;
|
return kB * fee_per_kb * fee_multiplier;
|
||||||
}
|
}
|
||||||
|
@ -1402,8 +1401,8 @@ bool wallet2::store_keys(const std::string& keys_file_name, const std::string& p
|
||||||
value2.SetUint(m_default_mixin);
|
value2.SetUint(m_default_mixin);
|
||||||
json.AddMember("default_mixin", value2, json.GetAllocator());
|
json.AddMember("default_mixin", value2, json.GetAllocator());
|
||||||
|
|
||||||
value2.SetUint(m_default_fee_multiplier);
|
value2.SetUint(m_default_priority);
|
||||||
json.AddMember("default_fee_multiplier", value2, json.GetAllocator());
|
json.AddMember("default_priority", value2, json.GetAllocator());
|
||||||
|
|
||||||
value2.SetInt(m_auto_refresh ? 1 :0);
|
value2.SetInt(m_auto_refresh ? 1 :0);
|
||||||
json.AddMember("auto_refresh", value2, json.GetAllocator());
|
json.AddMember("auto_refresh", value2, json.GetAllocator());
|
||||||
|
@ -1476,7 +1475,7 @@ bool wallet2::load_keys(const std::string& keys_file_name, const std::string& pa
|
||||||
m_watch_only = false;
|
m_watch_only = false;
|
||||||
m_always_confirm_transfers = false;
|
m_always_confirm_transfers = false;
|
||||||
m_default_mixin = 0;
|
m_default_mixin = 0;
|
||||||
m_default_fee_multiplier = 0;
|
m_default_priority = 0;
|
||||||
m_auto_refresh = true;
|
m_auto_refresh = true;
|
||||||
m_refresh_type = RefreshType::RefreshDefault;
|
m_refresh_type = RefreshType::RefreshDefault;
|
||||||
}
|
}
|
||||||
|
@ -1509,8 +1508,19 @@ bool wallet2::load_keys(const std::string& keys_file_name, const std::string& pa
|
||||||
m_store_tx_info = ((field_store_tx_keys != 0) || (field_store_tx_info != 0));
|
m_store_tx_info = ((field_store_tx_keys != 0) || (field_store_tx_info != 0));
|
||||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, default_mixin, unsigned int, Uint, false, 0);
|
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, default_mixin, unsigned int, Uint, false, 0);
|
||||||
m_default_mixin = field_default_mixin;
|
m_default_mixin = field_default_mixin;
|
||||||
|
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, default_priority, unsigned int, Uint, false, 0);
|
||||||
|
if (field_default_priority_found)
|
||||||
|
{
|
||||||
|
m_default_priority = field_default_priority;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, default_fee_multiplier, unsigned int, Uint, false, 0);
|
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, default_fee_multiplier, unsigned int, Uint, false, 0);
|
||||||
m_default_fee_multiplier = field_default_fee_multiplier;
|
if (field_default_fee_multiplier_found)
|
||||||
|
m_default_priority = field_default_fee_multiplier;
|
||||||
|
else
|
||||||
|
m_default_priority = 0;
|
||||||
|
}
|
||||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, auto_refresh, int, Int, false, true);
|
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, auto_refresh, int, Int, false, true);
|
||||||
m_auto_refresh = field_auto_refresh;
|
m_auto_refresh = field_auto_refresh;
|
||||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, refresh_type, int, Int, false, RefreshType::RefreshDefault);
|
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, refresh_type, int, Int, false, RefreshType::RefreshDefault);
|
||||||
|
@ -2535,15 +2545,22 @@ void wallet2::commit_tx(std::vector<pending_tx>& ptx_vector)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t wallet2::sanitize_fee_multiplier(uint64_t fee_multiplier) const
|
uint64_t wallet2::get_fee_multiplier(uint32_t priority, bool use_new_fee) const
|
||||||
{
|
{
|
||||||
// 0, default value used for previous fee argument, defaults to normal fee
|
static const uint64_t old_multipliers[3] = {1, 2, 3};
|
||||||
if (fee_multiplier == 0)
|
static const uint64_t new_multipliers[3] = {1, 20, 166};
|
||||||
return m_default_fee_multiplier > 0 ? m_default_fee_multiplier : 1;
|
|
||||||
// 1 to 3 are allowed as multipliers
|
// 0 -> default (here, x1)
|
||||||
if (fee_multiplier >= 1 && fee_multiplier <= 3)
|
if (priority == 0)
|
||||||
return fee_multiplier;
|
priority = m_default_priority;
|
||||||
THROW_WALLET_EXCEPTION_IF (false, error::invalid_fee_multiplier);
|
if (priority == 0)
|
||||||
|
priority = 1;
|
||||||
|
|
||||||
|
// 1 to 3 are allowed as priorities
|
||||||
|
if (priority >= 1 && priority <= 3)
|
||||||
|
return (use_new_fee ? new_multipliers : old_multipliers)[priority-1];
|
||||||
|
|
||||||
|
THROW_WALLET_EXCEPTION_IF (false, error::invalid_priority);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2552,12 +2569,13 @@ uint64_t wallet2::sanitize_fee_multiplier(uint64_t fee_multiplier) const
|
||||||
//
|
//
|
||||||
// this function will make multiple calls to wallet2::transfer if multiple
|
// this function will make multiple calls to wallet2::transfer if multiple
|
||||||
// transactions will be required
|
// transactions will be required
|
||||||
std::vector<wallet2::pending_tx> wallet2::create_transactions(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint64_t fee_multiplier, const std::vector<uint8_t> extra, bool trusted_daemon)
|
std::vector<wallet2::pending_tx> wallet2::create_transactions(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon)
|
||||||
{
|
{
|
||||||
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 uint64_t fee_per_kb = use_fork_rules(3, -720 * 14) ? FEE_PER_KB : FEE_PER_KB_OLD;
|
const bool use_new_fee = use_fork_rules(3, -720 * 14);
|
||||||
fee_multiplier = sanitize_fee_multiplier(fee_multiplier);
|
const uint64_t fee_per_kb = use_new_fee ? FEE_PER_KB : FEE_PER_KB_OLD;
|
||||||
|
const uint64_t fee_multiplier = get_fee_multiplier(priority, use_new_fee);
|
||||||
|
|
||||||
// failsafe split attempt counter
|
// failsafe split attempt counter
|
||||||
size_t attempt_count = 0;
|
size_t attempt_count = 0;
|
||||||
|
@ -3198,7 +3216,7 @@ std::vector<size_t> wallet2::pick_prefered_rct_inputs(uint64_t needed_money) con
|
||||||
// This system allows for sending (almost) the entire balance, since it does
|
// This system allows for sending (almost) the entire balance, since it does
|
||||||
// not generate spurious change in all txes, thus decreasing the instantaneous
|
// not generate spurious change in all txes, thus decreasing the instantaneous
|
||||||
// usable balance.
|
// usable balance.
|
||||||
std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint64_t fee_multiplier, const std::vector<uint8_t> extra, bool trusted_daemon)
|
std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon)
|
||||||
{
|
{
|
||||||
std::vector<size_t> unused_transfers_indices;
|
std::vector<size_t> unused_transfers_indices;
|
||||||
std::vector<size_t> unused_dust_indices;
|
std::vector<size_t> unused_dust_indices;
|
||||||
|
@ -3226,8 +3244,9 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
||||||
uint64_t upper_transaction_size_limit = get_upper_tranaction_size_limit();
|
uint64_t upper_transaction_size_limit = get_upper_tranaction_size_limit();
|
||||||
const bool use_rct = use_fork_rules(4, 0);
|
const bool use_rct = use_fork_rules(4, 0);
|
||||||
|
|
||||||
const uint64_t fee_per_kb = use_fork_rules(3, -720 * 14) ? FEE_PER_KB : FEE_PER_KB_OLD;
|
const bool use_new_fee = use_fork_rules(3, -720 * 14);
|
||||||
fee_multiplier = sanitize_fee_multiplier(fee_multiplier);
|
const uint64_t fee_per_kb = use_new_fee ? FEE_PER_KB : FEE_PER_KB_OLD;
|
||||||
|
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
|
||||||
THROW_WALLET_EXCEPTION_IF(dsts.empty(), error::zero_destination);
|
THROW_WALLET_EXCEPTION_IF(dsts.empty(), error::zero_destination);
|
||||||
|
@ -3461,7 +3480,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
||||||
return ptx_vector;
|
return ptx_vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, uint64_t fee_multiplier, const std::vector<uint8_t> extra, bool trusted_daemon)
|
std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon)
|
||||||
{
|
{
|
||||||
std::vector<size_t> unused_transfers_indices;
|
std::vector<size_t> unused_transfers_indices;
|
||||||
std::vector<size_t> unused_dust_indices;
|
std::vector<size_t> unused_dust_indices;
|
||||||
|
@ -3478,8 +3497,9 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptono
|
||||||
uint64_t upper_transaction_size_limit = get_upper_tranaction_size_limit();
|
uint64_t upper_transaction_size_limit = get_upper_tranaction_size_limit();
|
||||||
const bool use_rct = use_fork_rules(4, 0);
|
const bool use_rct = use_fork_rules(4, 0);
|
||||||
|
|
||||||
const uint64_t fee_per_kb = use_fork_rules(3, -720 * 14) ? FEE_PER_KB : FEE_PER_KB_OLD;
|
const bool use_new_fee = use_fork_rules(3, -720 * 14);
|
||||||
fee_multiplier = sanitize_fee_multiplier(fee_multiplier);
|
const uint64_t fee_per_kb = use_new_fee ? FEE_PER_KB : FEE_PER_KB_OLD;
|
||||||
|
const uint64_t fee_multiplier = get_fee_multiplier(priority, use_new_fee);
|
||||||
|
|
||||||
// gather all our dust and non dust outputs
|
// gather all our dust and non dust outputs
|
||||||
for (size_t i = 0; i < m_transfers.size(); ++i)
|
for (size_t i = 0; i < m_transfers.size(); ++i)
|
||||||
|
@ -3893,7 +3913,8 @@ std::vector<wallet2::pending_tx> wallet2::create_unmixable_sweep_transactions(bo
|
||||||
const bool hf1_rules = use_fork_rules(2, 10); // first hard fork has version 2
|
const bool hf1_rules = use_fork_rules(2, 10); // first hard fork has version 2
|
||||||
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 uint64_t fee_per_kb = use_fork_rules(3, -720 * 14) ? FEE_PER_KB : FEE_PER_KB_OLD;
|
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;
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
|
@ -92,10 +92,10 @@ namespace tools
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wallet2(const wallet2&) : m_run(true), m_callback(0), m_testnet(false), m_always_confirm_transfers (false), m_store_tx_info(true), m_default_mixin(0), m_default_fee_multiplier(0), m_refresh_type(RefreshOptimizeCoinbase), m_auto_refresh(true), m_refresh_from_block_height(0) {}
|
wallet2(const wallet2&) : m_run(true), m_callback(0), m_testnet(false), m_always_confirm_transfers (false), m_store_tx_info(true), m_default_mixin(0), m_default_priority(0), m_refresh_type(RefreshOptimizeCoinbase), m_auto_refresh(true), m_refresh_from_block_height(0) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wallet2(bool testnet = false, bool restricted = false) : m_run(true), m_callback(0), m_testnet(testnet), m_restricted(restricted), is_old_file_format(false), m_store_tx_info(true), m_default_mixin(0), m_default_fee_multiplier(0), m_refresh_type(RefreshOptimizeCoinbase), m_auto_refresh(true), m_refresh_from_block_height(0) {}
|
wallet2(bool testnet = false, bool restricted = false) : m_run(true), m_callback(0), m_testnet(testnet), m_restricted(restricted), is_old_file_format(false), m_store_tx_info(true), m_default_mixin(0), m_default_priority(0), m_refresh_type(RefreshOptimizeCoinbase), m_auto_refresh(true), m_refresh_from_block_height(0) {}
|
||||||
struct transfer_details
|
struct transfer_details
|
||||||
{
|
{
|
||||||
uint64_t m_block_height;
|
uint64_t m_block_height;
|
||||||
|
@ -305,9 +305,9 @@ namespace tools
|
||||||
|
|
||||||
void commit_tx(pending_tx& ptx_vector);
|
void commit_tx(pending_tx& ptx_vector);
|
||||||
void commit_tx(std::vector<pending_tx>& ptx_vector);
|
void commit_tx(std::vector<pending_tx>& ptx_vector);
|
||||||
std::vector<pending_tx> create_transactions(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint64_t fee_multiplier, const std::vector<uint8_t> extra, bool trusted_daemon);
|
std::vector<pending_tx> create_transactions(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon);
|
||||||
std::vector<wallet2::pending_tx> create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint64_t fee_multiplier, const std::vector<uint8_t> extra, bool trusted_daemon);
|
std::vector<wallet2::pending_tx> create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon);
|
||||||
std::vector<wallet2::pending_tx> create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, uint64_t fee_multiplier, const std::vector<uint8_t> extra, bool trusted_daemon);
|
std::vector<wallet2::pending_tx> create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t> extra, bool trusted_daemon);
|
||||||
std::vector<pending_tx> create_unmixable_sweep_transactions(bool trusted_daemon);
|
std::vector<pending_tx> create_unmixable_sweep_transactions(bool trusted_daemon);
|
||||||
bool check_connection(bool *same_version = NULL);
|
bool check_connection(bool *same_version = NULL);
|
||||||
void get_transfers(wallet2::transfer_container& incoming_transfers) const;
|
void get_transfers(wallet2::transfer_container& incoming_transfers) const;
|
||||||
|
@ -385,8 +385,8 @@ namespace tools
|
||||||
void store_tx_info(bool store) { m_store_tx_info = store; }
|
void store_tx_info(bool store) { m_store_tx_info = store; }
|
||||||
uint32_t default_mixin() const { return m_default_mixin; }
|
uint32_t default_mixin() const { return m_default_mixin; }
|
||||||
void default_mixin(uint32_t m) { m_default_mixin = m; }
|
void default_mixin(uint32_t m) { m_default_mixin = m; }
|
||||||
uint32_t get_default_fee_multiplier() const { return m_default_fee_multiplier; }
|
uint32_t get_default_priority() const { return m_default_priority; }
|
||||||
void set_default_fee_multiplier(uint32_t m) { m_default_fee_multiplier = m; }
|
void set_default_priority(uint32_t p) { m_default_priority = p; }
|
||||||
bool auto_refresh() const { return m_auto_refresh; }
|
bool auto_refresh() const { return m_auto_refresh; }
|
||||||
void auto_refresh(bool r) { m_auto_refresh = r; }
|
void auto_refresh(bool r) { m_auto_refresh = r; }
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ namespace tools
|
||||||
void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const;
|
void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const;
|
||||||
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 sanitize_fee_multiplier(uint64_t fee_multiplier) const;
|
uint64_t get_fee_multiplier(uint32_t priority, bool use_new_fee) const;
|
||||||
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(transfer_details &td, uint64_t height);
|
void set_spent(transfer_details &td, uint64_t height);
|
||||||
|
@ -498,7 +498,7 @@ namespace tools
|
||||||
bool m_always_confirm_transfers;
|
bool m_always_confirm_transfers;
|
||||||
bool m_store_tx_info; /*!< request txkey to be returned in RPC, and store in the wallet cache file */
|
bool m_store_tx_info; /*!< request txkey to be returned in RPC, and store in the wallet cache file */
|
||||||
uint32_t m_default_mixin;
|
uint32_t m_default_mixin;
|
||||||
uint32_t m_default_fee_multiplier;
|
uint32_t m_default_priority;
|
||||||
RefreshType m_refresh_type;
|
RefreshType m_refresh_type;
|
||||||
bool m_auto_refresh;
|
bool m_auto_refresh;
|
||||||
uint64_t m_refresh_from_block_height;
|
uint64_t m_refresh_from_block_height;
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace tools
|
||||||
// file_read_error
|
// file_read_error
|
||||||
// file_save_error
|
// file_save_error
|
||||||
// invalid_password
|
// invalid_password
|
||||||
// invalid_fee_multiplier
|
// invalid_priority
|
||||||
// refresh_error *
|
// refresh_error *
|
||||||
// acc_outs_lookup_error
|
// acc_outs_lookup_error
|
||||||
// block_parse_error
|
// block_parse_error
|
||||||
|
@ -227,10 +227,10 @@ namespace tools
|
||||||
|
|
||||||
std::string to_string() const { return wallet_logic_error::to_string(); }
|
std::string to_string() const { return wallet_logic_error::to_string(); }
|
||||||
};
|
};
|
||||||
struct invalid_fee_multiplier : public wallet_logic_error
|
struct invalid_priority : public wallet_logic_error
|
||||||
{
|
{
|
||||||
explicit invalid_fee_multiplier(std::string&& loc)
|
explicit invalid_priority(std::string&& loc)
|
||||||
: wallet_logic_error(std::move(loc), "invalid fee multiplier")
|
: wallet_logic_error(std::move(loc), "invalid priority")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ namespace tools
|
||||||
LOG_PRINT_L1("Requested mixin " << req.mixin << " too low for hard fork 2, using 2");
|
LOG_PRINT_L1("Requested mixin " << req.mixin << " too low for hard fork 2, using 2");
|
||||||
mixin = 2;
|
mixin = 2;
|
||||||
}
|
}
|
||||||
std::vector<wallet2::pending_tx> ptx_vector = m_wallet.create_transactions_2(dsts, mixin, req.unlock_time, req.fee_multiplier, extra, req.trusted_daemon);
|
std::vector<wallet2::pending_tx> ptx_vector = m_wallet.create_transactions_2(dsts, mixin, req.unlock_time, req.priority, extra, req.trusted_daemon);
|
||||||
|
|
||||||
// reject proposed transactions if there are more than one. see on_transfer_split below.
|
// reject proposed transactions if there are more than one. see on_transfer_split below.
|
||||||
if (ptx_vector.size() != 1)
|
if (ptx_vector.size() != 1)
|
||||||
|
@ -307,7 +307,7 @@ namespace tools
|
||||||
mixin = 2;
|
mixin = 2;
|
||||||
}
|
}
|
||||||
std::vector<wallet2::pending_tx> ptx_vector;
|
std::vector<wallet2::pending_tx> ptx_vector;
|
||||||
ptx_vector = m_wallet.create_transactions_2(dsts, mixin, req.unlock_time, req.fee_multiplier, extra, req.trusted_daemon);
|
ptx_vector = m_wallet.create_transactions_2(dsts, mixin, req.unlock_time, req.priority, extra, req.trusted_daemon);
|
||||||
|
|
||||||
m_wallet.commit_tx(ptx_vector);
|
m_wallet.commit_tx(ptx_vector);
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ namespace tools
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::vector<wallet2::pending_tx> ptx_vector = m_wallet.create_transactions_all(dsts[0].addr, req.mixin, req.unlock_time, req.fee_multiplier, extra, req.trusted_daemon);
|
std::vector<wallet2::pending_tx> ptx_vector = m_wallet.create_transactions_all(dsts[0].addr, req.mixin, req.unlock_time, req.priority, extra, req.trusted_daemon);
|
||||||
|
|
||||||
m_wallet.commit_tx(ptx_vector);
|
m_wallet.commit_tx(ptx_vector);
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ namespace wallet_rpc
|
||||||
struct request
|
struct request
|
||||||
{
|
{
|
||||||
std::list<transfer_destination> destinations;
|
std::list<transfer_destination> destinations;
|
||||||
uint64_t fee_multiplier;
|
uint32_t priority;
|
||||||
uint64_t mixin;
|
uint64_t mixin;
|
||||||
uint64_t unlock_time;
|
uint64_t unlock_time;
|
||||||
std::string payment_id;
|
std::string payment_id;
|
||||||
|
@ -119,7 +119,7 @@ namespace wallet_rpc
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE(destinations)
|
KV_SERIALIZE(destinations)
|
||||||
KV_SERIALIZE(fee_multiplier)
|
KV_SERIALIZE(priority)
|
||||||
KV_SERIALIZE(mixin)
|
KV_SERIALIZE(mixin)
|
||||||
KV_SERIALIZE(unlock_time)
|
KV_SERIALIZE(unlock_time)
|
||||||
KV_SERIALIZE(payment_id)
|
KV_SERIALIZE(payment_id)
|
||||||
|
@ -147,7 +147,7 @@ namespace wallet_rpc
|
||||||
struct request
|
struct request
|
||||||
{
|
{
|
||||||
std::list<transfer_destination> destinations;
|
std::list<transfer_destination> destinations;
|
||||||
uint64_t fee_multiplier;
|
uint32_t priority;
|
||||||
uint64_t mixin;
|
uint64_t mixin;
|
||||||
uint64_t unlock_time;
|
uint64_t unlock_time;
|
||||||
std::string payment_id;
|
std::string payment_id;
|
||||||
|
@ -156,7 +156,7 @@ namespace wallet_rpc
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE(destinations)
|
KV_SERIALIZE(destinations)
|
||||||
KV_SERIALIZE(fee_multiplier)
|
KV_SERIALIZE(priority)
|
||||||
KV_SERIALIZE(mixin)
|
KV_SERIALIZE(mixin)
|
||||||
KV_SERIALIZE(unlock_time)
|
KV_SERIALIZE(unlock_time)
|
||||||
KV_SERIALIZE(payment_id)
|
KV_SERIALIZE(payment_id)
|
||||||
|
@ -225,7 +225,7 @@ namespace wallet_rpc
|
||||||
struct request
|
struct request
|
||||||
{
|
{
|
||||||
std::string address;
|
std::string address;
|
||||||
uint64_t fee_multiplier;
|
uint32_t priority;
|
||||||
uint64_t mixin;
|
uint64_t mixin;
|
||||||
uint64_t unlock_time;
|
uint64_t unlock_time;
|
||||||
std::string payment_id;
|
std::string payment_id;
|
||||||
|
@ -234,7 +234,7 @@ namespace wallet_rpc
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE(address)
|
KV_SERIALIZE(address)
|
||||||
KV_SERIALIZE(fee_multiplier)
|
KV_SERIALIZE(priority)
|
||||||
KV_SERIALIZE(mixin)
|
KV_SERIALIZE(mixin)
|
||||||
KV_SERIALIZE(unlock_time)
|
KV_SERIALIZE(unlock_time)
|
||||||
KV_SERIALIZE(payment_id)
|
KV_SERIALIZE(payment_id)
|
||||||
|
|
Loading…
Reference in New Issue