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

Function getutxout_callback

lightningd/bitcoind.c:513–542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511};
512
513static void getutxout_callback(const char *buf, const jsmntok_t *toks,
514 const jsmntok_t *idtok,
515 struct getutxout_call *call)
516{
517 const char *err;
518 struct bitcoin_tx_output txout;
519
520 err = json_scan(tmpctx, buf, toks, "{result:{script:null}}");
521 if (!err) {
522 db_begin_transaction(call->bitcoind->ld->wallet->db);
523 call->cb(call->bitcoind, NULL, call->cb_arg);
524 db_commit_transaction(call->bitcoind->ld->wallet->db);
525 goto clean;
526 }
527
528 err = json_scan(tmpctx, buf, toks, "{result:{script:%,amount:%}}",
529 JSON_SCAN_TAL(tmpctx, json_tok_bin_from_hex,
530 &txout.script),
531 JSON_SCAN(json_to_sat, &txout.amount));
532 if (err)
533 bitcoin_plugin_error(call->bitcoind, buf, toks, "getutxout",
534 "bad 'result' field: %s", err);
535
536 db_begin_transaction(call->bitcoind->ld->wallet->db);
537 call->cb(call->bitcoind, &txout, call->cb_arg);
538 db_commit_transaction(call->bitcoind->ld->wallet->db);
539
540clean:
541 tal_free(call);
542}
543
544void bitcoind_getutxout_(struct bitcoind *bitcoind,
545 const struct bitcoin_outpoint *outpoint,

Callers

nothing calls this directly

Calls 4

bitcoin_plugin_errorFunction · 0.85
tal_freeFunction · 0.85
json_scanFunction · 0.50
db_commit_transactionFunction · 0.50

Tested by

no test coverage detected