mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-11 23:58:18 +00:00
Merge #7550: rpc: Input-from-stdin mode for bitcoin-cli
f22f14c
doc: mention bitcoin-cli -stdin in release notes (Wladimir J. van der Laan)92bcca3
rpc: Input-from-stdin mode for bitcoin-cli (Wladimir J. van der Laan)
This commit is contained in:
commit
8b958ab15b
@ -8,6 +8,19 @@ Example item
|
|||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
|
||||||
|
bitcoin-cli: arguments privacy
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
The RPC command line client gained a new argument, `-stdin`
|
||||||
|
to read extra arguments from standard input, one per line until EOF/Ctrl-D.
|
||||||
|
For example:
|
||||||
|
|
||||||
|
$ echo -e "mysecretcode\n120" | src/bitcoin-cli -stdin walletpassphrase
|
||||||
|
|
||||||
|
It is recommended to use this for sensitive information such as wallet
|
||||||
|
passphrases, as command-line arguments can usually be read from the process
|
||||||
|
table by any user on the system.
|
||||||
|
|
||||||
0.13.0 Change log
|
0.13.0 Change log
|
||||||
=================
|
=================
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ std::string HelpMessageCli()
|
|||||||
strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections"));
|
strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections"));
|
||||||
strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
|
strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
|
||||||
strUsage += HelpMessageOpt("-rpcclienttimeout=<n>", strprintf(_("Timeout during HTTP requests (default: %d)"), DEFAULT_HTTP_CLIENT_TIMEOUT));
|
strUsage += HelpMessageOpt("-rpcclienttimeout=<n>", strprintf(_("Timeout during HTTP requests (default: %d)"), DEFAULT_HTTP_CLIENT_TIMEOUT));
|
||||||
|
strUsage += HelpMessageOpt("-stdin", _("Read extra arguments from standard input, one per line until EOF/Ctrl-D (recommended for sensitive information such as passphrases)"));
|
||||||
|
|
||||||
return strUsage;
|
return strUsage;
|
||||||
}
|
}
|
||||||
@ -232,15 +233,17 @@ int CommandLineRPC(int argc, char *argv[])
|
|||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
|
std::vector<std::string> args = std::vector<std::string>(&argv[1], &argv[argc]);
|
||||||
// Method
|
if (GetBoolArg("-stdin", false)) {
|
||||||
if (argc < 2)
|
// Read one arg per line from stdin and append
|
||||||
throw runtime_error("too few parameters");
|
std::string line;
|
||||||
string strMethod = argv[1];
|
while (std::getline(std::cin,line))
|
||||||
|
args.push_back(line);
|
||||||
// Parameters default to strings
|
}
|
||||||
std::vector<std::string> strParams(&argv[2], &argv[argc]);
|
if (args.size() < 1)
|
||||||
UniValue params = RPCConvertValues(strMethod, strParams);
|
throw runtime_error("too few parameters (need at least command)");
|
||||||
|
std::string strMethod = args[0];
|
||||||
|
UniValue params = RPCConvertValues(strMethod, std::vector<std::string>(args.begin()+1, args.end()));
|
||||||
|
|
||||||
// Execute and handle connection failures with -rpcwait
|
// Execute and handle connection failures with -rpcwait
|
||||||
const bool fWait = GetBoolArg("-rpcwait", false);
|
const bool fWait = GetBoolArg("-rpcwait", false);
|
||||||
|
Loading…
Reference in New Issue
Block a user