diff options
author | Alexander Blair <snipa@jagtech.io> | 2020-08-27 02:58:22 -0700 |
---|---|---|
committer | Alexander Blair <snipa@jagtech.io> | 2020-08-27 02:58:23 -0700 |
commit | a06c83db73977ec8f5e1457d667761f95d9fdd93 (patch) | |
tree | f66b7adf7c433840ccb3568a83834491a65dc78d /src/simplewallet/simplewallet.cpp | |
parent | Merge pull request #6731 (diff) | |
parent | simplewallet: allow setting tx keys when sending to a subaddress (diff) | |
download | monero-a06c83db73977ec8f5e1457d667761f95d9fdd93.tar.xz |
Merge pull request #6752
85899230d simplewallet: allow setting tx keys when sending to a subaddress (moneromooo-monero)
e916201f1 wallet2: fix setting tx keys when another is already set (moneromooo-monero)
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index bbf303ea5..02540a844 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -208,7 +208,7 @@ namespace const char* USAGE_ADDRESS_BOOK("address_book [(add (<address>|<integrated address>) [<description possibly with whitespaces>])|(delete <index>)]"); const char* USAGE_SET_VARIABLE("set <option> [<value>]"); const char* USAGE_GET_TX_KEY("get_tx_key <txid>"); - const char* USAGE_SET_TX_KEY("set_tx_key <txid> <tx_key>"); + const char* USAGE_SET_TX_KEY("set_tx_key <txid> <tx_key> [<subaddress>]"); const char* USAGE_CHECK_TX_KEY("check_tx_key <txid> <txkey> <address>"); const char* USAGE_GET_TX_PROOF("get_tx_proof <txid> <address> [<message>]"); const char* USAGE_CHECK_TX_PROOF("check_tx_proof <txid> <address> <signature_file> [<message>]"); @@ -7963,11 +7963,27 @@ bool simple_wallet::set_tx_key(const std::vector<std::string> &args_) { std::vector<std::string> local_args = args_; - if(local_args.size() != 2) { + if(local_args.size() != 2 && local_args.size() != 3) { PRINT_USAGE(USAGE_SET_TX_KEY); return true; } + boost::optional<cryptonote::account_public_address> single_destination_subaddress; + if (local_args.size() > 1) + { + cryptonote::address_parse_info info; + if (cryptonote::get_account_address_from_str_or_url(info, m_wallet->nettype(), local_args.back(), oa_prompter)) + { + if (!info.is_subaddress) + { + fail_msg_writer() << tr("Last argument is an address, but not a subaddress"); + return true; + } + single_destination_subaddress = info.address; + local_args.pop_back(); + } + } + crypto::hash txid; if (!epee::string_tools::hex_to_pod(local_args[0], txid)) { @@ -8007,12 +8023,14 @@ bool simple_wallet::set_tx_key(const std::vector<std::string> &args_) try { - m_wallet->set_tx_key(txid, tx_key, additional_tx_keys); + m_wallet->set_tx_key(txid, tx_key, additional_tx_keys, single_destination_subaddress); success_msg_writer() << tr("Tx key successfully stored."); } catch (const std::exception &e) { fail_msg_writer() << tr("Failed to store tx key: ") << e.what(); + if (!single_destination_subaddress) + fail_msg_writer() << tr("It could be because the transfer was to a subaddress. If this is the case, pass the subaddress last"); } return true; } |