mirror of
https://github.com/monero-project/monero.git
synced 2025-08-08 16:02:18 -04:00
wallet-rpc: restore from multisig seed
This commit is contained in:
parent
94e67bf96b
commit
45b52de28e
7 changed files with 217 additions and 35 deletions
|
@ -3807,7 +3807,7 @@ namespace tools
|
|||
std::string old_language;
|
||||
|
||||
// check the given seed
|
||||
{
|
||||
if (!req.enable_multisig_experimental) {
|
||||
if (!crypto::ElectrumWords::words_to_bytes(req.seed, recovery_key, old_language))
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
|
@ -3830,6 +3830,13 @@ namespace tools
|
|||
|
||||
// process seed_offset if given
|
||||
{
|
||||
if (req.enable_multisig_experimental && !req.seed_offset.empty())
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = "Multisig seeds are not compatible with seed offsets";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!req.seed_offset.empty())
|
||||
{
|
||||
recovery_key = cryptonote::decrypt_key(recovery_key, req.seed_offset);
|
||||
|
@ -3893,7 +3900,27 @@ namespace tools
|
|||
crypto::secret_key recovery_val;
|
||||
try
|
||||
{
|
||||
recovery_val = wal->generate(wallet_file, std::move(rc.second).password(), recovery_key, true, false, false);
|
||||
if (req.enable_multisig_experimental)
|
||||
{
|
||||
// Parse multisig seed into raw multisig data
|
||||
epee::wipeable_string multisig_data;
|
||||
multisig_data.resize(req.seed.size() / 2);
|
||||
if (!epee::from_hex::to_buffer(epee::to_mut_byte_span(multisig_data), req.seed))
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = "Multisig seed not represented as hexadecimal string";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Generate multisig wallet
|
||||
wal->generate(wallet_file, std::move(rc.second).password(), multisig_data, false);
|
||||
wal->enable_multisig(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Generate normal wallet
|
||||
recovery_val = wal->generate(wallet_file, std::move(rc.second).password(), recovery_key, true, false, false);
|
||||
}
|
||||
MINFO("Wallet has been restored.\n");
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
|
@ -3904,7 +3931,7 @@ namespace tools
|
|||
|
||||
// // Convert the secret key back to seed
|
||||
epee::wipeable_string electrum_words;
|
||||
if (!crypto::ElectrumWords::bytes_to_words(recovery_val, electrum_words, mnemonic_language))
|
||||
if (!req.enable_multisig_experimental && !crypto::ElectrumWords::bytes_to_words(recovery_val, electrum_words, mnemonic_language))
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = "Failed to encode seed";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue