| 2312 | struct commitment_revocation_payload *); |
| 2313 | |
| 2314 | void peer_got_revoke(struct channel *channel, const u8 *msg) |
| 2315 | { |
| 2316 | u64 revokenum; |
| 2317 | struct secret per_commitment_secret; |
| 2318 | struct pubkey next_per_commitment_point; |
| 2319 | struct changed_htlc *changed; |
| 2320 | enum onion_wire *badonions; |
| 2321 | u8 **failmsgs; |
| 2322 | size_t i; |
| 2323 | struct lightningd *ld = channel->peer->ld; |
| 2324 | struct fee_states *fee_states; |
| 2325 | struct height_states *blockheight_states; |
| 2326 | struct penalty_base *pbase; |
| 2327 | struct commitment_revocation_payload *payload; |
| 2328 | struct bitcoin_tx *penalty_tx; |
| 2329 | |
| 2330 | if (!fromwire_channeld_got_revoke(msg, msg, |
| 2331 | &revokenum, &per_commitment_secret, |
| 2332 | &next_per_commitment_point, |
| 2333 | &fee_states, |
| 2334 | &blockheight_states, |
| 2335 | &changed, |
| 2336 | &pbase, |
| 2337 | &penalty_tx) |
| 2338 | || !fee_states_valid(fee_states, channel->opener) |
| 2339 | || !height_states_valid(blockheight_states, channel->opener)) { |
| 2340 | channel_internal_error(channel, "bad fromwire_channeld_got_revoke %s", |
| 2341 | tal_hex(channel, msg)); |
| 2342 | return; |
| 2343 | } |
| 2344 | |
| 2345 | log_debug(channel->log, |
| 2346 | "got revoke %"PRIu64": %zu changed", |
| 2347 | revokenum, tal_count(changed)); |
| 2348 | |
| 2349 | /* Save any immediate failures for after we reply. */ |
| 2350 | badonions = tal_arrz(msg, enum onion_wire, tal_count(changed)); |
| 2351 | failmsgs = tal_arrz(msg, u8 *, tal_count(changed)); |
| 2352 | for (i = 0; i < tal_count(changed); i++) { |
| 2353 | /* If we're doing final accept, we need to forward */ |
| 2354 | if (changed[i].newstate == RCVD_ADD_ACK_REVOCATION) { |
| 2355 | peer_accepted_htlc(failmsgs, |
| 2356 | channel, changed[i].id, false, |
| 2357 | &badonions[i], &failmsgs[i]); |
| 2358 | } else { |
| 2359 | if (!changed_htlc(channel, &changed[i])) { |
| 2360 | channel_internal_error(channel, |
| 2361 | "got_revoke: update failed"); |
| 2362 | return; |
| 2363 | } |
| 2364 | } |
| 2365 | } |
| 2366 | |
| 2367 | if (revokenum >= (1ULL << 48)) { |
| 2368 | channel_internal_error(channel, "got_revoke: too many txs %"PRIu64, |
| 2369 | revokenum); |
| 2370 | return; |
| 2371 | } |
no test coverage detected