Construct a close command structure and add to ld. */
| 135 | |
| 136 | /* Construct a close command structure and add to ld. */ |
| 137 | static void |
| 138 | register_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 | |
| 168 | static struct amount_sat calc_tx_fee(struct amount_sat sat_in, |
| 169 | const struct bitcoin_tx *tx) |
no test coverage detected