5 #if defined(HAVE_CONFIG_H)
14 #ifdef ENABLE_EXTERNAL_SIGNER
15 #include <boost/process.hpp>
20 #ifdef ENABLE_EXTERNAL_SIGNER
21 namespace bp = boost::process;
24 bp::opstream stdin_stream;
25 bp::ipstream stdout_stream;
26 bp::ipstream stderr_stream;
32 bp::std_out > stdout_stream,
33 bp::std_err > stderr_stream,
34 bp::std_in < stdin_stream
36 if (!str_std_in.empty()) {
37 stdin_stream << str_std_in << std::endl;
39 stdin_stream.pipe().close();
43 std::getline(stdout_stream, result);
44 std::getline(stderr_stream,
error);
47 const int n_error = c.exit_code();
48 if (n_error)
throw std::runtime_error(
strprintf(
"RunCommandParseJSON error: process(%s) returned %d: %s\n", str_command, n_error,
error));
49 if (!result_json.
read(result))
throw std::runtime_error(
"Unable to parse JSON: " + result);
53 throw std::runtime_error(
"Compiled without external signing support (required for external signing).");
bool read(std::string_view raw)
bool error(const char *fmt, const Args &... args)
UniValue RunCommandParseJSON(const std::string &str_command, const std::string &str_std_in)
Execute a command which returns JSON, and parse the result.