From 1ef79b430f72f2cc2465d4e7bbe324f40c188772 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 27 Dec 2018 00:43:15 +0000 Subject: [PATCH] simplewallet: disable long payment ids by default unless --long-payment-id-support is used --- src/simplewallet/simplewallet.cpp | 47 +++++++++++++++++++++++-------- src/simplewallet/simplewallet.h | 2 ++ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index e23fb3836..3f3b7593b 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -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 arg_create_address_file = {"create-address-file", sw::tr("Create an address file for new wallets"), false}; const command_line::arg_descriptor arg_subaddress_lookahead = {"subaddress-lookahead", tools::wallet2::tr("Set subaddress lookahead sizes to :"), ""}; const command_line::arg_descriptor arg_use_english_language_names = {"use-english-language-names", sw::tr("Display English language names"), false}; + const command_line::arg_descriptor 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 > arg_command = {"command", ""}; @@ -151,12 +160,12 @@ namespace const char* USAGE_PAYMENTS("payments [ ... ]"); const char* USAGE_PAYMENT_ID("payment_id"); const char* USAGE_TRANSFER("transfer [index=[,,...]] [] [] ( |
) []"); - const char* USAGE_LOCKED_TRANSFER("locked_transfer [index=[,,...]] [] [] ( | ) []"); - const char* USAGE_LOCKED_SWEEP_ALL("locked_sweep_all [index=[,,...]] [] []
[]"); - const char* USAGE_SWEEP_ALL("sweep_all [index=[,,...]] [] [] [outputs=]
[]"); - const char* USAGE_SWEEP_BELOW("sweep_below [index=[,,...]] [] []
[]"); - const char* USAGE_SWEEP_SINGLE("sweep_single [] [] [outputs=]
[]"); - const char* USAGE_DONATE("donate [index=[,,...]] [] [] []"); + const char* USAGE_LOCKED_TRANSFER("locked_transfer [index=[,,...]] [] [] ( | ) []"); + const char* USAGE_LOCKED_SWEEP_ALL("locked_sweep_all [index=[,,...]] [] []
[]"); + const char* USAGE_SWEEP_ALL("sweep_all [index=[,,...]] [] [] [outputs=]
[]"); + const char* USAGE_SWEEP_BELOW("sweep_below [index=[,,...]] [] []
[]"); + const char* USAGE_SWEEP_SINGLE("sweep_single [] [] [outputs=]
[]"); + const char* USAGE_DONATE("donate [index=[,,...]] [] [] []"); const char* USAGE_SIGN_TRANSFER("sign_transfer [export_raw]"); const char* USAGE_SET_LOG("set_log |{+,-,}"); const char* USAGE_ACCOUNT("account\n" @@ -861,6 +870,8 @@ bool simple_wallet::change_password(const std::vector &args) bool simple_wallet::payment_id(const std::vector &args/* = std::vector()*/) { + LONG_PAYMENT_ID_SUPPORT_CHECK(); + crypto::hash payment_id; if (args.size() > 0) { @@ -2223,6 +2234,8 @@ bool simple_wallet::set_refresh_type(const std::vector &args/* = st bool simple_wallet::set_confirm_missing_payment_id(const std::vector &args/* = std::vector()*/) { + LONG_PAYMENT_ID_SUPPORT_CHECK(); + const auto pwd_container = get_and_verify_password(); if (pwd_container) { @@ -2848,7 +2861,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.")); @@ -3901,6 +3914,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() || @@ -4614,7 +4628,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) @@ -5313,6 +5327,8 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vectorconfirm_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()) @@ -5967,6 +5984,8 @@ bool simple_wallet::sweep_main(uint64_t below, bool locked, const std::vectorconfirm_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()) @@ -6222,6 +6241,7 @@ bool simple_wallet::sweep_single(const std::vector &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 @@ -6279,7 +6299,7 @@ bool simple_wallet::sweep_single(const std::vector &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()) @@ -6495,6 +6515,7 @@ bool simple_wallet::accept_loaded_tx(const std::function 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)"; } } } @@ -8223,6 +8244,7 @@ bool simple_wallet::address_book(const std::vector &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)) @@ -8266,7 +8288,7 @@ bool simple_wallet::address_book(const std::vector &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"; } } @@ -8949,6 +8971,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); diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index f364df2ff..c3dc16d96 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -398,6 +398,8 @@ namespace cryptonote bool m_auto_refresh_refreshing; std::atomic 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(); };