| 543 | } |
| 544 | |
| 545 | static struct command_result *json_dev_rescan_outputs(struct command *cmd, |
| 546 | const char *buffer, |
| 547 | const jsmntok_t *obj UNNEEDED, |
| 548 | const jsmntok_t *params) |
| 549 | { |
| 550 | struct txo_rescan *rescan = tal(cmd, struct txo_rescan); |
| 551 | |
| 552 | if (!param(cmd, buffer, params, NULL)) |
| 553 | return command_param_failed(); |
| 554 | |
| 555 | rescan->response = json_stream_success(cmd); |
| 556 | rescan->cmd = cmd; |
| 557 | |
| 558 | /* Open the outputs structure so we can incrementally add results */ |
| 559 | json_array_start(rescan->response, "outputs"); |
| 560 | rescan->utxos = wallet_get_all_utxos(rescan, cmd->ld->wallet); |
| 561 | if (tal_count(rescan->utxos) == 0) { |
| 562 | json_array_end(rescan->response); |
| 563 | return command_success(cmd, rescan->response); |
| 564 | } |
| 565 | bitcoind_getutxout(rescan, cmd->ld->topology->bitcoind, |
| 566 | &rescan->utxos[0]->outpoint, |
| 567 | process_utxo_result, |
| 568 | rescan); |
| 569 | return command_still_pending(cmd); |
| 570 | } |
| 571 | |
| 572 | static const struct json_command dev_rescan_output_command = { |
| 573 | "dev-rescan-outputs", |
nothing calls this directly
no test coverage detected