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

Function getutxout_callback

lightningd/bitcoind.c:598–626  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

596};
597
598static void getutxout_callback(const char *buf, const jsmntok_t *toks,
599 const jsmntok_t *idtok,
600 struct getutxout_call *call)
601{
602 const jsmntok_t *resulttok;
603 const char *err;
604 struct bitcoin_tx_output txout;
605
606 /* Whatever happens, we want to free this. */
607 tal_steal(tmpctx, call);
608
609 resulttok = get_bitcoin_result(call->bitcoind, buf, toks, "getutxout");
610
611 err = json_scan(tmpctx, buf, resulttok, "{script:null}");
612 if (!err) {
613 call->cb(call->bitcoind, NULL, call->cb_arg);
614 return;
615 }
616
617 err = json_scan(tmpctx, buf, resulttok, "{script:%,amount:%}",
618 JSON_SCAN_TAL(tmpctx, json_tok_bin_from_hex,
619 &txout.script),
620 JSON_SCAN(json_to_sat, &txout.amount));
621 if (err)
622 bitcoin_plugin_error(call->bitcoind, buf, resulttok, "getutxout",
623 "bad 'result' field: %s", err);
624
625 call->cb(call->bitcoind, &txout, call->cb_arg);
626}
627
628void bitcoind_getutxout_(const tal_t *ctx,
629 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