| 560 | } |
| 561 | |
| 562 | static 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 | |
| 601 | static void destroy_reservation(struct reservation *r, |
| 602 | struct info *info) |
no test coverage detected