diff options
Diffstat (limited to 'src/wallet/wallet_rpc_server.cpp')
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 81e26c120..c9a840005 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -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"; |