aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet_rpc_server.cpp
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2023-08-17 10:20:20 -0500
committerluigi1111 <luigi1111w@gmail.com>2023-08-17 10:20:20 -0500
commit3b67d5fc5b8d91e4def0f7b3d63228caf1d29881 (patch)
tree7670a786eff91efcc05eceb22e7c01a1fcda67d7 /src/wallet/wallet_rpc_server.cpp
parentMerge pull request #8913 (diff)
parentwallet-rpc: restore from multisig seed (diff)
downloadmonero-3b67d5fc5b8d91e4def0f7b3d63228caf1d29881.tar.xz
Merge pull request #8914
45b52de wallet-rpc: restore from multisig seed (jeffro256)
Diffstat (limited to 'src/wallet/wallet_rpc_server.cpp')
-rw-r--r--src/wallet/wallet_rpc_server.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index 7c46d9887..0cc42ae3f 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -3811,7 +3811,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;
@@ -3834,6 +3834,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);
@@ -3897,7 +3904,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)
@@ -3908,7 +3935,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";