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

Function send_revocation

channeld/channeld.c:1745–1805  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1743}
1744
1745static void send_revocation(struct peer *peer,
1746 const struct bitcoin_signature *commit_sig,
1747 const struct bitcoin_signature *htlc_sigs,
1748 const struct htlc **changed_htlcs,
1749 const struct bitcoin_tx *committx,
1750 const struct secret *old_secret,
1751 const struct pubkey *next_point,
1752 const struct commitsig **splice_commitsigs)
1753{
1754 struct changed_htlc *changed;
1755 struct fulfilled_htlc *fulfilled;
1756 const struct failed_htlc **failed;
1757 const struct added_htlc **added;
1758 const u8 *msg;
1759 const u8 *msg_for_master;
1760
1761 /* Marshall it now before channel_sending_revoke_and_ack changes htlcs */
1762 /* FIXME: Make infrastructure handle state post-revoke_and_ack! */
1763 marshall_htlc_info(tmpctx,
1764 changed_htlcs,
1765 &changed,
1766 &fulfilled,
1767 &failed,
1768 &added);
1769
1770 /* From now on we apply changes to the next commitment */
1771 peer->next_index[LOCAL]++;
1772
1773 /* If this queues more changes on the other end, send commit. */
1774 if (channel_sending_revoke_and_ack(peer->channel)) {
1775 status_debug("revoke_and_ack made pending: commit timer");
1776 start_commit_timer(peer);
1777 }
1778
1779 /* Tell master daemon about commitsig (and by implication, that we're
1780 * sending revoke_and_ack), then wait for it to ack. */
1781 /* We had to do this after channel_sending_revoke_and_ack, since we
1782 * want it to save the fee_states produced there. */
1783 msg_for_master
1784 = towire_channeld_got_commitsig(NULL,
1785 peer->next_index[LOCAL] - 1,
1786 peer->channel->fee_states,
1787 peer->channel->blockheight_states,
1788 commit_sig, htlc_sigs,
1789 added,
1790 fulfilled,
1791 failed,
1792 changed,
1793 committx,
1794 splice_commitsigs);
1795 master_wait_sync_reply(tmpctx, peer, take(msg_for_master),
1796 WIRE_CHANNELD_GOT_COMMITSIG_REPLY);
1797
1798 /* Now that the master has persisted the new commitment advance the HSMD
1799 * and fetch the revocation secret for the old one. */
1800 msg = make_revocation_msg(peer, peer->next_index[LOCAL]-2,
1801 &peer->next_local_per_commit);
1802

Callers 1

handle_peer_commit_sigFunction · 0.85

Calls 6

marshall_htlc_infoFunction · 0.85
start_commit_timerFunction · 0.85
master_wait_sync_replyFunction · 0.85
make_revocation_msgFunction · 0.85
peer_writeFunction · 0.85

Tested by

no test coverage detected