MCPcopy Create free account
hub / github.com/ElementsProject/lightning / process_getutxout

Function process_getutxout

plugins/bcli.c:395–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393}
394
395static struct command_result *process_getutxout(struct bitcoin_cli *bcli)
396{
397 const jsmntok_t *tokens;
398 struct json_stream *response;
399 struct bitcoin_tx_output output;
400 const char *err;
401
402 /* As of at least v0.15.1.0, bitcoind returns "success" but an empty
403 string on a spent txout. */
404 if (*bcli->exitstatus != 0 || bcli->output_bytes == 0) {
405 response = jsonrpc_stream_success(bcli->cmd);
406 json_add_null(response, "amount");
407 json_add_null(response, "script");
408
409 return command_finished(bcli->cmd, response);
410 }
411
412 tokens = json_parse_simple(bcli->output, bcli->output,
413 bcli->output_bytes);
414 if (!tokens) {
415 return command_err_bcli_badjson(bcli, "cannot parse");
416 }
417
418 err = json_scan(tmpctx, bcli->output, tokens,
419 "{value:%,scriptPubKey:{hex:%}}",
420 JSON_SCAN(json_to_bitcoin_amount,
421 &output.amount.satoshis), /* Raw: bitcoind */
422 JSON_SCAN_TAL(bcli, json_tok_bin_from_hex,
423 &output.script));
424 if (err)
425 return command_err_bcli_badjson(bcli, err);
426
427 response = jsonrpc_stream_success(bcli->cmd);
428 json_add_sats(response, "amount", output.amount);
429 json_add_string(response, "script", tal_hex(response, output.script));
430
431 return command_finished(bcli->cmd, response);
432}
433
434static struct command_result *process_getblockchaininfo(struct bitcoin_cli *bcli)
435{

Callers

nothing calls this directly

Calls 9

json_add_nullFunction · 0.85
command_err_bcli_badjsonFunction · 0.85
json_add_satsFunction · 0.85
tal_hexFunction · 0.85
jsonrpc_stream_successFunction · 0.70
command_finishedFunction · 0.70
json_parse_simpleFunction · 0.50
json_scanFunction · 0.50
json_add_stringFunction · 0.50

Tested by

no test coverage detected