| 2635 | struct commitment_revocation_payload *); |
| 2636 | |
| 2637 | void peer_got_revoke(struct channel *channel, const u8 *msg) |
| 2638 | { |
| 2639 | u64 revokenum; |
| 2640 | struct secret per_commitment_secret; |
| 2641 | struct pubkey next_per_commitment_point; |
| 2642 | struct changed_htlc *changed; |
| 2643 | enum onion_wire *badonions; |
| 2644 | u8 **failmsgs; |
| 2645 | size_t i; |
| 2646 | struct lightningd *ld = channel->peer->ld; |
| 2647 | struct fee_states *fee_states; |
| 2648 | struct height_states *blockheight_states; |
| 2649 | struct penalty_base *pbase; |
| 2650 | struct commitment_revocation_payload *payload; |
| 2651 | struct bitcoin_tx *penalty_tx; |
| 2652 | |
| 2653 | if (!fromwire_channeld_got_revoke(msg, msg, |
| 2654 | &revokenum, &per_commitment_secret, |
| 2655 | &next_per_commitment_point, |
| 2656 | &fee_states, |
| 2657 | &blockheight_states, |
| 2658 | &changed, |
| 2659 | &pbase, |
| 2660 | &penalty_tx) |
| 2661 | || !fee_states_valid(fee_states, channel->opener) |
| 2662 | || !height_states_valid(blockheight_states, channel->opener)) { |
| 2663 | channel_internal_error(channel, "bad fromwire_channeld_got_revoke %s", |
| 2664 | tal_hex(channel, msg)); |
| 2665 | return; |
| 2666 | } |
| 2667 | |
| 2668 | log_debug(channel->log, |
| 2669 | "got revoke %"PRIu64": %zu changed", |
| 2670 | revokenum, tal_count(changed)); |
| 2671 | |
| 2672 | /* Save any immediate failures for after we reply. */ |
| 2673 | badonions = tal_arrz(msg, enum onion_wire, tal_count(changed)); |
| 2674 | failmsgs = tal_arrz(msg, u8 *, tal_count(changed)); |
| 2675 | for (i = 0; i < tal_count(changed); i++) { |
| 2676 | /* BOLT #2: |
| 2677 | * A node: |
| 2678 | * - until an incoming HTLC has been irrevocably committed: |
| 2679 | * - MUST NOT offer the corresponding outgoing HTLC |
| 2680 | * (`update_add_htlc`) in response to that incoming HTLC. |
| 2681 | */ |
| 2682 | /* If we're doing final accept, we need to forward */ |
| 2683 | if (changed[i].newstate == RCVD_ADD_ACK_REVOCATION) { |
| 2684 | peer_accepted_htlc(failmsgs, |
| 2685 | channel, changed[i].id, false, |
| 2686 | &badonions[i], &failmsgs[i]); |
| 2687 | } else { |
| 2688 | if (!changed_htlc(channel, &changed[i])) { |
| 2689 | channel_internal_error(channel, |
| 2690 | "got_revoke: update failed"); |
| 2691 | return; |
| 2692 | } |
| 2693 | } |
| 2694 | } |
no test coverage detected