Skip to content

Commit

Permalink
cli: enter encryptwallet password from stdin. fixes #15318
Browse files Browse the repository at this point in the history
  • Loading branch information
darosior committed Feb 5, 2019
1 parent fc21bb4 commit 20816de
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/bitcoin-cli.cpp
Expand Up @@ -441,6 +441,19 @@ static int CommandLineRPC(int argc, char *argv[])
method = args[0];
args.erase(args.begin()); // Remove trailing method name from arguments vector
}
// Get wallet encryption password from command line
if (method == "encryptwallet" && !args.size()) {
std::string password, verification;
fprintf(stdout, "Enter password to encrypt the wallet : ");
if(!std::getline(std::cin, password)) {
throw std::runtime_error("Failed to read password");
}
fprintf(stdout, "Re-enter password : ");
if(!std::getline(std::cin, verification) || password != verification) {
throw std::runtime_error("Passwords do not match");
}
args.push_back(password);
}

// Execute and handle connection failures with -rpcwait
const bool fWait = gArgs.GetBoolArg("-rpcwait", false);
Expand Down

0 comments on commit 20816de

Please sign in to comment.