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

Function add_routehints

lightningd/invoice.c:698–834  ·  view source on GitHub ↗

Add routehints based on listincoming results: NULL means success. */

Source from the content-addressed store, hash-verified

696
697/* Add routehints based on listincoming results: NULL means success. */
698static struct command_result *
699add_routehints(struct invoice_info *info,
700 const char *buffer,
701 const jsmntok_t *toks,
702 bool *warning_mpp,
703 bool *warning_capacity,
704 bool *warning_deadends,
705 bool *warning_offline,
706 bool *warning_private_unused)
707{
708 const struct chanhints *chanhints = info->chanhints;
709 bool node_unpublished;
710 struct amount_msat avail_capacity, deadend_capacity, offline_capacity,
711 private_capacity;
712 struct routehint_candidate *candidates;
713 struct amount_msat total, needed;
714
715 /* Dev code can force routes. */
716 if (info->b11->routes) {
717 *warning_mpp = *warning_capacity = *warning_deadends
718 = *warning_offline = *warning_private_unused
719 = false;
720 return NULL;
721 }
722
723 candidates = routehint_candidates(tmpctx, info->cmd->ld,
724 buffer, toks,
725 chanhints ? &chanhints->expose_all_private : NULL,
726 chanhints ? chanhints->hints : NULL,
727 &node_unpublished,
728 &avail_capacity,
729 &private_capacity,
730 &deadend_capacity,
731 &offline_capacity);
732
733 /* If they told us to use scids and we couldn't, fail. */
734 if (tal_count(candidates) == 0
735 && chanhints && tal_count(chanhints->hints) != 0) {
736 return command_fail(info->cmd,
737 INVOICE_HINTS_GAVE_NO_ROUTES,
738 "None of those hints were suitable local channels");
739 }
740
741 needed = info->b11->msat ? *info->b11->msat : AMOUNT_MSAT(1);
742
743 /* --payment-fronting-node means use all candidates. */
744 if (tal_count(info->cmd->ld->fronting_nodes))
745 info->b11->routes = select_inchan_all(info->b11, info->cmd->ld, candidates);
746
747 /* If we are not completely unpublished, try with reservoir
748 * sampling first.
749 *
750 * Why do we not do this if we are completely unpublished?
751 * Because it is possible that multiple invoices will, by
752 * chance, select the same channel as routehint.
753 * This single channel might not be able to accept all the
754 * incoming payments on all the invoices generated.
755 * If we were published, that is fine because the payer can

Callers 1

listincoming_doneFunction · 0.85

Calls 12

routehint_candidatesFunction · 0.85
select_inchan_allFunction · 0.85
select_inchanFunction · 0.85
select_inchan_mppFunction · 0.85
amount_msat_addFunction · 0.85
amount_msat_accumulateFunction · 0.85
amount_msat_greater_eqFunction · 0.85
amount_msat_greaterFunction · 0.85
abortFunction · 0.85
command_failFunction · 0.70
fatalFunction · 0.70
fmt_amount_msatFunction · 0.50

Tested by

no test coverage detected