mirror of
https://github.com/monero-project/monero.git
synced 2025-08-18 05:30:22 -04:00
Merge pull request #4188
a3fe1c5
simplewallet: add set_tx_key for importing tx keys from 3rd party wallets (stoffu)
This commit is contained in:
commit
8d2e454929
4 changed files with 112 additions and 0 deletions
|
@ -2303,6 +2303,10 @@ simple_wallet::simple_wallet()
|
|||
boost::bind(&simple_wallet::get_tx_key, this, _1),
|
||||
tr("get_tx_key <txid>"),
|
||||
tr("Get the transaction key (r) for a given <txid>."));
|
||||
m_cmd_binder.set_handler("set_tx_key",
|
||||
boost::bind(&simple_wallet::set_tx_key, this, _1),
|
||||
tr("set_tx_key <txid> <tx_key>"),
|
||||
tr("Set the transaction key (r) for a given <txid> in case the tx was made by some other device or 3rd party wallet."));
|
||||
m_cmd_binder.set_handler("check_tx_key",
|
||||
boost::bind(&simple_wallet::check_tx_key, this, _1),
|
||||
tr("check_tx_key <txid> <txkey> <address>"),
|
||||
|
@ -5831,6 +5835,64 @@ bool simple_wallet::get_tx_key(const std::vector<std::string> &args_)
|
|||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::set_tx_key(const std::vector<std::string> &args_)
|
||||
{
|
||||
std::vector<std::string> local_args = args_;
|
||||
|
||||
if(local_args.size() != 2) {
|
||||
fail_msg_writer() << tr("usage: set_tx_key <txid> <tx_key>");
|
||||
return true;
|
||||
}
|
||||
|
||||
crypto::hash txid;
|
||||
if (!epee::string_tools::hex_to_pod(local_args[0], txid))
|
||||
{
|
||||
fail_msg_writer() << tr("failed to parse txid");
|
||||
return true;
|
||||
}
|
||||
|
||||
crypto::secret_key tx_key;
|
||||
std::vector<crypto::secret_key> additional_tx_keys;
|
||||
try
|
||||
{
|
||||
if (!epee::string_tools::hex_to_pod(local_args[1].substr(0, 64), tx_key))
|
||||
{
|
||||
fail_msg_writer() << tr("failed to parse tx_key");
|
||||
return true;
|
||||
}
|
||||
while(true)
|
||||
{
|
||||
local_args[1] = local_args[1].substr(64);
|
||||
if (local_args[1].empty())
|
||||
break;
|
||||
additional_tx_keys.resize(additional_tx_keys.size() + 1);
|
||||
if (!epee::string_tools::hex_to_pod(local_args[1].substr(0, 64), additional_tx_keys.back()))
|
||||
{
|
||||
fail_msg_writer() << tr("failed to parse tx_key");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::out_of_range &e)
|
||||
{
|
||||
fail_msg_writer() << tr("failed to parse tx_key");
|
||||
return true;
|
||||
}
|
||||
|
||||
LOCK_IDLE_SCOPE();
|
||||
|
||||
try
|
||||
{
|
||||
m_wallet->set_tx_key(txid, tx_key, additional_tx_keys);
|
||||
success_msg_writer() << tr("Tx key successfully stored.");
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
fail_msg_writer() << tr("Failed to store tx key: ") << e.what();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::get_tx_proof(const std::vector<std::string> &args)
|
||||
{
|
||||
if (m_wallet->key_on_device())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue