Construct a close command structure and add to ld. */
| 138 | |
| 139 | /* Construct a close command structure and add to ld. */ |
| 140 | static void |
| 141 | register_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 | |
| 171 | static struct amount_sat calc_tx_fee(struct amount_sat sat_in, |
| 172 | const struct bitcoin_tx *tx) |
no test coverage detected