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

Function add_hintchan

plugins/renepay/mods.c:467–550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467static void add_hintchan(struct payment *payment, const struct node_id *src,
468 const struct node_id *dst, u16 cltv_expiry_delta,
469 const struct short_channel_id scid, u32 fee_base_msat,
470 u32 fee_proportional_millionths,
471 const struct amount_msat *chan_htlc_min,
472 const struct amount_msat *chan_htlc_max)
473{
474 assert(payment);
475 assert(payment->local_gossmods);
476
477 const char *errmsg;
478 struct chan_extra *ce =
479 uncertainty_find_channel(pay_plugin->uncertainty, scid);
480
481 if (!ce) {
482 struct short_channel_id_dir scidd;
483 /* We assume any HTLC is allowed */
484 struct amount_msat htlc_min = AMOUNT_MSAT(0), htlc_max = MAX_CAPACITY;
485
486 if (chan_htlc_min)
487 htlc_min = *chan_htlc_min;
488 if (chan_htlc_max)
489 htlc_max = *chan_htlc_max;
490
491 struct amount_msat fee_base = amount_msat(fee_base_msat);
492 bool enabled = true;
493 scidd.scid = scid;
494 scidd.dir = node_id_idx(src, dst);
495
496 /* This channel is not public, we don't know his capacity
497 One possible solution is set the capacity to
498 MAX_CAP and the state to [0,MAX_CAP]. Alternatively we could
499 the capacity to amount and state to [amount,amount], but that
500 wouldn't work if the recepient provides more than one hints
501 telling us to partition the payment in multiple routes. */
502 ce = uncertainty_add_channel(pay_plugin->uncertainty, scid,
503 MAX_CAPACITY);
504 if (!ce) {
505 errmsg = tal_fmt(tmpctx,
506 "Unable to find/add scid=%s in the "
507 "local uncertainty network",
508 fmt_short_channel_id(tmpctx, scid));
509 goto function_error;
510 }
511 /* FIXME: features? */
512 if (!gossmap_local_addchan(payment->local_gossmods, src, dst,
513 scid, MAX_CAPACITY, NULL) ||
514 !gossmap_local_updatechan(
515 payment->local_gossmods, &scidd,
516 &enabled, &htlc_min, &htlc_max,
517 &fee_base, &fee_proportional_millionths,
518 &cltv_expiry_delta)) {
519 errmsg = tal_fmt(
520 tmpctx,
521 "Failed to update scid=%s in the local_gossmods.",
522 fmt_short_channel_id(tmpctx, scid));
523 goto function_error;
524 }

Callers 3

selfpay_cbFunction · 0.85
routehints_doneFunction · 0.85
blindedhints_cbFunction · 0.85

Calls 8

uncertainty_find_channelFunction · 0.85
node_id_idxFunction · 0.85
uncertainty_add_channelFunction · 0.85
fmt_short_channel_idFunction · 0.85
gossmap_local_addchanFunction · 0.85
gossmap_local_updatechanFunction · 0.85
amount_msatClass · 0.70
plugin_logFunction · 0.50

Tested by

no test coverage detected