mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-23 11:23:26 +01:00
Merge pull request #3629
ed7825d
monero-wallet-cli: added locked_sweep_all command (jcktm)
This commit is contained in:
commit
b293c487fb
@ -2169,6 +2169,10 @@ simple_wallet::simple_wallet()
|
||||
boost::bind(&simple_wallet::locked_transfer, this, _1),
|
||||
tr("locked_transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <addr> <amount> <lockblocks> [<payment_id>]"),
|
||||
tr("Transfer <amount> to <address> and lock it for <lockblocks> (max. 1000000). 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 transaction fee. 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_sweep_all",
|
||||
boost::bind(&simple_wallet::locked_sweep_all, this, _1),
|
||||
tr("locked_sweep_all [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <lockblocks> [<payment_id>]"),
|
||||
tr("Send all unlocked balance to an address and lock it for <lockblocks> (max. 1000000). 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. <priority> is the priority of the sweep. The higher the priority, the higher the transaction fee. 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."));
|
||||
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"));
|
||||
@ -4870,6 +4874,11 @@ bool simple_wallet::locked_transfer(const std::vector<std::string> &args_)
|
||||
return transfer_main(TransferLocked, args_);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::locked_sweep_all(const std::vector<std::string> &args_)
|
||||
{
|
||||
return sweep_main(0, true, args_);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
bool simple_wallet::sweep_unmixable(const std::vector<std::string> &args_)
|
||||
{
|
||||
@ -4977,7 +4986,7 @@ bool simple_wallet::sweep_unmixable(const std::vector<std::string> &args_)
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &args_)
|
||||
bool simple_wallet::sweep_main(uint64_t below, bool locked, const std::vector<std::string> &args_)
|
||||
{
|
||||
auto print_usage = [below]()
|
||||
{
|
||||
@ -5040,9 +5049,44 @@ bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &a
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t unlock_block = 0;
|
||||
if (locked) {
|
||||
uint64_t locked_blocks = 0;
|
||||
|
||||
if (local_args.size() < 2) {
|
||||
fail_msg_writer() << tr("missing lockedblocks parameter");
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
locked_blocks = boost::lexical_cast<uint64_t>(local_args[1]);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
fail_msg_writer() << tr("bad locked_blocks parameter");
|
||||
return true;
|
||||
}
|
||||
if (locked_blocks > 1000000)
|
||||
{
|
||||
fail_msg_writer() << tr("Locked blocks too high, max 1000000 (˜4 yrs)");
|
||||
return true;
|
||||
}
|
||||
std::string err;
|
||||
uint64_t bc_height = get_daemon_blockchain_height(err);
|
||||
if (!err.empty())
|
||||
{
|
||||
fail_msg_writer() << tr("failed to get blockchain height: ") << err;
|
||||
return true;
|
||||
}
|
||||
unlock_block = bc_height + locked_blocks;
|
||||
|
||||
local_args.erase(local_args.begin() + 1);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> extra;
|
||||
bool payment_id_seen = false;
|
||||
if (2 >= local_args.size())
|
||||
if (local_args.size() >= 2)
|
||||
{
|
||||
std::string payment_id_str = local_args.back();
|
||||
|
||||
@ -5124,7 +5168,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 */, priority, extra, m_current_subaddress_account, subaddr_indices, is_daemon_trusted());
|
||||
auto ptx_vector = m_wallet->create_transactions_all(below, info.address, info.is_subaddress, fake_outs_count, unlock_block /* unlock_time */, priority, extra, m_current_subaddress_account, subaddr_indices, is_daemon_trusted());
|
||||
|
||||
if (ptx_vector.empty())
|
||||
{
|
||||
@ -5420,7 +5464,7 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::sweep_all(const std::vector<std::string> &args_)
|
||||
{
|
||||
return sweep_main(0, args_);
|
||||
return sweep_main(0, false, args_);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::sweep_below(const std::vector<std::string> &args_)
|
||||
@ -5436,7 +5480,7 @@ bool simple_wallet::sweep_below(const std::vector<std::string> &args_)
|
||||
fail_msg_writer() << tr("invalid amount threshold");
|
||||
return true;
|
||||
}
|
||||
return sweep_main(below, std::vector<std::string>(++args_.begin(), args_.end()));
|
||||
return sweep_main(below, false, std::vector<std::string>(++args_.begin(), args_.end()));
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::donate(const std::vector<std::string> &args_)
|
||||
|
@ -153,7 +153,8 @@ namespace cryptonote
|
||||
bool transfer(const std::vector<std::string> &args);
|
||||
bool transfer_new(const std::vector<std::string> &args);
|
||||
bool locked_transfer(const std::vector<std::string> &args);
|
||||
bool sweep_main(uint64_t below, const std::vector<std::string> &args);
|
||||
bool locked_sweep_all(const std::vector<std::string> &args);
|
||||
bool sweep_main(uint64_t below, bool locked, const std::vector<std::string> &args);
|
||||
bool sweep_all(const std::vector<std::string> &args);
|
||||
bool sweep_below(const std::vector<std::string> &args);
|
||||
bool sweep_single(const std::vector<std::string> &args);
|
||||
|
Loading…
Reference in New Issue
Block a user