mirror of
https://github.com/monero-project/monero.git
synced 2024-12-25 06:29:22 -05:00
Merge pull request #5020
1ef79b43
simplewallet: disable long payment ids by default (moneromooo-monero)
This commit is contained in:
commit
f3368acef5
@ -113,6 +113,14 @@ typedef cryptonote::simple_wallet sw;
|
||||
|
||||
#define PRINT_USAGE(usage_help) fail_msg_writer() << boost::format(tr("usage: %s")) % usage_help;
|
||||
|
||||
#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,
|
||||
@ -141,6 +149,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", ""};
|
||||
|
||||
@ -151,12 +160,12 @@ namespace
|
||||
const char* USAGE_PAYMENTS("payments <PID_1> [<PID_2> ... <PID_N>]");
|
||||
const char* USAGE_PAYMENT_ID("payment_id");
|
||||
const char* USAGE_TRANSFER("transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] (<URI> | <address> <amount>) [<payment_id>]");
|
||||
const char* USAGE_LOCKED_TRANSFER("locked_transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] (<URI> | <addr> <amount>) <lockblocks> [<payment_id>]");
|
||||
const char* USAGE_LOCKED_SWEEP_ALL("locked_sweep_all [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <lockblocks> [<payment_id>]");
|
||||
const char* USAGE_SWEEP_ALL("sweep_all [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] [outputs=<N>] <address> [<payment_id>]");
|
||||
const char* USAGE_SWEEP_BELOW("sweep_below <amount_threshold> [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> [<payment_id>]");
|
||||
const char* USAGE_SWEEP_SINGLE("sweep_single [<priority>] [<ring_size>] [outputs=<N>] <key_image> <address> [<payment_id>]");
|
||||
const char* USAGE_DONATE("donate [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <amount> [<payment_id>]");
|
||||
const char* USAGE_LOCKED_TRANSFER("locked_transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] (<URI> | <addr> <amount>) <lockblocks> [<payment_id (obsolete)>]");
|
||||
const char* USAGE_LOCKED_SWEEP_ALL("locked_sweep_all [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <lockblocks> [<payment_id (obsolete)>]");
|
||||
const char* USAGE_SWEEP_ALL("sweep_all [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] [outputs=<N>] <address> [<payment_id (obsolete)>]");
|
||||
const char* USAGE_SWEEP_BELOW("sweep_below <amount_threshold> [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> [<payment_id (obsolete)>]");
|
||||
const char* USAGE_SWEEP_SINGLE("sweep_single [<priority>] [<ring_size>] [outputs=<N>] <key_image> <address> [<payment_id (obsolete)>]");
|
||||
const char* USAGE_DONATE("donate [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <amount> [<payment_id (obsolete)>]");
|
||||
const char* USAGE_SIGN_TRANSFER("sign_transfer [export_raw]");
|
||||
const char* USAGE_SET_LOG("set_log <level>|{+,-,}<categories>");
|
||||
const char* USAGE_ACCOUNT("account\n"
|
||||
@ -864,6 +873,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)
|
||||
{
|
||||
@ -2226,6 +2237,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)
|
||||
{
|
||||
@ -2851,7 +2864,7 @@ simple_wallet::simple_wallet()
|
||||
m_cmd_binder.set_handler("payment_id",
|
||||
boost::bind(&simple_wallet::payment_id, this, _1),
|
||||
tr(USAGE_PAYMENT_ID),
|
||||
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."));
|
||||
@ -3904,6 +3917,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() ||
|
||||
@ -4617,7 +4631,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)
|
||||
@ -5316,6 +5330,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);
|
||||
@ -5426,6 +5442,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");
|
||||
}
|
||||
@ -5447,7 +5464,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?"), true);
|
||||
if (std::cin.eof())
|
||||
@ -5970,6 +5987,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);
|
||||
@ -6014,7 +6033,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?"), true);
|
||||
if (std::cin.eof())
|
||||
@ -6225,6 +6244,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
|
||||
@ -6282,7 +6302,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?"), true);
|
||||
if (std::cin.eof())
|
||||
@ -6498,6 +6518,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)";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8226,6 +8247,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))
|
||||
@ -8269,7 +8291,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";
|
||||
}
|
||||
}
|
||||
@ -8952,6 +8974,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);
|
||||
|
@ -398,6 +398,8 @@ 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;
|
||||
|
||||
// MMS
|
||||
mms::message_store& get_message_store() const { return m_wallet->get_message_store(); };
|
||||
|
Loading…
Reference in New Issue
Block a user