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

Function peer_sending_revocation

lightningd/peer_htlcs.c:2379–2414  ·  view source on GitHub ↗

The peer doesn't tell us this separately, but logically it's a separate * step to receiving commitsig */

Source from the content-addressed store, hash-verified

2377/* The peer doesn't tell us this separately, but logically it's a separate
2378 * step to receiving commitsig */
2379static bool peer_sending_revocation(struct channel *channel,
2380 struct added_htlc **added,
2381 struct fulfilled_htlc *fulfilled,
2382 struct failed_htlc **failed,
2383 struct changed_htlc *changed)
2384{
2385 size_t i;
2386
2387 for (i = 0; i < tal_count(added); i++) {
2388 if (!update_in_htlc(channel, added[i]->id, SENT_ADD_REVOCATION))
2389 return false;
2390 }
2391 for (i = 0; i < tal_count(fulfilled); i++) {
2392 if (!update_out_htlc(channel, fulfilled[i].id,
2393 SENT_REMOVE_REVOCATION))
2394 return false;
2395 }
2396 for (i = 0; i < tal_count(failed); i++) {
2397 if (!update_out_htlc(channel, failed[i]->id, SENT_REMOVE_REVOCATION))
2398 return false;
2399 }
2400 for (i = 0; i < tal_count(changed); i++) {
2401 if (changed[i].newstate == RCVD_ADD_ACK_COMMIT) {
2402 if (!update_out_htlc(channel, changed[i].id,
2403 SENT_ADD_ACK_REVOCATION))
2404 return false;
2405 } else {
2406 if (!update_in_htlc(channel, changed[i].id,
2407 SENT_REMOVE_ACK_REVOCATION))
2408 return false;
2409 }
2410 }
2411
2412 channel->last_was_revoke = true;
2413 return true;
2414}
2415
2416struct deferred_commitsig {
2417 struct channel *channel;

Callers 1

peer_got_commitsigFunction · 0.85

Calls 2

update_in_htlcFunction · 0.85
update_out_htlcFunction · 0.85

Tested by

no test coverage detected