5#include <bitcoin-build-config.h>
13#ifdef ENABLE_EXTERNAL_SIGNER
23#ifdef ENABLE_EXTERNAL_SIGNER
27 std::istringstream stdout_stream;
28 std::istringstream stderr_stream;
33 if (!str_std_in.empty()) {
36 auto [out_res, err_res] = c.communicate();
37 stdout_stream.str(std::string{out_res.buf.begin(), out_res.buf.end()});
38 stderr_stream.str(std::string{err_res.buf.begin(), err_res.buf.end()});
42 std::getline(stdout_stream, result);
43 std::getline(stderr_stream, error);
45 const int n_error = c.retcode();
46 if (n_error)
throw std::runtime_error(
strprintf(
"RunCommandParseJSON error: process(%s) returned %d: %s\n",
util::Join(cmd_args,
" "), n_error, error));
47 if (!result_json.
read(result))
throw std::runtime_error(
"Unable to parse JSON: " + result);
51 throw std::runtime_error(
"Compiled without external signing support (required for external signing).");
bool read(std::string_view raw)
auto Join(const C &container, const S &separator, UnaryOp unary_op)
Join all container items.
UniValue RunCommandParseJSON(const std::vector< std::string > &cmd_args, const std::string &str_std_in)
Execute a command which returns JSON, and parse the result.