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

Function resolve_one_close_command

lightningd/closing_control.c:37–66  ·  view source on GitHub ↗

Resolve a single close command. */

Source from the content-addressed store, hash-verified

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