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

Function getutxout_callback

lightningd/bitcoind.c:616–644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

614};
615
616static void getutxout_callback(const char *buf, const jsmntok_t *toks,
617 const jsmntok_t *idtok,
618 struct getutxout_call *call)
619{
620 const jsmntok_t *resulttok;
621 const char *err;
622 struct bitcoin_tx_output txout;
623
624 /* Whatever happens, we want to free this. */
625 tal_steal(tmpctx, call);
626
627 resulttok = get_bitcoin_result(call->bitcoind, buf, toks, "getutxout");
628
629 err = json_scan(tmpctx, buf, resulttok, "{script:null}");
630 if (!err) {
631 call->cb(call->bitcoind, NULL, call->cb_arg);
632 return;
633 }
634
635 err = json_scan(tmpctx, buf, resulttok, "{script:%,amount:%}",
636 JSON_SCAN_TAL(tmpctx, json_tok_bin_from_hex,
637 &txout.script),
638 JSON_SCAN(json_to_sat, &txout.amount));
639 if (err)
640 bitcoin_plugin_error(call->bitcoind, buf, resulttok, "getutxout",
641 "bad 'result' field: %s", err);
642
643 call->cb(call->bitcoind, &txout, call->cb_arg);
644}
645
646void bitcoind_getutxout_(const tal_t *ctx,
647 struct bitcoind *bitcoind,

Callers

nothing calls this directly

Calls 3

get_bitcoin_resultFunction · 0.85
bitcoin_plugin_errorFunction · 0.85
json_scanFunction · 0.50

Tested by

no test coverage detected