I am with Cricktor.
Why legacy? And how are you related to this bounty? And what has Core Lightning / and or Rusty Russell said about the bounty.
On a side note, it does work for me I just used it to pay a bitrefill invoice so I don't know how widespread this issue really is.
-Dave
My ignorance. I am the initiator. Nothing yet.
It is the most commented ongoing issue on the Core Lightning Github page:
https://github.com/ElementsProject/lightning/issues?q=is%3Aissue+is%3Aopen+sort%3Acomments-descI can suggest these changes in libplugin-pay.c.
static bool payment_chanhints_apply_route(struct payment *p)
{
bool can_apply;
struct route_hop *current_hop;
struct channel_hint *current_hint;
struct payment *root = payment_root(p);
assert(p->route != NULL);
for (size_t i = 0; i < tal_count(p->route); i++) {
current_hop = &p->route[i];
current_hint = payment_chanhints_get(root, current_hop);
if (!current_hint)
continue;
can_apply = (!current_hint->local) || (current_hint->local->htlc_budget > 0);
can_apply &= amount_msat_greater_eq(current_hint->estimated_capacity, current_hop->amount);
if (!can_apply) {
paymod_log(p, LOG_DBG,
"Could not update the channel hint for %s. Could be a concurrent `getroute` call.",
fmt_short_channel_id_dir(tmpctx, ¤t_hint->scid));
paymod_log(p, LOG_DBG,
"Capacity: estimated_capacity=%s, hop_amount=%s. local=%s%s",
fmt_amount_msat(tmpctx, current_hint->estimated_capacity),
fmt_amount_msat(tmpctx, current_hop->amount),
current_hint->local ? "Y" : "N",
current_hint->local ? tal_fmt(tmpctx, " HTLC Budget: htlc_budget=%d", current_hint->local->htlc_budget) : "");
return false;
}
}
for (size_t i = 0; i < tal_count(p->route); i++) {
current_hop = &p->route[i];
current_hint = payment_chanhints_get(root, current_hop);
if (!current_hint)
continue;
if (current_hint->local) {
current_hint->local->htlc_budget--;
}
if (!amount_msat_sub(¤t_hint->estimated_capacity, current_hint->estimated_capacity, current_hop->amount)) {
// This should never happen due to the preemptive test above.
abort();
}
}
return true;
}
static void payment_chanhints_unapply_route(struct payment *p)
{
struct payment *root = payment_root(p);
for (size_t i = 0; i < tal_count(p->route); i++) {
struct route_hop *current_hop;
struct channel_hint *current_hint;
current_hop = &p->route[i];
current_hint = payment_chanhints_get(root, current_hop);
if (!current_hint)
continue;
if (current_hint->local)
current_hint->local->htlc_budget++;
if (!amount_msat_accumulate(¤t_hint->estimated_capacity, current_hop->amount)) {
// This should never happen, it'd mean that we unapply a route that would result in a msatoshi wrap-around.
abort();
}
}
}