MCPcopy Create free account
hub / github.com/ElementsProject/lightning / process_utxo_result

Function process_utxo_result

wallet/walletrpc.c:512–543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510};
511
512static 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
545static struct command_result *json_dev_rescan_outputs(struct command *cmd,
546 const char *buffer,

Callers

nothing calls this directly

Calls 8

json_object_startFunction · 0.85
json_add_txidFunction · 0.85
json_add_numFunction · 0.85
json_object_endFunction · 0.85
json_array_endFunction · 0.85
was_pendingFunction · 0.50
command_successFunction · 0.50

Tested by

no test coverage detected