MCPcopy Create free account
hub / github.com/ElementsProject/elements / RunCommandParseJSON

Function RunCommandParseJSON

src/util/system.cpp:1316–1353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1314#endif
1315
1316UniValue RunCommandParseJSON(const std::string& str_command, const std::string& str_std_in)
1317{
1318#ifdef ENABLE_EXTERNAL_SIGNER
1319 namespace bp = boost::process;
1320
1321 UniValue result_json;
1322 bp::opstream stdin_stream;
1323 bp::ipstream stdout_stream;
1324 bp::ipstream stderr_stream;
1325
1326 if (str_command.empty()) return UniValue::VNULL;
1327
1328 bp::child c(
1329 str_command,
1330 bp::std_out > stdout_stream,
1331 bp::std_err > stderr_stream,
1332 bp::std_in < stdin_stream
1333 );
1334 if (!str_std_in.empty()) {
1335 stdin_stream << str_std_in << std::endl;
1336 }
1337 stdin_stream.pipe().close();
1338
1339 std::string result;
1340 std::string error;
1341 std::getline(stdout_stream, result);
1342 std::getline(stderr_stream, error);
1343
1344 c.wait();
1345 const int n_error = c.exit_code();
1346 if (n_error) throw std::runtime_error(strprintf("RunCommandParseJSON error: process(%s) returned %d: %s\n", str_command, n_error, error));
1347 if (!result_json.read(result)) throw std::runtime_error("Unable to parse JSON: " + result);
1348
1349 return result_json;
1350#else
1351 throw std::runtime_error("Compiled without external signing support (required for external signing).");
1352#endif // ENABLE_EXTERNAL_SIGNER
1353}
1354
1355void SetupEnvironment()
1356{

Callers 5

EnumerateMethod · 0.85
DisplayAddressMethod · 0.85
GetDescriptorsMethod · 0.85
SignTransactionMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 4

waitMethod · 0.80
emptyMethod · 0.45
closeMethod · 0.45
readMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68