5 #include <bitcoin-build-config.h> 12 #ifdef ENABLE_EXTERNAL_SIGNER 14 #endif // ENABLE_EXTERNAL_SIGNER 18 #ifdef ENABLE_EXTERNAL_SIGNER 22 std::istringstream stdout_stream;
23 std::istringstream stderr_stream;
28 if (!str_std_in.empty()) {
31 auto [out_res, err_res] = c.communicate();
32 stdout_stream.str(std::string{out_res.buf.begin(), out_res.buf.end()});
33 stderr_stream.str(std::string{err_res.buf.begin(), err_res.buf.end()});
37 std::getline(stdout_stream,
result);
38 std::getline(stderr_stream, error);
40 const int n_error = c.retcode();
41 if (n_error)
throw std::runtime_error(
strprintf(
"RunCommandParseJSON error: process(%s) returned %d: %s\n", str_command, n_error, error));
42 if (!result_json.
read(
result))
throw std::runtime_error(
"Unable to parse JSON: " +
result);
46 throw std::runtime_error(
"Compiled without external signing support (required for external signing).");
47 #endif // ENABLE_EXTERNAL_SIGNER
bool read(std::string_view raw)
UniValue RunCommandParseJSON(const std::string &str_command, const std::string &str_std_in)
Execute a command which returns JSON, and parse the result.