Construct a close command structure and add to ld. */
| 140 | |
| 141 | /* Construct a close command structure and add to ld. */ |
| 142 | static void |
| 143 | register_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 | |
| 173 | static bool calc_tx_fee(struct channel *channel, |
| 174 | const struct bitcoin_tx *tx, |
no test coverage detected