select_inchan_mpp * * @brief fallback in case select_inchan cannot find a *single* * channel capable of accepting the payment as a whole. * Also the main routehint-selector if we are completely unpublished * (i.e. all our channels are unpublished), since if we are completely * unpublished then the payer cannot fall back to just directly routing * to us. */
| 623 | * to us. |
| 624 | */ |
| 625 | static struct route_info **select_inchan_mpp(const tal_t *ctx, |
| 626 | struct lightningd *ld, |
| 627 | struct amount_msat amount_needed, |
| 628 | struct routehint_candidate |
| 629 | *candidates) |
| 630 | { |
| 631 | /* The total amount we have gathered for incoming channels. */ |
| 632 | struct amount_msat gathered; |
| 633 | /* Routehint array. */ |
| 634 | struct route_info **routehints; |
| 635 | |
| 636 | gathered = AMOUNT_MSAT(0); |
| 637 | routehints = tal_arr(ctx, struct route_info *, 0); |
| 638 | |
| 639 | /* Sort by rr_number, so we get fresh channels. */ |
| 640 | asort(candidates, tal_count(candidates), cmp_rr_number, ld); |
| 641 | for (size_t i = 0; i < tal_count(candidates); i++) { |
| 642 | if (amount_msat_greater_eq(gathered, amount_needed)) |
| 643 | break; |
| 644 | |
| 645 | /* Add to current routehints set. */ |
| 646 | if (!amount_msat_accumulate(&gathered, candidates[i].capacity)) { |
| 647 | log_broken(ld->log, |
| 648 | "Gathered channel capacity overflow: " |
| 649 | "%s + %s", |
| 650 | fmt_amount_msat(tmpctx, gathered), |
| 651 | fmt_amount_msat(tmpctx, candidates[i].capacity)); |
| 652 | continue; |
| 653 | } |
| 654 | tal_arr_expand(&routehints, |
| 655 | tal_dup(routehints, struct route_info, |
| 656 | candidates[i].r)); |
| 657 | /* Put to the back of the round-robin list */ |
| 658 | candidates[i].c->rr_number = ld->rr_counter++; |
| 659 | } |
| 660 | |
| 661 | return routehints; |
| 662 | } |
| 663 | |
| 664 | static struct route_info **select_inchan_all(const tal_t *ctx, |
| 665 | struct lightningd *ld, |
no test coverage detected