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

Function resolve_one_close_command

lightningd/closing_control.c:39–68  ·  view source on GitHub ↗

Resolve a single close command. */

Source from the content-addressed store, hash-verified

37
38/* Resolve a single close command. */
39static void
40resolve_one_close_command(struct close_command *cc, bool cooperative,
41 const struct bitcoin_tx **close_txs)
42{
43 struct json_stream *result = json_stream_success(cc->cmd);
44
45 json_array_start(result, "txs");
46 for (int i = 0; i < tal_count(close_txs); i++)
47 json_add_tx(result, NULL, close_txs[i]);
48 json_array_end(result);
49
50 json_array_start(result, "txids");
51 for (int i = 0; i < tal_count(close_txs); i++) {
52 if (invalid_last_tx(close_txs[i])) {
53 json_add_string(result, NULL, "INVALID_TXID");
54 } else {
55 struct bitcoin_txid txid;
56 bitcoin_txid(close_txs[i], &txid);
57 json_add_txid(result, NULL, &txid);
58 }
59 }
60 json_array_end(result);
61
62 if (cooperative)
63 json_add_string(result, "type", "mutual");
64 else
65 json_add_string(result, "type", "unilateral");
66
67 was_pending(command_success(cc->cmd, result));
68}
69
70const char *cmd_id_from_close_command(const tal_t *ctx,
71 struct lightningd *ld, struct channel *channel)

Callers 1

resolve_close_commandFunction · 0.85

Calls 10

json_array_startFunction · 0.85
json_add_txFunction · 0.85
json_array_endFunction · 0.85
invalid_last_txFunction · 0.85
json_add_txidFunction · 0.85
json_stream_successFunction · 0.70
bitcoin_txidClass · 0.70
was_pendingFunction · 0.70
command_successFunction · 0.70
json_add_stringFunction · 0.50

Tested by

no test coverage detected