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

Function register_close_command

lightningd/closing_control.c:142–171  ·  view source on GitHub ↗

Construct a close command structure and add to ld. */

Source from the content-addressed store, hash-verified

140
141/* Construct a close command structure and add to ld. */
142static void
143register_close_command(struct lightningd *ld,
144 struct command *cmd,
145 struct channel *channel,
146 unsigned int timeout)
147{
148 struct close_command *cc;
149 assert(channel);
150
151 cc = tal(cmd, struct close_command);
152 list_add_tail(&ld->close_commands, &cc->list);
153 cc->cmd = cmd;
154 cc->channel = channel;
155 tal_add_destructor(cc, &destroy_close_command);
156 tal_add_destructor2(channel,
157 &destroy_close_command_on_channel_destroy,
158 cc);
159
160 if (!channel->owner) {
161 char *msg = tal_strdup(tmpctx, "peer is offline, will negotiate once they reconnect");
162 if (timeout)
163 tal_append_fmt(&msg, " (%u seconds before unilateral close)",
164 timeout);
165 json_notify_fmt(cmd, LOG_INFORM, "%s.", msg);
166 }
167 log_debug(ld->log, "close_command: timeout = %u", timeout);
168 if (timeout)
169 new_reltimer(ld->timers, cc, time_from_sec(timeout),
170 &close_command_timeout, cc);
171}
172
173static bool calc_tx_fee(struct channel *channel,
174 const struct bitcoin_tx *tx,

Callers 1

json_closeFunction · 0.85

Calls 3

tal_append_fmtFunction · 0.85
time_from_secFunction · 0.85
json_notify_fmtFunction · 0.70

Tested by

no test coverage detected