| 414 | } |
| 415 | |
| 416 | static void channel_hints_update(struct payment *p, |
| 417 | const struct short_channel_id scid, |
| 418 | int direction, bool enabled, bool local, |
| 419 | const struct amount_msat *estimated_capacity, |
| 420 | const struct amount_msat overall_capacity, |
| 421 | u16 *htlc_budget) |
| 422 | { |
| 423 | struct payment *root = payment_root(p); |
| 424 | struct short_channel_id_dir *scidd = |
| 425 | tal(tmpctx, struct short_channel_id_dir); |
| 426 | struct channel_hint *hint; |
| 427 | scidd->scid = scid; |
| 428 | scidd->dir = direction; |
| 429 | |
| 430 | /* Local channels must have an HTLC budget */ |
| 431 | assert(!local || htlc_budget != NULL); |
| 432 | |
| 433 | channel_hint_set_add(root->hints, clock_time().ts.tv_sec, scidd, enabled, |
| 434 | estimated_capacity, overall_capacity, htlc_budget); |
| 435 | |
| 436 | hint = channel_hint_set_find(root->hints, scidd); |
| 437 | |
| 438 | if (local) { |
| 439 | hint->local = tal_free(hint->local); |
| 440 | hint->local = tal(root->hints, struct local_hint); |
| 441 | hint->local->htlc_budget = *htlc_budget; |
| 442 | } |
| 443 | |
| 444 | /* If the channel is marked as enabled it must have an estimate. */ |
| 445 | assert(!enabled || estimated_capacity != NULL); |
| 446 | |
| 447 | if (hint != NULL) { |
| 448 | paymod_log(p, LOG_DBG, |
| 449 | "Updated a channel hint for %s: " |
| 450 | "enabled %s, " |
| 451 | "estimated capacity %s", |
| 452 | fmt_short_channel_id_dir(tmpctx, &hint->scid), |
| 453 | hint->enabled ? "true" : "false", |
| 454 | hint->enabled ? fmt_amount_msat(tmpctx, hint->estimated_capacity) : "UNKNOWN"); |
| 455 | channel_hint_notify(p->plugin, hint); |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | static struct amount_msat payment_route_fee(struct payment *p) |
| 460 | { |
no test coverage detected