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

Function register_close_command

lightningd/closing_control.c:140–169  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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