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

Function got_revoke_msg

channeld/channeld.c:1768–1810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1766}
1767
1768static u8 *got_revoke_msg(struct peer *peer, u64 revoke_num,
1769 const struct secret *per_commitment_secret,
1770 const struct pubkey *next_per_commit_point,
1771 const struct htlc **changed_htlcs,
1772 const struct fee_states *fee_states,
1773 const struct height_states *blockheight_states)
1774{
1775 u8 *msg;
1776 struct penalty_base *pbase;
1777 struct changed_htlc *changed = tal_arr(tmpctx, struct changed_htlc, 0);
1778 const struct bitcoin_tx *ptx = NULL;
1779
1780 for (size_t i = 0; i < tal_count(changed_htlcs); i++) {
1781 struct changed_htlc c;
1782 const struct htlc *htlc = changed_htlcs[i];
1783
1784 status_debug("HTLC %"PRIu64"[%s] => %s",
1785 htlc->id, side_to_str(htlc_owner(htlc)),
1786 htlc_state_name(htlc->state));
1787
1788 c.id = changed_htlcs[i]->id;
1789 c.newstate = changed_htlcs[i]->state;
1790 tal_arr_expand(&changed, c);
1791 }
1792
1793 pbase = penalty_base_by_commitnum(tmpctx, peer, revoke_num);
1794
1795 if (pbase) {
1796 ptx = penalty_tx_create(
1797 NULL, peer->channel, peer->feerate_penalty,
1798 peer->final_index, peer->final_ext_key,
1799 peer->final_scriptpubkey, per_commitment_secret,
1800 &pbase->txid, pbase->outnum, pbase->amount,
1801 HSM_FD);
1802 }
1803
1804 msg = towire_channeld_got_revoke(peer, revoke_num, per_commitment_secret,
1805 next_per_commit_point, fee_states,
1806 blockheight_states, changed,
1807 pbase, ptx);
1808 tal_free(ptx);
1809 return msg;
1810}
1811
1812static void handle_peer_revoke_and_ack(struct peer *peer, const u8 *msg)
1813{

Callers 1

Calls 6

side_to_strFunction · 0.85
htlc_ownerFunction · 0.85
penalty_tx_createFunction · 0.85
tal_freeFunction · 0.85
htlc_state_nameFunction · 0.50

Tested by

no test coverage detected