aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r--src/wallet/wallet2.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index db4fae557..712f08adc 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -174,9 +174,7 @@ boost::optional<tools::password_container> get_password(const boost::program_opt
if (command_line::has_arg(vm, opts.password))
{
- tools::password_container pwd(false);
- pwd.password(command_line::get_arg(vm, opts.password));
- return {std::move(pwd)};
+ return tools::password_container{command_line::get_arg(vm, opts.password)};
}
if (command_line::has_arg(vm, opts.password_file))
@@ -192,19 +190,10 @@ boost::optional<tools::password_container> get_password(const boost::program_opt
// Remove line breaks the user might have inserted
boost::trim_right_if(password, boost::is_any_of("\r\n"));
- return {tools::password_container(std::move(password))};
+ return {tools::password_container{std::move(password)}};
}
- //vm is already part of the password container class. just need to check vm for an already existing wallet
- //here need to pass in variable map. This will indicate if the wallet already exists to the read password function
- tools::password_container pwd(verify);
- if (pwd.read_password())
- {
- return {std::move(pwd)};
- }
-
- tools::fail_msg_writer() << tools::wallet2::tr("failed to read wallet password");
- return boost::none;
+ return tools::wallet2::password_prompt(verify);
}
std::unique_ptr<tools::wallet2> generate_from_json(const std::string& json_file, bool testnet, bool restricted)
@@ -431,6 +420,18 @@ void wallet2::init_options(boost::program_options::options_description& desc_par
command_line::add_arg(desc_params, opts.restricted);
}
+boost::optional<password_container> wallet2::password_prompt(const bool is_new_wallet)
+{
+ auto pwd_container = tools::password_container::prompt(
+ is_new_wallet, (is_new_wallet ? tr("Enter a password for your new wallet") : tr("Wallet password"))
+ );
+ if (!pwd_container)
+ {
+ tools::fail_msg_writer() << tr("failed to read wallet password");
+ }
+ return pwd_container;
+}
+
std::unique_ptr<wallet2> wallet2::make_from_json(const boost::program_options::variables_map& vm, const std::string& json_file)
{
const options opts{};
@@ -444,7 +445,7 @@ std::pair<std::unique_ptr<wallet2>, password_container> wallet2::make_from_file(
auto pwd = get_password(vm, opts, false);
if (!pwd)
{
- return {nullptr, password_container(false)};
+ return {nullptr, password_container{}};
}
auto wallet = make_basic(vm, opts);
if (wallet)
@@ -460,7 +461,7 @@ std::pair<std::unique_ptr<wallet2>, password_container> wallet2::make_new(const
auto pwd = get_password(vm, opts, true);
if (!pwd)
{
- return {nullptr, password_container(false)};
+ return {nullptr, password_container{}};
}
return {make_basic(vm, opts), std::move(*pwd)};
}