| 510 | }; |
| 511 | |
| 512 | static void process_utxo_result(struct bitcoind *bitcoind, |
| 513 | const struct bitcoin_tx_output *txout, |
| 514 | struct txo_rescan *rescan) |
| 515 | { |
| 516 | struct json_stream *response = rescan->response; |
| 517 | struct utxo *u = rescan->utxos[0]; |
| 518 | enum output_status newstate = |
| 519 | txout == NULL ? OUTPUT_STATE_SPENT : OUTPUT_STATE_AVAILABLE; |
| 520 | |
| 521 | json_object_start(rescan->response, NULL); |
| 522 | json_add_txid(response, "txid", &u->outpoint.txid); |
| 523 | json_add_num(response, "output", u->outpoint.n); |
| 524 | json_add_num(response, "oldstate", u->status); |
| 525 | json_add_num(response, "newstate", newstate); |
| 526 | json_object_end(rescan->response); |
| 527 | wallet_update_output_status(bitcoind->ld->wallet, &u->outpoint, |
| 528 | u->status, newstate); |
| 529 | |
| 530 | /* Remove the utxo we just resolved */ |
| 531 | rescan->utxos[0] = rescan->utxos[tal_count(rescan->utxos) - 1]; |
| 532 | tal_resize(&rescan->utxos, tal_count(rescan->utxos) - 1); |
| 533 | |
| 534 | if (tal_count(rescan->utxos) == 0) { |
| 535 | /* Complete the response */ |
| 536 | json_array_end(rescan->response); |
| 537 | was_pending(command_success(rescan->cmd, rescan->response)); |
| 538 | } else { |
| 539 | bitcoind_getutxout(bitcoind, bitcoind, |
| 540 | &rescan->utxos[0]->outpoint, |
| 541 | process_utxo_result, rescan); |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | static struct command_result *json_dev_rescan_outputs(struct command *cmd, |
| 546 | const char *buffer, |
nothing calls this directly
no test coverage detected