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

Function process_utxo_result

wallet/walletrpc.c:392–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390};
391
392static 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
426static struct command_result *json_dev_rescan_outputs(struct command *cmd,
427 const char *buffer,

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected