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

Function add_mpp

tests/plugins/channeld_fakenet.c:562–599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

560}
561
562static void add_mpp(struct info *info,
563 struct fake_htlc *htlc STEALS,
564 const struct onion_payload *payload STEALS)
565{
566 struct preimage preimage;
567 struct multi_payment *mp;
568
569 status_debug("Received payment at %s", current_node->name);
570 mp = add_payment_part(info, htlc, payload);
571 if (!mp)
572 return;
573
574 /* Completed payment. Guess payment_hash */
575 memset(&preimage, 0, sizeof(preimage));
576 for (size_t n = 0; n < 256; n++) {
577 struct sha256 hash;
578 preimage.r[0] = n;
579 sha256(&hash, &preimage, sizeof(preimage));
580 if (sha256_eq(&hash, &mp->payment_hash)) {
581 for (size_t i = 0; i < tal_count(mp->payments); i++) {
582 struct payment *p = mp->payments[i];
583 succeed(info, p->htlc, p->payload, &preimage);
584 }
585 tal_free(mp);
586 return;
587 }
588 status_debug("payment_hash %zu = %s",
589 n, fmt_sha256(tmpctx, &hash));
590 }
591
592 /* Unknown, fail them all. */
593 for (size_t i = 0; i < tal_count(mp->payments); i++) {
594 struct payment *p = mp->payments[i];
595 fail(info, p->htlc, p->payload,
596 WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS);
597 }
598 tal_free(mp);
599}
600
601static void destroy_reservation(struct reservation *r,
602 struct info *info)

Callers 1

forward_htlcFunction · 0.85

Calls 6

add_payment_partFunction · 0.85
succeedFunction · 0.85
tal_freeFunction · 0.85
fmt_sha256Function · 0.85
failFunction · 0.85
sha256Class · 0.70

Tested by

no test coverage detected