| 511 | }; |
| 512 | |
| 513 | static 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 | |
| 540 | clean: |
| 541 | tal_free(call); |
| 542 | } |
| 543 | |
| 544 | void bitcoind_getutxout_(struct bitcoind *bitcoind, |
| 545 | const struct bitcoin_outpoint *outpoint, |
nothing calls this directly
no test coverage detected