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

Function register_close_command

lightningd/closing_control.c:137–166  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 1

json_closeFunction · 0.85

Calls 3

tal_append_fmtFunction · 0.85
json_notify_fmtFunction · 0.85
time_from_secFunction · 0.85

Tested by

no test coverage detected