diff --git a/rai/node/cli.cpp b/rai/node/cli.cpp index 7f4a57e0..307ef62d 100644 --- a/rai/node/cli.cpp +++ b/rai/node/cli.cpp @@ -51,7 +51,8 @@ void rai::add_node_options (boost::program_options::options_description & descri ("file", boost::program_options::value (), "Defines for other commands") ("key", boost::program_options::value (), "Defines the for other commands, hex") ("password", boost::program_options::value (), "Defines for other commands") - ("wallet", boost::program_options::value (), "Defines for other commands"); + ("wallet", boost::program_options::value (), "Defines for other commands") + ("force", boost::program_options::value(), "Bool to force command if allowed"); // clang-format on } @@ -525,6 +526,7 @@ std::error_code rai::handle_node_options (boost::program_options::variables_map { if (vm.count ("file") == 1) { + bool forced (false); std::string filename (vm["file"].as ()); std::ifstream stream; stream.open (filename.c_str ()); @@ -537,6 +539,10 @@ std::error_code rai::handle_node_options (boost::program_options::variables_map { password = vm["password"].as (); } + if (vm.count ("force") == 1) + { + forced = vm["force"].as (); + } if (vm.count ("wallet") == 1) { rai::uint256_union wallet_id; @@ -554,8 +560,21 @@ std::error_code rai::handle_node_options (boost::program_options::variables_map } else { - std::cerr << "Wallet doesn't exist\n"; - ec = rai::error_cli::invalid_arguments; + if (!forced) + { + std::cerr << "Wallet doesn't exist\n"; + ec = rai::error_cli::invalid_arguments; + } + else + { + node.node->wallets.create (wallet_id); + auto existing (node.node->wallets.items.find (wallet_id)); + if (existing->second->import (contents.str (), password)) + { + std::cerr << "Unable to import wallet\n"; + ec = rai::error_cli::invalid_arguments; + } + } } } else