Changeset View
Changeset View
Standalone View
Standalone View
src/bitcoin-cli.cpp
Show First 20 Lines • Show All 533 Lines • ▼ Show 20 Lines | try { | ||||
if (!StdinReady()) { | if (!StdinReady()) { | ||||
fputs("RPC password> ", stderr); | fputs("RPC password> ", stderr); | ||||
fflush(stderr); | fflush(stderr); | ||||
} | } | ||||
if (!std::getline(std::cin, rpcPass)) { | if (!std::getline(std::cin, rpcPass)) { | ||||
throw std::runtime_error("-stdinrpcpass specified but failed " | throw std::runtime_error("-stdinrpcpass specified but failed " | ||||
"to read from standard input"); | "to read from standard input"); | ||||
} | } | ||||
if (StdinTerminal()) { | |||||
fputc('\n', stdout); | |||||
} | |||||
gArgs.ForceSetArg("-rpcpassword", rpcPass); | gArgs.ForceSetArg("-rpcpassword", rpcPass); | ||||
} | } | ||||
std::vector<std::string> args = | std::vector<std::string> args = | ||||
std::vector<std::string>(&argv[1], &argv[argc]); | std::vector<std::string>(&argv[1], &argv[argc]); | ||||
if (gArgs.GetBoolArg("-stdinwalletpassphrase", false)) { | if (gArgs.GetBoolArg("-stdinwalletpassphrase", false)) { | ||||
NO_STDIN_ECHO(); | NO_STDIN_ECHO(); | ||||
std::string walletPass; | std::string walletPass; | ||||
if (args.size() < 1 || | if (args.size() < 1 || | ||||
args[0].substr(0, 16) != "walletpassphrase") { | args[0].substr(0, 16) != "walletpassphrase") { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"-stdinwalletpassphrase is only applicable for " | "-stdinwalletpassphrase is only applicable for " | ||||
"walletpassphrase(change)"); | "walletpassphrase(change)"); | ||||
} | } | ||||
if (!StdinReady()) { | if (!StdinReady()) { | ||||
fputs("Wallet passphrase> ", stderr); | fputs("Wallet passphrase> ", stderr); | ||||
fflush(stderr); | fflush(stderr); | ||||
} | } | ||||
if (!std::getline(std::cin, walletPass)) { | if (!std::getline(std::cin, walletPass)) { | ||||
throw std::runtime_error("-stdinwalletpassphrase specified but " | throw std::runtime_error("-stdinwalletpassphrase specified but " | ||||
"failed to read from standard input"); | "failed to read from standard input"); | ||||
} | } | ||||
if (StdinTerminal()) { | |||||
fputc('\n', stdout); | |||||
} | |||||
args.insert(args.begin() + 1, walletPass); | args.insert(args.begin() + 1, walletPass); | ||||
} | } | ||||
if (gArgs.GetBoolArg("-stdin", false)) { | if (gArgs.GetBoolArg("-stdin", false)) { | ||||
// Read one arg per line from stdin and append | // Read one arg per line from stdin and append | ||||
std::string line; | std::string line; | ||||
while (std::getline(std::cin, line)) { | while (std::getline(std::cin, line)) { | ||||
args.push_back(line); | args.push_back(line); | ||||
} | } | ||||
if (StdinTerminal()) { | |||||
fputc('\n', stdout); | |||||
} | |||||
} | } | ||||
std::unique_ptr<BaseRequestHandler> rh; | std::unique_ptr<BaseRequestHandler> rh; | ||||
std::string method; | std::string method; | ||||
if (gArgs.GetBoolArg("-getinfo", false)) { | if (gArgs.GetBoolArg("-getinfo", false)) { | ||||
rh.reset(new GetinfoRequestHandler()); | rh.reset(new GetinfoRequestHandler()); | ||||
method = ""; | method = ""; | ||||
} else { | } else { | ||||
rh.reset(new DefaultRequestHandler()); | rh.reset(new DefaultRequestHandler()); | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |