mirror of
https://github.com/monero-project/monero.git
synced 2024-12-14 04:16:32 +02:00
wallet-cli: allow priority argument for sweep_all and donate
This commit is contained in:
parent
13a84caa22
commit
8041b4e901
@ -107,7 +107,7 @@ enum TransferType {
|
||||
|
||||
namespace
|
||||
{
|
||||
const auto allowed_priority_strings = {"default", "unimportant", "normal", "elevated", "priority"};
|
||||
const std::array<const char* const, 5> allowed_priority_strings = {{"default", "unimportant", "normal", "elevated", "priority"}};
|
||||
const auto arg_wallet_file = wallet_args::arg_wallet_file();
|
||||
const command_line::arg_descriptor<std::string> arg_generate_new_wallet = {"generate-new-wallet", sw::tr("Generate new wallet and save it to <arg>"), ""};
|
||||
const command_line::arg_descriptor<std::string> arg_generate_from_view_key = {"generate-from-view-key", sw::tr("Generate incoming-only wallet from view key"), ""};
|
||||
@ -278,6 +278,18 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
bool parse_priority(const std::string& arg, uint32_t& priority)
|
||||
{
|
||||
auto priority_pos = std::find(
|
||||
allowed_priority_strings.begin(),
|
||||
allowed_priority_strings.end(),
|
||||
arg);
|
||||
if(priority_pos != allowed_priority_strings.end()) {
|
||||
priority = std::distance(allowed_priority_strings.begin(), priority_pos);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string simple_wallet::get_commands_str()
|
||||
{
|
||||
@ -820,8 +832,8 @@ simple_wallet::simple_wallet()
|
||||
m_cmd_binder.set_handler("transfer", boost::bind(&simple_wallet::transfer_new, this, _1), tr("transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <amount> [<payment_id>] - Transfer <amount> to <address>. If the parameter \"index=<N1>[,<N2>,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. <priority> is the priority of the transaction. The higher the priority, the higher the fee of the transaction. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. <ring_size> is the number of inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)"));
|
||||
m_cmd_binder.set_handler("locked_transfer", boost::bind(&simple_wallet::locked_transfer, this, _1), tr("locked_transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <addr> <amount> <lockblocks> [<payment_id>] - Same as transfer, but with number of blocks to lock the transaction for, max 1000000"));
|
||||
m_cmd_binder.set_handler("sweep_unmixable", boost::bind(&simple_wallet::sweep_unmixable, this, _1), tr("Send all unmixable outputs to yourself with ring_size 1"));
|
||||
m_cmd_binder.set_handler("sweep_all", boost::bind(&simple_wallet::sweep_all, this, _1), tr("sweep_all [index=<N1>[,<N2>,...]] [<ring_size>] <address> [<payment_id>] - Send all unlocked balance to an address. If the parameter \"index<N1>[,<N2>,...]\" is specified, the wallet sweeps outputs received by those address indices. If omitted, the wallet randomly chooses an address index to be used."));
|
||||
m_cmd_binder.set_handler("sweep_below", boost::bind(&simple_wallet::sweep_below, this, _1), tr("sweep_below <amount_threshold> [index=<N1>[,<N2>,...]] [<ring_size>] <address> [<payment_id>] - Send all unlocked outputs below the threshold to an address"));
|
||||
m_cmd_binder.set_handler("sweep_all", boost::bind(&simple_wallet::sweep_all, this, _1), tr("sweep_all [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> [<payment_id>] - Send all unlocked balance to an address. If the parameter \"index<N1>[,<N2>,...]\" is specified, the wallet sweeps outputs received by those address indices. If omitted, the wallet randomly chooses an address index to be used."));
|
||||
m_cmd_binder.set_handler("sweep_below", boost::bind(&simple_wallet::sweep_below, this, _1), tr("sweep_below <amount_threshold> [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> [<payment_id>] - Send all unlocked outputs below the threshold to an address"));
|
||||
m_cmd_binder.set_handler("donate", boost::bind(&simple_wallet::donate, this, _1), tr("donate [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <amount> [<payment_id>] - Donate <amount> to the development team (donate.getmonero.org)"));
|
||||
m_cmd_binder.set_handler("sign_transfer", boost::bind(&simple_wallet::sign_transfer, this, _1), tr("Sign a transaction from a file"));
|
||||
m_cmd_binder.set_handler("submit_transfer", boost::bind(&simple_wallet::submit_transfer, this, _1), tr("Submit a signed transaction from a file"));
|
||||
@ -2483,17 +2495,9 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
|
||||
local_args.erase(local_args.begin());
|
||||
}
|
||||
|
||||
int priority = 0;
|
||||
if(local_args.size() > 0) {
|
||||
auto priority_pos = std::find(
|
||||
allowed_priority_strings.begin(),
|
||||
allowed_priority_strings.end(),
|
||||
local_args[0]);
|
||||
if(priority_pos != allowed_priority_strings.end()) {
|
||||
uint32_t priority = 0;
|
||||
if (local_args.size() > 0 && parse_priority(local_args[0], priority))
|
||||
local_args.erase(local_args.begin());
|
||||
priority = std::distance(allowed_priority_strings.begin(), priority_pos);
|
||||
}
|
||||
}
|
||||
|
||||
size_t fake_outs_count = 0;
|
||||
if(local_args.size() > 0) {
|
||||
@ -3082,6 +3086,10 @@ bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &a
|
||||
local_args.erase(local_args.begin());
|
||||
}
|
||||
|
||||
uint32_t priority = 0;
|
||||
if (local_args.size() > 0 && parse_priority(local_args[0], priority))
|
||||
local_args.erase(local_args.begin());
|
||||
|
||||
size_t fake_outs_count = 0;
|
||||
if(local_args.size() > 0) {
|
||||
size_t ring_size;
|
||||
@ -3186,7 +3194,7 @@ bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &a
|
||||
try
|
||||
{
|
||||
// figure out what tx will be necessary
|
||||
auto ptx_vector = m_wallet->create_transactions_all(below, info.address, info.is_subaddress, fake_outs_count, 0 /* unlock_time */, 0 /* unused fee arg*/, extra, m_current_subaddress_account, subaddr_indices, m_trusted_daemon);
|
||||
auto ptx_vector = m_wallet->create_transactions_all(below, info.address, info.is_subaddress, fake_outs_count, 0 /* unlock_time */, priority, extra, m_current_subaddress_account, subaddr_indices, m_trusted_daemon);
|
||||
|
||||
if (ptx_vector.empty())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user