| 393 | } |
| 394 | |
| 395 | static struct command_result *process_getutxout(struct bitcoin_cli *bcli) |
| 396 | { |
| 397 | const jsmntok_t *tokens; |
| 398 | struct json_stream *response; |
| 399 | struct bitcoin_tx_output output; |
| 400 | const char *err; |
| 401 | |
| 402 | /* As of at least v0.15.1.0, bitcoind returns "success" but an empty |
| 403 | string on a spent txout. */ |
| 404 | if (*bcli->exitstatus != 0 || bcli->output_bytes == 0) { |
| 405 | response = jsonrpc_stream_success(bcli->cmd); |
| 406 | json_add_null(response, "amount"); |
| 407 | json_add_null(response, "script"); |
| 408 | |
| 409 | return command_finished(bcli->cmd, response); |
| 410 | } |
| 411 | |
| 412 | tokens = json_parse_simple(bcli->output, bcli->output, |
| 413 | bcli->output_bytes); |
| 414 | if (!tokens) { |
| 415 | return command_err_bcli_badjson(bcli, "cannot parse"); |
| 416 | } |
| 417 | |
| 418 | err = json_scan(tmpctx, bcli->output, tokens, |
| 419 | "{value:%,scriptPubKey:{hex:%}}", |
| 420 | JSON_SCAN(json_to_bitcoin_amount, |
| 421 | &output.amount.satoshis), /* Raw: bitcoind */ |
| 422 | JSON_SCAN_TAL(bcli, json_tok_bin_from_hex, |
| 423 | &output.script)); |
| 424 | if (err) |
| 425 | return command_err_bcli_badjson(bcli, err); |
| 426 | |
| 427 | response = jsonrpc_stream_success(bcli->cmd); |
| 428 | json_add_sats(response, "amount", output.amount); |
| 429 | json_add_string(response, "script", tal_hex(response, output.script)); |
| 430 | |
| 431 | return command_finished(bcli->cmd, response); |
| 432 | } |
| 433 | |
| 434 | static struct command_result *process_getblockchaininfo(struct bitcoin_cli *bcli) |
| 435 | { |
nothing calls this directly
no test coverage detected