simplewallet: disable long payment ids by default
unless --long-payment-id-support is used
This commit is contained in:
parent
b84b350fd4
commit
e10d12b658
|
@ -107,6 +107,14 @@ typedef cryptonote::simple_wallet sw;
|
|||
if (m_wallet->ask_password() && !m_wallet->watch_only() && !(pwd_container = get_and_verify_password())) { return true; } \
|
||||
tools::wallet_keys_unlocker unlocker(*m_wallet, pwd_container);
|
||||
|
||||
#define LONG_PAYMENT_ID_SUPPORT_CHECK() \
|
||||
do { \
|
||||
if (!m_long_payment_id_support) { \
|
||||
fail_msg_writer() << tr("Long payment IDs are obsolete. Use --long-payment-id-support if you really must use one."); \
|
||||
return true; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
enum TransferType {
|
||||
Transfer,
|
||||
TransferLocked,
|
||||
|
@ -134,6 +142,7 @@ namespace
|
|||
const command_line::arg_descriptor<bool> arg_create_address_file = {"create-address-file", sw::tr("Create an address file for new wallets"), false};
|
||||
const command_line::arg_descriptor<std::string> arg_subaddress_lookahead = {"subaddress-lookahead", tools::wallet2::tr("Set subaddress lookahead sizes to <major>:<minor>"), ""};
|
||||
const command_line::arg_descriptor<bool> arg_use_english_language_names = {"use-english-language-names", sw::tr("Display English language names"), false};
|
||||
const command_line::arg_descriptor<bool> arg_long_payment_id_support = {"long-payment-id-support", sw::tr("Support obsolete long (unencrypted) payment ids"), false};
|
||||
|
||||
const command_line::arg_descriptor< std::vector<std::string> > arg_command = {"command", ""};
|
||||
|
||||
|
@ -766,6 +775,8 @@ bool simple_wallet::change_password(const std::vector<std::string> &args)
|
|||
|
||||
bool simple_wallet::payment_id(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
|
||||
{
|
||||
LONG_PAYMENT_ID_SUPPORT_CHECK();
|
||||
|
||||
crypto::hash payment_id;
|
||||
if (args.size() > 0)
|
||||
{
|
||||
|
@ -1986,6 +1997,8 @@ bool simple_wallet::set_refresh_type(const std::vector<std::string> &args/* = st
|
|||
|
||||
bool simple_wallet::set_confirm_missing_payment_id(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
|
||||
{
|
||||
LONG_PAYMENT_ID_SUPPORT_CHECK();
|
||||
|
||||
const auto pwd_container = get_and_verify_password();
|
||||
if (pwd_container)
|
||||
{
|
||||
|
@ -2308,33 +2321,33 @@ simple_wallet::simple_wallet()
|
|||
boost::bind(&simple_wallet::show_blockchain_height, this, _1),
|
||||
tr("Show the blockchain height."));
|
||||
m_cmd_binder.set_handler("transfer", boost::bind(&simple_wallet::transfer, this, _1),
|
||||
tr("transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] (<URI> | <address> <amount>) [<payment_id>]"),
|
||||
tr("transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] (<URI> | <address> <amount>) [<payment_id (obsolete)>]"),
|
||||
tr("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 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 URI_2 or <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>] (<URI> | <addr> <amount>) <lockblocks> [<payment_id>]"),
|
||||
tr("locked_transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] (<URI> | <addr> <amount>) <lockblocks> [<payment_id (obsolete)>]"),
|
||||
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 URI_2 or <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("locked_sweep_all [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <lockblocks> [<payment_id (obsolete)>]"),
|
||||
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"));
|
||||
m_cmd_binder.set_handler("sweep_all", boost::bind(&simple_wallet::sweep_all, this, _1),
|
||||
tr("sweep_all [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] [outputs=<N>] <address> [<payment_id>]"),
|
||||
tr("sweep_all [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] [outputs=<N>] <address> [<payment_id (obsolete)>]"),
|
||||
tr("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. If the parameter \"outputs=<N>\" is specified and N > 0, wallet splits the transaction into N even outputs."));
|
||||
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>]"),
|
||||
tr("sweep_below <amount_threshold> [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> [<payment_id (obsolete)>]"),
|
||||
tr("Send all unlocked outputs below the threshold to an address."));
|
||||
m_cmd_binder.set_handler("sweep_single",
|
||||
boost::bind(&simple_wallet::sweep_single, this, _1),
|
||||
tr("sweep_single [<priority>] [<ring_size>] [outputs=<N>] <key_image> <address> [<payment_id>]"),
|
||||
tr("sweep_single [<priority>] [<ring_size>] [outputs=<N>] <key_image> <address> [<payment_id (obsolete)>]"),
|
||||
tr("Send a single output of the given key image to an address without change."));
|
||||
m_cmd_binder.set_handler("donate",
|
||||
boost::bind(&simple_wallet::donate, this, _1),
|
||||
tr("donate [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <amount> [<payment_id>]"),
|
||||
tr("donate [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <amount> [<payment_id (obsolete)>]"),
|
||||
tr("Donate <amount> to the development team (donate.getmonero.org)."));
|
||||
m_cmd_binder.set_handler("sign_transfer",
|
||||
boost::bind(&simple_wallet::sign_transfer, this, _1),
|
||||
|
@ -2550,7 +2563,7 @@ simple_wallet::simple_wallet()
|
|||
tr("Change the wallet's password."));
|
||||
m_cmd_binder.set_handler("payment_id",
|
||||
boost::bind(&simple_wallet::payment_id, this, _1),
|
||||
tr("Generate a new random full size payment id. These will be unencrypted on the blockchain, see integrated_address for encrypted short payment ids."));
|
||||
tr("Generate a new random full size payment id (obsolete). These will be unencrypted on the blockchain, see integrated_address for encrypted short payment ids."));
|
||||
m_cmd_binder.set_handler("fee",
|
||||
boost::bind(&simple_wallet::print_fee_info, this, _1),
|
||||
tr("Print the information about the current fee and transaction backlog."));
|
||||
|
@ -3480,6 +3493,7 @@ bool simple_wallet::handle_command_line(const boost::program_options::variables_
|
|||
m_do_not_relay = command_line::get_arg(vm, arg_do_not_relay);
|
||||
m_subaddress_lookahead = command_line::get_arg(vm, arg_subaddress_lookahead);
|
||||
m_use_english_language_names = command_line::get_arg(vm, arg_use_english_language_names);
|
||||
m_long_payment_id_support = command_line::get_arg(vm, arg_long_payment_id_support);
|
||||
m_restoring = !m_generate_from_view_key.empty() ||
|
||||
!m_generate_from_spend_key.empty() ||
|
||||
!m_generate_from_keys.empty() ||
|
||||
|
@ -4180,7 +4194,7 @@ void simple_wallet::on_money_received(uint64_t height, const crypto::hash &txid,
|
|||
tr("NOTE: this transaction uses an encrypted payment ID: consider using subaddresses instead");
|
||||
else if (get_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id))
|
||||
message_writer(console_color_red, false) <<
|
||||
tr("WARNING: this transaction uses an unencrypted payment ID: consider using subaddresses instead");
|
||||
(m_long_payment_id_support ? tr("WARNING: this transaction uses an unencrypted payment ID: consider using subaddresses instead.") : tr("WARNING: this transaction uses an unencrypted payment ID: these are obsolete. Support will be withdrawn in the future. Use subaddresses instead."));
|
||||
}
|
||||
}
|
||||
if (m_auto_refresh_refreshing)
|
||||
|
@ -4781,6 +4795,8 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
|
|||
bool r = true;
|
||||
if (tools::wallet2::parse_long_payment_id(payment_id_str, payment_id))
|
||||
{
|
||||
LONG_PAYMENT_ID_SUPPORT_CHECK();
|
||||
|
||||
std::string extra_nonce;
|
||||
set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
|
||||
r = add_extra_nonce_to_tx_extra(extra, extra_nonce);
|
||||
|
@ -4889,6 +4905,7 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
|
|||
}
|
||||
else if (tools::wallet2::parse_payment_id(payment_id_uri, payment_id))
|
||||
{
|
||||
LONG_PAYMENT_ID_SUPPORT_CHECK();
|
||||
set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
|
||||
message_writer() << tr("Unencrypted payment IDs are bad for privacy: ask the recipient to use subaddresses instead");
|
||||
}
|
||||
|
@ -4910,7 +4927,7 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
|
|||
}
|
||||
|
||||
// prompt is there is no payment id and confirmation is required
|
||||
if (!payment_id_seen && m_wallet->confirm_missing_payment_id() && dsts.size() > num_subaddresses)
|
||||
if (m_long_payment_id_support && !payment_id_seen && m_wallet->confirm_missing_payment_id() && dsts.size() > num_subaddresses)
|
||||
{
|
||||
std::string accepted = input_line(tr("No payment id is included with this transaction. Is this okay? (Y/Yes/N/No): "));
|
||||
if (std::cin.eof())
|
||||
|
@ -5385,6 +5402,8 @@ bool simple_wallet::sweep_main(uint64_t below, bool locked, const std::vector<st
|
|||
bool r = tools::wallet2::parse_long_payment_id(payment_id_str, payment_id);
|
||||
if(r)
|
||||
{
|
||||
LONG_PAYMENT_ID_SUPPORT_CHECK();
|
||||
|
||||
std::string extra_nonce;
|
||||
set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
|
||||
r = add_extra_nonce_to_tx_extra(extra, extra_nonce);
|
||||
|
@ -5429,7 +5448,7 @@ bool simple_wallet::sweep_main(uint64_t below, bool locked, const std::vector<st
|
|||
}
|
||||
|
||||
// prompt is there is no payment id and confirmation is required
|
||||
if (!payment_id_seen && m_wallet->confirm_missing_payment_id() && !info.is_subaddress)
|
||||
if (m_long_payment_id_support && !payment_id_seen && m_wallet->confirm_missing_payment_id() && !info.is_subaddress)
|
||||
{
|
||||
std::string accepted = input_line(tr("No payment id is included with this transaction. Is this okay? (Y/Yes/N/No): "));
|
||||
if (std::cin.eof())
|
||||
|
@ -5616,6 +5635,7 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
|
|||
std::string extra_nonce;
|
||||
if (tools::wallet2::parse_long_payment_id(local_args.back(), payment_id))
|
||||
{
|
||||
LONG_PAYMENT_ID_SUPPORT_CHECK();
|
||||
set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id);
|
||||
}
|
||||
else
|
||||
|
@ -5673,7 +5693,7 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
|
|||
}
|
||||
|
||||
// prompt if there is no payment id and confirmation is required
|
||||
if (!payment_id_seen && m_wallet->confirm_missing_payment_id() && !info.is_subaddress)
|
||||
if (m_long_payment_id_support && !payment_id_seen && m_wallet->confirm_missing_payment_id() && !info.is_subaddress)
|
||||
{
|
||||
std::string accepted = input_line(tr("No payment id is included with this transaction. Is this okay? (Y/Yes/N/No): "));
|
||||
if (std::cin.eof())
|
||||
|
@ -5864,6 +5884,7 @@ bool simple_wallet::accept_loaded_tx(const std::function<size_t()> get_num_txes,
|
|||
if (!payment_id_string.empty())
|
||||
payment_id_string += ", ";
|
||||
payment_id_string = std::string("unencrypted payment ID ") + epee::string_tools::pod_to_hex(payment_id);
|
||||
payment_id_string += " (OBSOLETE)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7417,6 +7438,7 @@ bool simple_wallet::address_book(const std::vector<std::string> &args/* = std::v
|
|||
{
|
||||
if (tools::wallet2::parse_long_payment_id(args[3], payment_id))
|
||||
{
|
||||
LONG_PAYMENT_ID_SUPPORT_CHECK();
|
||||
description_start += 2;
|
||||
}
|
||||
else if (tools::wallet2::parse_short_payment_id(args[3], info.payment_id))
|
||||
|
@ -7460,7 +7482,7 @@ bool simple_wallet::address_book(const std::vector<std::string> &args/* = std::v
|
|||
auto& row = address_book[i];
|
||||
success_msg_writer() << tr("Index: ") << i;
|
||||
success_msg_writer() << tr("Address: ") << get_account_address_as_str(m_wallet->nettype(), row.m_is_subaddress, row.m_address);
|
||||
success_msg_writer() << tr("Payment ID: ") << row.m_payment_id;
|
||||
success_msg_writer() << tr("Payment ID: ") << row.m_payment_id << " (OBSOLETE)";
|
||||
success_msg_writer() << tr("Description: ") << row.m_description << "\n";
|
||||
}
|
||||
}
|
||||
|
@ -8092,6 +8114,7 @@ int main(int argc, char* argv[])
|
|||
command_line::add_arg(desc_params, arg_create_address_file);
|
||||
command_line::add_arg(desc_params, arg_subaddress_lookahead);
|
||||
command_line::add_arg(desc_params, arg_use_english_language_names);
|
||||
command_line::add_arg(desc_params, arg_long_payment_id_support);
|
||||
|
||||
po::positional_options_description positional_options;
|
||||
positional_options.add(arg_command.name, -1);
|
||||
|
|
|
@ -357,5 +357,7 @@ namespace cryptonote
|
|||
bool m_auto_refresh_refreshing;
|
||||
std::atomic<bool> m_in_manual_refresh;
|
||||
uint32_t m_current_subaddress_account;
|
||||
|
||||
bool m_long_payment_id_support;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue