aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet_rpc_server.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-10-28 19:13:42 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-11-14 17:06:26 +0000
commite89994e98f85be95d68c7bf471fcadf9aabbc93a (patch)
tree2cb9f29bc15e4488eeaeee81115d791babced4fc /src/wallet/wallet_rpc_server.cpp
parentmove input_line from command_line to simplewallet (diff)
downloadmonero-e89994e98f85be95d68c7bf471fcadf9aabbc93a.tar.xz
wallet: rejig to avoid prompting in wallet2
wallet2 is a library, and should not prompt for stdin. Instead, pass a function so simplewallet can prompt on stdin, and a GUI might display a window, etc.
Diffstat (limited to '')
-rw-r--r--src/wallet/wallet_rpc_server.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index fda8f244a..9dc2baea6 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -60,6 +60,16 @@ namespace
const command_line::arg_descriptor<std::string> arg_wallet_dir = {"wallet-dir", "Directory for newly created wallets"};
constexpr const char default_rpc_username[] = "monero";
+
+ boost::optional<tools::password_container> password_prompter(const char *prompt, bool verify)
+ {
+ auto pwd_container = tools::password_container::prompt(verify, prompt);
+ if (!pwd_container)
+ {
+ MERROR("failed to read wallet password");
+ }
+ return pwd_container;
+ }
}
namespace tools
@@ -131,7 +141,7 @@ namespace tools
walvars = m_wallet;
else
{
- tmpwal = tools::wallet2::make_dummy(*m_vm);
+ tmpwal = tools::wallet2::make_dummy(*m_vm, password_prompter);
walvars = tmpwal.get();
}
boost::optional<epee::net_utils::http::login> http_login{};
@@ -1798,7 +1808,7 @@ namespace tools
command_line::add_arg(desc, arg_password);
po::store(po::parse_command_line(argc, argv, desc), vm2);
}
- std::unique_ptr<tools::wallet2> wal = tools::wallet2::make_new(vm2).first;
+ std::unique_ptr<tools::wallet2> wal = tools::wallet2::make_new(vm2, password_prompter).first;
if (!wal)
{
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
@@ -1872,7 +1882,7 @@ namespace tools
}
std::unique_ptr<tools::wallet2> wal = nullptr;
try {
- wal = tools::wallet2::make_from_file(vm2, wallet_file).first;
+ wal = tools::wallet2::make_from_file(vm2, wallet_file, password_prompter).first;
}
catch (const std::exception& e)
{
@@ -2007,11 +2017,11 @@ int main(int argc, char** argv) {
LOG_PRINT_L0(tools::wallet_rpc_server::tr("Loading wallet..."));
if(!wallet_file.empty())
{
- wal = tools::wallet2::make_from_file(*vm, wallet_file).first;
+ wal = tools::wallet2::make_from_file(*vm, wallet_file, password_prompter).first;
}
else
{
- wal = tools::wallet2::make_from_json(*vm, from_json);
+ wal = tools::wallet2::make_from_json(*vm, from_json, password_prompter);
}
if (!wal)
{