MCPcopy Create free account
hub / github.com/ElementsProject/lightning / peer_got_revoke

Function peer_got_revoke

lightningd/peer_htlcs.c:2691–2836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2689 struct commitment_revocation_payload *);
2690
2691void peer_got_revoke(struct channel *channel, const u8 *msg)
2692{
2693 u64 revokenum;
2694 struct secret per_commitment_secret;
2695 struct pubkey next_per_commitment_point;
2696 struct changed_htlc *changed;
2697 enum onion_wire *badonions;
2698 u8 **failmsgs;
2699 size_t i;
2700 struct lightningd *ld = channel->peer->ld;
2701 struct fee_states *fee_states;
2702 struct height_states *blockheight_states;
2703 struct penalty_base *pbases;
2704 struct bitcoin_tx **penalty_txs;
2705
2706 if (!fromwire_channeld_got_revoke(msg, msg,
2707 &revokenum, &per_commitment_secret,
2708 &next_per_commitment_point,
2709 &fee_states,
2710 &blockheight_states,
2711 &changed,
2712 &pbases,
2713 &penalty_txs)
2714 || !fee_states_valid(fee_states, channel->opener)
2715 || !height_states_valid(blockheight_states, channel->opener)) {
2716 channel_internal_error(channel, "bad fromwire_channeld_got_revoke %s",
2717 tal_hex(channel, msg));
2718 return;
2719 }
2720
2721 log_debug(channel->log,
2722 "got revoke %"PRIu64": %zu changed",
2723 revokenum, tal_count(changed));
2724
2725 if (revokenum >= (1ULL << 48)) {
2726 channel_internal_error(channel, "got_revoke: too many txs %"PRIu64,
2727 revokenum);
2728 return;
2729 }
2730
2731 if (revokenum != revocations_received(&channel->their_shachain.chain)) {
2732 channel_internal_error(channel, "got_revoke: expected %"PRIu64
2733 " got %"PRIu64,
2734 revocations_received(&channel->their_shachain.chain), revokenum);
2735 return;
2736 }
2737
2738 /* BOLT #2:
2739 *
2740 * - if the `per_commitment_secret` was not generated by the protocol
2741 * in [BOLT #3](03-transactions.md#per-commitment-secret-requirements):
2742 * - MAY send a `warning` and close the connection, or send an
2743 * `error` and fail the channel.
2744 */
2745 if (!wallet_shachain_add_hash(ld->wallet,
2746 &channel->their_shachain,
2747 shachain_index(revokenum),
2748 &per_commitment_secret)) {

Callers 1

channel_msgFunction · 0.85

Calls 15

fee_states_validFunction · 0.85
height_states_validFunction · 0.85
tal_hexFunction · 0.85
revocations_receivedFunction · 0.85
wallet_shachain_add_hashFunction · 0.85
shachain_indexFunction · 0.85
fmt_secretFunction · 0.85
peer_accepted_htlcFunction · 0.85
tal_freeFunction · 0.85
update_per_commit_pointFunction · 0.85

Tested by

no test coverage detected