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

Function send_revocation

channeld/channeld.c:1524–1582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1522}
1523
1524static void send_revocation(struct peer *peer,
1525 const struct bitcoin_signature *commit_sig,
1526 const struct bitcoin_signature *htlc_sigs,
1527 const struct htlc **changed_htlcs,
1528 const struct bitcoin_tx *committx,
1529 const struct secret *old_secret,
1530 const struct pubkey *next_point)
1531{
1532 struct changed_htlc *changed;
1533 struct fulfilled_htlc *fulfilled;
1534 const struct failed_htlc **failed;
1535 struct added_htlc *added;
1536 const u8 *msg;
1537 const u8 *msg_for_master;
1538
1539 /* Marshall it now before channel_sending_revoke_and_ack changes htlcs */
1540 /* FIXME: Make infrastructure handle state post-revoke_and_ack! */
1541 marshall_htlc_info(tmpctx,
1542 changed_htlcs,
1543 &changed,
1544 &fulfilled,
1545 &failed,
1546 &added);
1547
1548 /* Revoke previous commit, get new point. */
1549 msg = make_revocation_msg_from_secret(peer, peer->next_index[LOCAL]-1,
1550 &peer->next_local_per_commit,
1551 old_secret, next_point);
1552
1553 /* From now on we apply changes to the next commitment */
1554 peer->next_index[LOCAL]++;
1555
1556 /* If this queues more changes on the other end, send commit. */
1557 if (channel_sending_revoke_and_ack(peer->channel)) {
1558 status_debug("revoke_and_ack made pending: commit timer");
1559 start_commit_timer(peer);
1560 }
1561
1562 /* Tell master daemon about commitsig (and by implication, that we're
1563 * sending revoke_and_ack), then wait for it to ack. */
1564 /* We had to do this after channel_sending_revoke_and_ack, since we
1565 * want it to save the fee_states produced there. */
1566 msg_for_master
1567 = towire_channeld_got_commitsig(NULL,
1568 peer->next_index[LOCAL] - 1,
1569 peer->channel->fee_states,
1570 peer->channel->blockheight_states,
1571 commit_sig, htlc_sigs,
1572 added,
1573 fulfilled,
1574 failed,
1575 changed,
1576 committx);
1577 master_wait_sync_reply(tmpctx, peer, take(msg_for_master),
1578 WIRE_CHANNELD_GOT_COMMITSIG_REPLY);
1579
1580 /* Now we can finally send revoke_and_ack to peer */
1581 peer_write(peer->pps, take(msg));

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
peer_writeFunction · 0.85

Tested by

no test coverage detected