merge conflicts

This commit is contained in:
Sean Darcy 2021-04-14 15:19:21 +10:00
parent b4c483b9bf
commit 71ab07f032
3 changed files with 38 additions and 30 deletions

View File

@ -5676,6 +5676,27 @@ void simple_wallet::check_for_inactivity_lock(bool user)
}
}
//----------------------------------------------------------------------------------------------------
std::string eat_named_argument(std::vector<std::string> &args, std::string_view prefix)
{
std::string result = {};
for (auto it = args.begin(); it != args.end(); it++)
{
if (it->size() > prefix.size() && tools::starts_with(*it, prefix))
{
result = it->substr(prefix.size());
args.erase(it);
break;
}
}
return result;
}
template <typename... Prefixes>
std::array<std::string, sizeof...(Prefixes)> eat_named_arguments(std::vector<std::string> &args, const Prefixes&... prefixes)
{
return { eat_named_argument(args, prefixes)... };
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::confirm_and_send_tx(std::vector<cryptonote::address_parse_info> const &dests, std::vector<tools::wallet2::pending_tx> &ptx_vector, bool blink, uint64_t lock_time_in_blocks, uint64_t unlock_block, bool called_by_mms)
{
if (ptx_vector.empty())
@ -5845,6 +5866,12 @@ bool simple_wallet::transfer_main(Transfer transfer_type, const std::vector<std:
return false;
std::vector<std::string> local_args = args_;
static constexpr auto BURN_PREFIX = "burn="sv;
uint64_t burn_amount = 0;
std::string burn_amount_str = eat_named_argument(local_args, BURN_PREFIX);
tools::parse_int(burn_amount_str, burn_amount);
uint32_t priority = 0;
std::set<uint32_t> subaddr_indices = {};
if (!parse_subaddr_indices_and_priority(*m_wallet, local_args, subaddr_indices, priority, m_current_subaddress_account)) return false;
@ -5863,6 +5890,7 @@ bool simple_wallet::transfer_main(Transfer transfer_type, const std::vector<std:
return false;
}
std::vector<uint8_t> extra;
if (!local_args.empty())
{
@ -6006,7 +6034,7 @@ bool simple_wallet::transfer_main(Transfer transfer_type, const std::vector<std:
}
oxen_construct_tx_params tx_params = tools::wallet2::construct_params(*hf_version, txtype::standard, priority);
oxen_construct_tx_params tx_params = tools::wallet2::construct_params(*hf_version, txtype::standard, priority, burn_amount*COIN);
ptx_vector = m_wallet->create_transactions_2(dsts, CRYPTONOTE_DEFAULT_TX_MIXIN, unlock_block, priority, extra, m_current_subaddress_account, subaddr_indices, tx_params);
if (ptx_vector.empty())
@ -6413,27 +6441,6 @@ bool simple_wallet::print_locked_stakes(const std::vector<std::string>& /*args*/
query_locked_stakes(true/*print_result*/);
return true;
}
//----------------------------------------------------------------------------------------------------
std::string eat_named_argument(std::vector<std::string> &args, std::string_view prefix)
{
std::string result = {};
for (auto it = args.begin(); it != args.end(); it++)
{
if (it->size() > prefix.size() && tools::starts_with(*it, prefix))
{
result = it->substr(prefix.size());
args.erase(it);
break;
}
}
return result;
}
template <typename... Prefixes>
std::array<std::string, sizeof...(Prefixes)> eat_named_arguments(std::vector<std::string> &args, const Prefixes&... prefixes)
{
return { eat_named_argument(args, prefixes)... };
}
// Parse a user-provided typestring value; if not provided, guess from the provided name and value.
static std::optional<ons::mapping_type> guess_ons_type(tools::wallet2& wallet, std::string_view typestr, std::string_view name, std::string_view value)

View File

@ -7838,7 +7838,7 @@ uint64_t wallet2::get_fee_quantization_mask() const
return 1;
}
oxen_construct_tx_params wallet2::construct_params(uint8_t hf_version, txtype tx_type, uint32_t priority, ons::mapping_type type)
oxen_construct_tx_params wallet2::construct_params(uint8_t hf_version, txtype tx_type, uint32_t priority, uint64_t extra_burn, ons::mapping_type type)
{
oxen_construct_tx_params tx_params;
tx_params.hf_version = hf_version;
@ -7847,11 +7847,11 @@ oxen_construct_tx_params wallet2::construct_params(uint8_t hf_version, txtype tx
if (tx_type == txtype::oxen_name_system)
{
assert(priority != tools::tx_priority_blink);
tx_params.burn_fixed = ons::burn_needed(hf_version, type);
tx_params.burn_fixed = ons::burn_needed(hf_version, type) + extra_burn;
}
else if (priority == tools::tx_priority_blink)
{
tx_params.burn_fixed = BLINK_BURN_FIXED;
tx_params.burn_fixed = BLINK_BURN_FIXED + extra_burn;
tx_params.burn_percent = hf_version <= network_version_14_blink
? BLINK_BURN_TX_FEE_PERCENT_OLD
: BLINK_BURN_TX_FEE_PERCENT;
@ -8877,7 +8877,7 @@ std::vector<wallet2::pending_tx> wallet2::ons_create_buy_mapping_tx(ons::mapping
return {};
}
oxen_construct_tx_params tx_params = wallet2::construct_params(*hf_version, txtype::oxen_name_system, priority, type);
oxen_construct_tx_params tx_params = wallet2::construct_params(*hf_version, txtype::oxen_name_system, priority, 0, type);
auto result = create_transactions_2({} /*dests*/,
CRYPTONOTE_DEFAULT_TX_MIXIN,
0 /*unlock_at_block*/,
@ -8934,7 +8934,7 @@ std::vector<wallet2::pending_tx> wallet2::ons_create_renewal_tx(
return {};
}
oxen_construct_tx_params tx_params = wallet2::construct_params(*hf_version, txtype::oxen_name_system, priority, type);
oxen_construct_tx_params tx_params = wallet2::construct_params(*hf_version, txtype::oxen_name_system, priority, 0, type);
auto result = create_transactions_2({} /*dests*/,
CRYPTONOTE_DEFAULT_TX_MIXIN,
0 /*unlock_at_block*/,
@ -8993,7 +8993,7 @@ std::vector<wallet2::pending_tx> wallet2::ons_create_update_mapping_tx(ons::mapp
if (reason) *reason = ERR_MSG_NETWORK_VERSION_QUERY_FAILED;
return {};
}
oxen_construct_tx_params tx_params = wallet2::construct_params(*hf_version, txtype::oxen_name_system, priority, ons::mapping_type::update_record_internal);
oxen_construct_tx_params tx_params = wallet2::construct_params(*hf_version, txtype::oxen_name_system, priority, 0, ons::mapping_type::update_record_internal);
auto result = create_transactions_2({} /*dests*/,
CRYPTONOTE_DEFAULT_TX_MIXIN,
@ -10948,6 +10948,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
THROW_WALLET_EXCEPTION_IF(needed_money < dt.amount, error::tx_sum_overflow, dsts, 0, m_nettype);
}
// throw if attempting a transaction with no money
THROW_WALLET_EXCEPTION_IF(needed_money == 0 && !is_ons_tx, error::zero_destination);
@ -11360,7 +11361,7 @@ skip_tx:
// fee percent)
if (burning)
{
tx_params.burn_fixed = burn_fixed + tx.needed_fee * burn_percent / fee_percent;
tx_params.burn_fixed = burn_fixed + (tx.needed_fee - burn_fixed) * burn_percent / fee_percent;
// Make sure we can't enlarge the tx because that could make it invalid:
THROW_WALLET_EXCEPTION_IF(tx_params.burn_fixed > BURN_FEE_PLACEHOLDER, error::wallet_internal_error, "attempt to burn a larger amount than is internally supported");
}

View File

@ -1225,7 +1225,7 @@ private:
// params constructor, accumulates the burn amounts if the priority is
// a blink and, or a ons tx. If it is a blink TX, ons_burn_type is ignored.
static cryptonote::oxen_construct_tx_params construct_params(uint8_t hf_version, cryptonote::txtype tx_type, uint32_t priority, ons::mapping_type ons_burn_type = static_cast<ons::mapping_type>(0));
static cryptonote::oxen_construct_tx_params construct_params(uint8_t hf_version, cryptonote::txtype tx_type, uint32_t priority, uint64_t extra_burn = 0, ons::mapping_type ons_burn_type = static_cast<ons::mapping_type>(0));
bool is_unattended() const { return m_unattended; }