5#include <bitcoin-build-config.h>
13#ifdef ENABLE_EXTERNAL_SIGNER
19#ifdef ENABLE_EXTERNAL_SIGNER
23 std::istringstream stdout_stream;
24 std::istringstream stderr_stream;
29 if (!str_std_in.empty()) {
32 auto [out_res, err_res] = c.communicate();
33 stdout_stream.str(std::string{out_res.buf.begin(), out_res.buf.end()});
34 stderr_stream.str(std::string{err_res.buf.begin(), err_res.buf.end()});
38 std::getline(stdout_stream, result);
39 std::getline(stderr_stream, error);
41 const int n_error = c.retcode();
42 if (n_error)
throw std::runtime_error(
strprintf(
"RunCommandParseJSON error: process(%s) returned %d: %s\n",
util::Join(cmd_args,
" "), n_error, error));
43 if (!result_json.
read(result))
throw std::runtime_error(
"Unable to parse JSON: " + result);
47 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.