| 2148 | } |
| 2149 | |
| 2150 | void routing_channel_spent(struct routing_state *rstate, |
| 2151 | u32 current_blockheight, |
| 2152 | struct chan *chan) |
| 2153 | { |
| 2154 | u64 index; |
| 2155 | u32 deadline; |
| 2156 | u8 *msg; |
| 2157 | |
| 2158 | /* FIXME: We should note that delay is not necessary (or even |
| 2159 | * sensible) for local channels! */ |
| 2160 | if (local_direction(rstate, chan, NULL)) { |
| 2161 | channel_spent(rstate, chan); |
| 2162 | return; |
| 2163 | } |
| 2164 | |
| 2165 | /* BOLT #7: |
| 2166 | * - once its funding output has been spent OR reorganized out: |
| 2167 | * - SHOULD forget a channel after a 12-block delay. |
| 2168 | */ |
| 2169 | deadline = current_blockheight + 12; |
| 2170 | |
| 2171 | /* Save to gossip_store in case we restart */ |
| 2172 | msg = towire_gossip_store_chan_dying(tmpctx, &chan->scid, deadline); |
| 2173 | index = gossip_store_add(rstate->gs, msg, 0, false, false, NULL); |
| 2174 | |
| 2175 | /* Remember locally so we can kill it in 12 blocks */ |
| 2176 | status_debug("channel %s closing soon due" |
| 2177 | " to the funding outpoint being spent", |
| 2178 | type_to_string(msg, struct short_channel_id, &chan->scid)); |
| 2179 | remember_chan_dying(rstate, &chan->scid, deadline, index); |
| 2180 | } |
| 2181 |
no test coverage detected