Rename to lockblocks and add max value

This commit is contained in:
Oyvind Kvanes 2016-10-04 11:13:26 +02:00
parent 68ac0607da
commit 71538f3240

View file

@ -652,7 +652,7 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("bc_height", boost::bind(&simple_wallet::show_blockchain_height, this, _1), tr("Show blockchain height"));
m_cmd_binder.set_handler("transfer_original", boost::bind(&simple_wallet::transfer, this, _1), tr("transfer [<mixin_count>] <addr_1> <amount_1> [<addr_2> <amount_2> ... <addr_N> <amount_N>] [payment_id] - Transfer <amount_1>,... <amount_N> to <address_1>,... <address_N>, respectively. <mixin_count> is the number of extra inputs to include for untraceability (from 0 to maximum available)"));
m_cmd_binder.set_handler("transfer", boost::bind(&simple_wallet::transfer_new, this, _1), tr("Same as transfer_original, but using a new transaction building algorithm"));
m_cmd_binder.set_handler("locked_transfer", boost::bind(&simple_wallet::locked_transfer, this, _1), tr("transfer [<mixin_count>] <addr> <amount> <locktime>(Number of blocks to lock the transaction for) [payment_id]"));
m_cmd_binder.set_handler("locked_transfer", boost::bind(&simple_wallet::locked_transfer, this, _1), tr("transfer [<mixin_count>] <addr> <amount> <lockblocks>(Number of blocks to lock the transaction for, max 1000000) [<payment_id>]"));
m_cmd_binder.set_handler("sweep_unmixable", boost::bind(&simple_wallet::sweep_unmixable, this, _1), tr("Send all unmixable outputs to yourself with mixin 0"));
m_cmd_binder.set_handler("sweep_all", boost::bind(&simple_wallet::sweep_all, this, _1), tr("Send all unlocked balance an address"));
m_cmd_binder.set_handler("set_log", boost::bind(&simple_wallet::set_log, this, _1), tr("set_log <level> - Change current log detail level, <0-4>"));
@ -2589,7 +2589,8 @@ bool simple_wallet::locked_transfer(const std::vector<std::string> &args_)
fail_msg_writer() << tr("this is a watch only wallet");
return true;
}
int given_unlock_time = 0;
int locked_blocks = 0;
std::vector<uint8_t> extra;
bool payment_id_seen = false;
@ -2627,54 +2628,39 @@ bool simple_wallet::locked_transfer(const std::vector<std::string> &args_)
}
}
//std::string unlock_time_string = local_args.back();
given_unlock_time = std::stoi( local_args.back() );
locked_blocks = std::stoi( local_args.back() );
if (locked_blocks > 1000000) {
fail_msg_writer() << tr("Locked blocks too high, max 1000000 (˜4 yrs)");
return true;
}
local_args.pop_back();
}
else
{
fail_msg_writer() << tr("wrong number of arguments");
fail_msg_writer() << tr("Wrong number of arguments, use: locked_transfer [<mixin_count>] <addr> <amount> <lockblocks> [<payment_id>]");
return true;
}
vector<cryptonote::tx_destination_entry> dsts;
for (size_t i = 0; i < 1; i += 2)
{
cryptonote::tx_destination_entry de;
bool has_payment_id;
crypto::hash8 new_payment_id;
if (!get_address_from_str(local_args[i], de.addr, has_payment_id, new_payment_id))
if (!get_address_from_str(local_args[0], de.addr, has_payment_id, new_payment_id))
return true;
if (has_payment_id)
{
if (payment_id_seen)
{
fail_msg_writer() << tr("a single transaction cannot use more than one payment id: ") << local_args[i];
return true;
}
std::string extra_nonce;
set_encrypted_payment_id_to_tx_extra_nonce(extra_nonce, new_payment_id);
bool r = add_extra_nonce_to_tx_extra(extra, extra_nonce);
if(!r)
{
fail_msg_writer() << tr("failed to set up payment id, though it was decoded correctly");
return true;
}
}
bool ok = cryptonote::parse_amount(de.amount, local_args[i + 1]);
bool ok = cryptonote::parse_amount(de.amount, local_args[1]);
if(!ok || 0 == de.amount)
{
fail_msg_writer() << tr("amount is wrong: ") << local_args[i] << ' ' << local_args[i + 1] <<
fail_msg_writer() << tr("amount is wrong: ") << local_args[0] << ' ' << local_args[1] <<
", " << tr("expected number from 0 to ") << print_money(std::numeric_limits<uint64_t>::max());
return true;
}
dsts.push_back(de);
}
try
{
@ -2683,8 +2669,8 @@ bool simple_wallet::locked_transfer(const std::vector<std::string> &args_)
std::string err;
int bc_height = get_daemon_blockchain_height(err);
int unlock_time = given_unlock_time + bc_height;
ptx_vector = m_wallet->create_transactions_2(dsts, fake_outs_count, unlock_time , 0 /* unused fee arg*/, extra, m_trusted_daemon);
int unlock_block = locked_blocks + bc_height;
ptx_vector = m_wallet->create_transactions_2(dsts, fake_outs_count, unlock_block , 0 /* unused fee arg*/, extra, m_trusted_daemon);
uint64_t total_fee = 0;
uint64_t dust_not_in_fee = 0;
@ -2716,9 +2702,8 @@ bool simple_wallet::locked_transfer(const std::vector<std::string> &args_)
if (dust_not_in_fee != 0) prompt << tr(".") << ENDL << boost::format(tr("A total of %s from dust change will be sent to dust address"))
% print_money(dust_not_in_fee);
float days = (float)(given_unlock_time) / 720.0;
prompt << boost::format(tr(".\nThe unlock time is approximately %s days")) %
days;
float days = (float)(locked_blocks) / 720.0;
prompt << boost::format(tr(".\nThe unlock time is approximately %s days")) % days;
prompt << tr(".") << ENDL << tr("Is this okay? (Y/Yes/N/No)");
@ -2766,7 +2751,7 @@ bool simple_wallet::locked_transfer(const std::vector<std::string> &args_)
print_money(e.tx_amount() + e.fee()) %
print_money(e.tx_amount()) %
print_money(e.fee()));
fail_msg_writer() << tr("Failed to find a way to create transactions, too bad. This is usually due to dust which is so small it cannot pay for itself in fees");
fail_msg_writer() << tr("Not enough money to transfer.");
}
catch (const tools::error::not_enough_outs_to_mix& e)
{