| 390 | }; |
| 391 | |
| 392 | static void process_utxo_result(struct bitcoind *bitcoind, |
| 393 | const struct bitcoin_tx_output *txout, |
| 394 | void *arg) |
| 395 | { |
| 396 | struct txo_rescan *rescan = arg; |
| 397 | struct json_stream *response = rescan->response; |
| 398 | struct utxo *u = rescan->utxos[0]; |
| 399 | enum output_status newstate = |
| 400 | txout == NULL ? OUTPUT_STATE_SPENT : OUTPUT_STATE_AVAILABLE; |
| 401 | |
| 402 | json_object_start(rescan->response, NULL); |
| 403 | json_add_txid(response, "txid", &u->outpoint.txid); |
| 404 | json_add_num(response, "output", u->outpoint.n); |
| 405 | json_add_num(response, "oldstate", u->status); |
| 406 | json_add_num(response, "newstate", newstate); |
| 407 | json_object_end(rescan->response); |
| 408 | wallet_update_output_status(bitcoind->ld->wallet, &u->outpoint, |
| 409 | u->status, newstate); |
| 410 | |
| 411 | /* Remove the utxo we just resolved */ |
| 412 | rescan->utxos[0] = rescan->utxos[tal_count(rescan->utxos) - 1]; |
| 413 | tal_resize(&rescan->utxos, tal_count(rescan->utxos) - 1); |
| 414 | |
| 415 | if (tal_count(rescan->utxos) == 0) { |
| 416 | /* Complete the response */ |
| 417 | json_array_end(rescan->response); |
| 418 | was_pending(command_success(rescan->cmd, rescan->response)); |
| 419 | } else { |
| 420 | bitcoind_getutxout(bitcoind->ld->topology->bitcoind, |
| 421 | &rescan->utxos[0]->outpoint, |
| 422 | process_utxo_result, rescan); |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | static struct command_result *json_dev_rescan_outputs(struct command *cmd, |
| 427 | const char *buffer, |
nothing calls this directly
no test coverage detected