| 596 | }; |
| 597 | |
| 598 | static 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 | |
| 628 | void bitcoind_getutxout_(const tal_t *ctx, |
| 629 | struct bitcoind *bitcoind, |
nothing calls this directly
no test coverage detected