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

Function payment_route_check

plugins/libplugin-pay.c:670–710  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

668}
669
670static bool payment_route_check(const struct gossmap *gossmap,
671 const struct gossmap_chan *c,
672 int dir,
673 struct amount_msat amount,
674 struct payment *p)
675{
676 struct short_channel_id_dir scidd;
677 const struct channel_hint *hint;
678
679 if (dst_is_excluded(gossmap, c, dir, payment_root(p)->excluded_nodes))
680 return false;
681
682 if (dst_is_excluded(gossmap, c, dir, p->temp_exclusion))
683 return false;
684
685 scidd.scid = gossmap_chan_scid(gossmap, c);
686 scidd.dir = dir;
687 hint = channel_hint_set_find(payment_root(p)->hints, &scidd);
688 if (!hint)
689 return true;
690
691 paymod_log(p, LOG_DBG,
692 "Checking hint {.scid=%s, .enabled=%d, .estimate=%s}",
693 fmt_short_channel_id_dir(tmpctx, &hint->scid), hint->enabled,
694 fmt_amount_msat(tmpctx, hint->estimated_capacity));
695
696 if (!hint->enabled)
697 return false;
698
699 if (amount_msat_greater_eq(amount, hint->estimated_capacity))
700 /* We exclude on equality because we've set the
701 * estimate to the smallest failed attempt. */
702 return false;
703
704 if (hint->local && hint->local->htlc_budget == 0)
705 /* If we cannot add any HTLCs to the channel we
706 * shouldn't look for a route through that channel */
707 return false;
708
709 return true;
710}
711
712static bool payment_route_can_carry(const struct gossmap *map,
713 const struct gossmap_chan *c,

Callers 2

payment_route_can_carryFunction · 0.85

Calls 8

dst_is_excludedFunction · 0.85
payment_rootFunction · 0.85
gossmap_chan_scidFunction · 0.85
channel_hint_set_findFunction · 0.85
paymod_logFunction · 0.85
fmt_short_channel_id_dirFunction · 0.85
amount_msat_greater_eqFunction · 0.85
fmt_amount_msatFunction · 0.50

Tested by

no test coverage detected