mirror of
https://github.com/monero-project/monero.git
synced 2024-11-18 10:01:02 +00:00
Merge pull request #1160
80b4da3
wallet: wallet option to confirm transfers with no payment id (moneromooo-monero)
This commit is contained in:
commit
bfdac4b5ff
4 changed files with 92 additions and 3 deletions
|
@ -622,6 +622,35 @@ bool simple_wallet::set_refresh_type(const std::vector<std::string> &args/* = st
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool simple_wallet::set_confirm_missing_payment_id(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
if (m_wallet->watch_only())
|
||||||
|
{
|
||||||
|
fail_msg_writer() << tr("wallet is watch-only and cannot transfer");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
tools::password_container pwd_container(m_wallet_file.empty());
|
||||||
|
success = pwd_container.read_password();
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
fail_msg_writer() << tr("failed to read wallet password");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* verify password before using so user doesn't accidentally set a new password for rewritten wallet */
|
||||||
|
success = m_wallet->verify_password(pwd_container.password());
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
fail_msg_writer() << tr("invalid password");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_wallet->confirm_missing_payment_id(is_it_true(args[1]));
|
||||||
|
m_wallet->rewrite(m_wallet_file, pwd_container.password());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool simple_wallet::help(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
|
bool simple_wallet::help(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
|
||||||
{
|
{
|
||||||
success_msg_writer() << get_commands_str();
|
success_msg_writer() << get_commands_str();
|
||||||
|
@ -659,7 +688,7 @@ simple_wallet::simple_wallet()
|
||||||
m_cmd_binder.set_handler("viewkey", boost::bind(&simple_wallet::viewkey, this, _1), tr("Display private view key"));
|
m_cmd_binder.set_handler("viewkey", boost::bind(&simple_wallet::viewkey, this, _1), tr("Display private view key"));
|
||||||
m_cmd_binder.set_handler("spendkey", boost::bind(&simple_wallet::spendkey, this, _1), tr("Display private spend key"));
|
m_cmd_binder.set_handler("spendkey", boost::bind(&simple_wallet::spendkey, this, _1), tr("Display private spend key"));
|
||||||
m_cmd_binder.set_handler("seed", boost::bind(&simple_wallet::seed, this, _1), tr("Display Electrum-style mnemonic seed"));
|
m_cmd_binder.set_handler("seed", boost::bind(&simple_wallet::seed, this, _1), tr("Display Electrum-style mnemonic seed"));
|
||||||
m_cmd_binder.set_handler("set", boost::bind(&simple_wallet::set_variable, this, _1), tr("Available options: seed language - set wallet seed language; always-confirm-transfers <1|0> - whether to confirm unsplit txes; store-tx-info <1|0> - whether to store outgoing tx info (destination address, payment ID, tx secret key) for future reference; default-mixin <n> - set default mixin (default is 4); auto-refresh <1|0> - whether to automatically sync new blocks from the daemon; refresh-type <full|optimize-coinbase|no-coinbase|default> - set wallet refresh behaviour; priority [1|2|3] - normal/elevated/priority fee"));
|
m_cmd_binder.set_handler("set", boost::bind(&simple_wallet::set_variable, this, _1), tr("Available options: seed language - set wallet seed language; always-confirm-transfers <1|0> - whether to confirm unsplit txes; store-tx-info <1|0> - whether to store outgoing tx info (destination address, payment ID, tx secret key) for future reference; default-mixin <n> - set default mixin (default is 4); auto-refresh <1|0> - whether to automatically sync new blocks from the daemon; refresh-type <full|optimize-coinbase|no-coinbase|default> - set wallet refresh behaviour; priority [1|2|3] - normal/elevated/priority fee; confirm-missing-payment-id <1|0>"));
|
||||||
m_cmd_binder.set_handler("rescan_spent", boost::bind(&simple_wallet::rescan_spent, this, _1), tr("Rescan blockchain for spent outputs"));
|
m_cmd_binder.set_handler("rescan_spent", boost::bind(&simple_wallet::rescan_spent, this, _1), tr("Rescan blockchain for spent outputs"));
|
||||||
m_cmd_binder.set_handler("get_tx_key", boost::bind(&simple_wallet::get_tx_key, this, _1), tr("Get transaction key (r) for a given <txid>"));
|
m_cmd_binder.set_handler("get_tx_key", boost::bind(&simple_wallet::get_tx_key, this, _1), tr("Get transaction key (r) for a given <txid>"));
|
||||||
m_cmd_binder.set_handler("check_tx_key", boost::bind(&simple_wallet::check_tx_key, this, _1), tr("Check amount going to <address> in <txid>"));
|
m_cmd_binder.set_handler("check_tx_key", boost::bind(&simple_wallet::check_tx_key, this, _1), tr("Check amount going to <address> in <txid>"));
|
||||||
|
@ -686,6 +715,7 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
|
||||||
success_msg_writer() << "auto-refresh = " << m_wallet->auto_refresh();
|
success_msg_writer() << "auto-refresh = " << m_wallet->auto_refresh();
|
||||||
success_msg_writer() << "refresh-type = " << get_refresh_type_name(m_wallet->get_refresh_type());
|
success_msg_writer() << "refresh-type = " << get_refresh_type_name(m_wallet->get_refresh_type());
|
||||||
success_msg_writer() << "priority = " << m_wallet->get_default_priority();
|
success_msg_writer() << "priority = " << m_wallet->get_default_priority();
|
||||||
|
success_msg_writer() << "confirm-missing-payment-id = " << m_wallet->confirm_missing_payment_id();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -796,6 +826,21 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (args[0] == "confirm-missing-payment-id")
|
||||||
|
{
|
||||||
|
if (args.size() <= 1)
|
||||||
|
{
|
||||||
|
fail_msg_writer() << tr("set confirm-missing-payment-id: needs an argument (0 or 1)");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::vector<std::string> local_args = args;
|
||||||
|
local_args.erase(local_args.begin(), local_args.begin()+2);
|
||||||
|
set_confirm_missing_payment_id(local_args);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fail_msg_writer() << tr("set: unrecognized argument(s)");
|
fail_msg_writer() << tr("set: unrecognized argument(s)");
|
||||||
return true;
|
return true;
|
||||||
|
@ -2370,6 +2415,7 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
|
||||||
fail_msg_writer() << tr("failed to set up payment id, though it was decoded correctly");
|
fail_msg_writer() << tr("failed to set up payment id, though it was decoded correctly");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
payment_id_seen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok = cryptonote::parse_amount(de.amount, local_args[i + 1]);
|
bool ok = cryptonote::parse_amount(de.amount, local_args[i + 1]);
|
||||||
|
@ -2383,6 +2429,22 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
|
||||||
dsts.push_back(de);
|
dsts.push_back(de);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prompt is there is no payment id and confirmation is required
|
||||||
|
if (!payment_id_seen && m_wallet->confirm_missing_payment_id())
|
||||||
|
{
|
||||||
|
std::string accepted = command_line::input_line(tr("No payment id is included with this transaction. Is this okay? (Y/Yes/N/No)"));
|
||||||
|
if (std::cin.eof())
|
||||||
|
return true;
|
||||||
|
if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes")
|
||||||
|
{
|
||||||
|
fail_msg_writer() << tr("transaction cancelled.");
|
||||||
|
|
||||||
|
// would like to return false, because no tx made, but everything else returns true
|
||||||
|
// and I don't know what returning false might adversely affect. *sigh*
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// figure out what tx will be necessary
|
// figure out what tx will be necessary
|
||||||
|
@ -2802,6 +2864,23 @@ bool simple_wallet::sweep_all(const std::vector<std::string> &args_)
|
||||||
fail_msg_writer() << tr("failed to set up payment id, though it was decoded correctly");
|
fail_msg_writer() << tr("failed to set up payment id, though it was decoded correctly");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
payment_id_seen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prompt is there is no payment id and confirmation is required
|
||||||
|
if (!payment_id_seen && m_wallet->confirm_missing_payment_id())
|
||||||
|
{
|
||||||
|
std::string accepted = command_line::input_line(tr("No payment id is included with this transaction. Is this okay? (Y/Yes/N/No)"));
|
||||||
|
if (std::cin.eof())
|
||||||
|
return true;
|
||||||
|
if (accepted != "Y" && accepted != "y" && accepted != "Yes" && accepted != "yes")
|
||||||
|
{
|
||||||
|
fail_msg_writer() << tr("transaction cancelled.");
|
||||||
|
|
||||||
|
// would like to return false, because no tx made, but everything else returns true
|
||||||
|
// and I don't know what returning false might adversely affect. *sigh*
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -110,6 +110,7 @@ namespace cryptonote
|
||||||
bool set_default_mixin(const std::vector<std::string> &args = std::vector<std::string>());
|
bool set_default_mixin(const std::vector<std::string> &args = std::vector<std::string>());
|
||||||
bool set_auto_refresh(const std::vector<std::string> &args = std::vector<std::string>());
|
bool set_auto_refresh(const std::vector<std::string> &args = std::vector<std::string>());
|
||||||
bool set_refresh_type(const std::vector<std::string> &args = std::vector<std::string>());
|
bool set_refresh_type(const std::vector<std::string> &args = std::vector<std::string>());
|
||||||
|
bool set_confirm_missing_payment_id(const std::vector<std::string> &args = std::vector<std::string>());
|
||||||
bool help(const std::vector<std::string> &args = std::vector<std::string>());
|
bool help(const std::vector<std::string> &args = std::vector<std::string>());
|
||||||
bool start_mining(const std::vector<std::string> &args);
|
bool start_mining(const std::vector<std::string> &args);
|
||||||
bool stop_mining(const std::vector<std::string> &args);
|
bool stop_mining(const std::vector<std::string> &args);
|
||||||
|
|
|
@ -1419,6 +1419,9 @@ bool wallet2::store_keys(const std::string& keys_file_name, const std::string& p
|
||||||
value2.SetUint64(m_refresh_from_block_height);
|
value2.SetUint64(m_refresh_from_block_height);
|
||||||
json.AddMember("refresh_height", value2, json.GetAllocator());
|
json.AddMember("refresh_height", value2, json.GetAllocator());
|
||||||
|
|
||||||
|
value2.SetInt(m_confirm_missing_payment_id ? 1 :0);
|
||||||
|
json.AddMember("confirm_missing_payment_id", value2, json.GetAllocator());
|
||||||
|
|
||||||
// Serialize the JSON object
|
// Serialize the JSON object
|
||||||
rapidjson::StringBuffer buffer;
|
rapidjson::StringBuffer buffer;
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
||||||
|
@ -1484,6 +1487,7 @@ bool wallet2::load_keys(const std::string& keys_file_name, const std::string& pa
|
||||||
m_default_priority = 0;
|
m_default_priority = 0;
|
||||||
m_auto_refresh = true;
|
m_auto_refresh = true;
|
||||||
m_refresh_type = RefreshType::RefreshDefault;
|
m_refresh_type = RefreshType::RefreshDefault;
|
||||||
|
m_confirm_missing_payment_id = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1541,6 +1545,8 @@ bool wallet2::load_keys(const std::string& keys_file_name, const std::string& pa
|
||||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, refresh_height, uint64_t, Uint64, false, 0);
|
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, refresh_height, uint64_t, Uint64, false, 0);
|
||||||
if (field_refresh_height_found)
|
if (field_refresh_height_found)
|
||||||
m_refresh_from_block_height = field_refresh_height;
|
m_refresh_from_block_height = field_refresh_height;
|
||||||
|
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, confirm_missing_payment_id, int, Int, false, false);
|
||||||
|
m_confirm_missing_payment_id = !field_confirm_missing_payment_id_found || field_confirm_missing_payment_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cryptonote::account_keys& keys = m_account.get_keys();
|
const cryptonote::account_keys& keys = m_account.get_keys();
|
||||||
|
|
|
@ -92,10 +92,10 @@ namespace tools
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wallet2(const wallet2&) : m_run(true), m_callback(0), m_testnet(false), m_always_confirm_transfers (false), m_store_tx_info(true), m_default_mixin(0), m_default_priority(0), m_refresh_type(RefreshOptimizeCoinbase), m_auto_refresh(true), m_refresh_from_block_height(0) {}
|
wallet2(const wallet2&) : m_run(true), m_callback(0), m_testnet(false), m_always_confirm_transfers (false), m_store_tx_info(true), m_default_mixin(0), m_default_priority(0), m_refresh_type(RefreshOptimizeCoinbase), m_auto_refresh(true), m_refresh_from_block_height(0), m_confirm_missing_payment_id(true) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wallet2(bool testnet = false, bool restricted = false) : m_run(true), m_callback(0), m_testnet(testnet), m_restricted(restricted), is_old_file_format(false), m_store_tx_info(true), m_default_mixin(0), m_default_priority(0), m_refresh_type(RefreshOptimizeCoinbase), m_auto_refresh(true), m_refresh_from_block_height(0) {}
|
wallet2(bool testnet = false, bool restricted = false) : m_run(true), m_callback(0), m_testnet(testnet), m_restricted(restricted), is_old_file_format(false), m_store_tx_info(true), m_default_mixin(0), m_default_priority(0), m_refresh_type(RefreshOptimizeCoinbase), m_auto_refresh(true), m_refresh_from_block_height(0), m_confirm_missing_payment_id(true) {}
|
||||||
struct transfer_details
|
struct transfer_details
|
||||||
{
|
{
|
||||||
uint64_t m_block_height;
|
uint64_t m_block_height;
|
||||||
|
@ -442,6 +442,8 @@ namespace tools
|
||||||
void set_default_priority(uint32_t p) { m_default_priority = p; }
|
void set_default_priority(uint32_t p) { m_default_priority = p; }
|
||||||
bool auto_refresh() const { return m_auto_refresh; }
|
bool auto_refresh() const { return m_auto_refresh; }
|
||||||
void auto_refresh(bool r) { m_auto_refresh = r; }
|
void auto_refresh(bool r) { m_auto_refresh = r; }
|
||||||
|
bool confirm_missing_payment_id() const { return m_confirm_missing_payment_id; }
|
||||||
|
void confirm_missing_payment_id(bool always) { m_confirm_missing_payment_id = always; }
|
||||||
|
|
||||||
bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key) const;
|
bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key) const;
|
||||||
|
|
||||||
|
@ -556,6 +558,7 @@ namespace tools
|
||||||
RefreshType m_refresh_type;
|
RefreshType m_refresh_type;
|
||||||
bool m_auto_refresh;
|
bool m_auto_refresh;
|
||||||
uint64_t m_refresh_from_block_height;
|
uint64_t m_refresh_from_block_height;
|
||||||
|
bool m_confirm_missing_payment_id;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
BOOST_CLASS_VERSION(tools::wallet2, 14)
|
BOOST_CLASS_VERSION(tools::wallet2, 14)
|
||||||
|
|
Loading…
Reference in a new issue