wallet: add password command
Also tweak wallet2 password code to verify password without saying it's a new wallet, because it's assuming things.
This commit is contained in:
parent
4728ab977a
commit
4b48565c9e
@ -380,8 +380,8 @@ bool simple_wallet::change_password(const std::vector<std::string> &args)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// prompts for a new password, this is not a new wallet so pass in false.
|
// prompts for a new password, pass true to verify the password
|
||||||
const auto pwd_container = tools::wallet2::password_prompt(false);
|
const auto pwd_container = tools::wallet2::password_prompt(true);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -676,6 +676,7 @@ simple_wallet::simple_wallet()
|
|||||||
m_cmd_binder.set_handler("export_outputs", boost::bind(&simple_wallet::export_outputs, this, _1), tr("Export a set of outputs owned by this wallet"));
|
m_cmd_binder.set_handler("export_outputs", boost::bind(&simple_wallet::export_outputs, this, _1), tr("Export a set of outputs owned by this wallet"));
|
||||||
m_cmd_binder.set_handler("import_outputs", boost::bind(&simple_wallet::import_outputs, this, _1), tr("Import set of outputs owned by this wallet"));
|
m_cmd_binder.set_handler("import_outputs", boost::bind(&simple_wallet::import_outputs, this, _1), tr("Import set of outputs owned by this wallet"));
|
||||||
m_cmd_binder.set_handler("show_transfer", boost::bind(&simple_wallet::show_transfer, this, _1), tr("Show information about a transfer to/from this address"));
|
m_cmd_binder.set_handler("show_transfer", boost::bind(&simple_wallet::show_transfer, this, _1), tr("Show information about a transfer to/from this address"));
|
||||||
|
m_cmd_binder.set_handler("password", boost::bind(&simple_wallet::change_password, this, _1), tr("Change wallet password"));
|
||||||
m_cmd_binder.set_handler("help", boost::bind(&simple_wallet::help, this, _1), tr("Show this help"));
|
m_cmd_binder.set_handler("help", boost::bind(&simple_wallet::help, this, _1), tr("Show this help"));
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
@ -452,10 +452,10 @@ void wallet2::init_options(boost::program_options::options_description& desc_par
|
|||||||
command_line::add_arg(desc_params, opts.restricted);
|
command_line::add_arg(desc_params, opts.restricted);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<password_container> wallet2::password_prompt(const bool is_new_wallet)
|
boost::optional<password_container> wallet2::password_prompt(const bool new_password)
|
||||||
{
|
{
|
||||||
auto pwd_container = tools::password_container::prompt(
|
auto pwd_container = tools::password_container::prompt(
|
||||||
is_new_wallet, (is_new_wallet ? tr("Enter a password for your new wallet") : tr("Wallet password"))
|
new_password, (new_password ? tr("Enter new wallet password") : tr("Wallet password"))
|
||||||
);
|
);
|
||||||
if (!pwd_container)
|
if (!pwd_container)
|
||||||
{
|
{
|
||||||
|
@ -114,7 +114,7 @@ namespace tools
|
|||||||
static void init_options(boost::program_options::options_description& desc_params);
|
static void init_options(boost::program_options::options_description& desc_params);
|
||||||
|
|
||||||
//! \return Password retrieved from prompt. Logs error on failure.
|
//! \return Password retrieved from prompt. Logs error on failure.
|
||||||
static boost::optional<password_container> password_prompt(const bool is_new_wallet);
|
static boost::optional<password_container> password_prompt(const bool new_password);
|
||||||
|
|
||||||
//! Uses stdin and stdout. Returns a wallet2 if no errors.
|
//! Uses stdin and stdout. Returns a wallet2 if no errors.
|
||||||
static std::unique_ptr<wallet2> make_from_json(const boost::program_options::variables_map& vm, const std::string& json_file);
|
static std::unique_ptr<wallet2> make_from_json(const boost::program_options::variables_map& vm, const std::string& json_file);
|
||||||
|
Loading…
Reference in New Issue
Block a user