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

Function send_revocation

channeld/channeld.c:1675–1735  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1673}
1674
1675static void send_revocation(struct peer *peer,
1676 const struct bitcoin_signature *commit_sig,
1677 const struct bitcoin_signature *htlc_sigs,
1678 const struct htlc **changed_htlcs,
1679 const struct bitcoin_tx *committx,
1680 const struct secret *old_secret,
1681 const struct pubkey *next_point,
1682 const struct commitsig **splice_commitsigs)
1683{
1684 struct changed_htlc *changed;
1685 struct fulfilled_htlc *fulfilled;
1686 const struct failed_htlc **failed;
1687 const struct added_htlc **added;
1688 const u8 *msg;
1689 const u8 *msg_for_master;
1690
1691 /* Marshall it now before channel_sending_revoke_and_ack changes htlcs */
1692 /* FIXME: Make infrastructure handle state post-revoke_and_ack! */
1693 marshall_htlc_info(tmpctx,
1694 changed_htlcs,
1695 &changed,
1696 &fulfilled,
1697 &failed,
1698 &added);
1699
1700 /* From now on we apply changes to the next commitment */
1701 peer->next_index[LOCAL]++;
1702
1703 /* If this queues more changes on the other end, send commit. */
1704 if (channel_sending_revoke_and_ack(peer->channel)) {
1705 status_debug("revoke_and_ack made pending: commit timer");
1706 start_commit_timer(peer);
1707 }
1708
1709 /* Tell master daemon about commitsig (and by implication, that we're
1710 * sending revoke_and_ack), then wait for it to ack. */
1711 /* We had to do this after channel_sending_revoke_and_ack, since we
1712 * want it to save the fee_states produced there. */
1713 msg_for_master
1714 = towire_channeld_got_commitsig(NULL,
1715 peer->next_index[LOCAL] - 1,
1716 peer->channel->fee_states,
1717 peer->channel->blockheight_states,
1718 commit_sig, htlc_sigs,
1719 added,
1720 fulfilled,
1721 failed,
1722 changed,
1723 committx,
1724 splice_commitsigs);
1725 master_wait_sync_reply(tmpctx, peer, take(msg_for_master),
1726 WIRE_CHANNELD_GOT_COMMITSIG_REPLY);
1727
1728 /* Now that the master has persisted the new commitment advance the HSMD
1729 * and fetch the revocation secret for the old one. */
1730 msg = make_revocation_msg(peer, peer->next_index[LOCAL]-2,
1731 &peer->next_local_per_commit);
1732

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