diff --git a/plugins/renepay/chan_extra.c b/plugins/renepay/chan_extra.c index 1caa17a24..46e3ff499 100644 --- a/plugins/renepay/chan_extra.c +++ b/plugins/renepay/chan_extra.c @@ -24,9 +24,10 @@ const char *fmt_chan_extra_map(const tal_t *ctx, const char *scid_str = fmt_short_channel_id(this_ctx, ch->scid); for (int dir = 0; dir < 2; ++dir) { tal_append_fmt( - &buff, "%s[%d]:(%s,%s)\n", scid_str, dir, + &buff, "%s[%d]:(%s,%s) htlc: %s\n", scid_str, dir, fmt_amount_msat(this_ctx, ch->half[dir].known_min), - fmt_amount_msat(this_ctx, ch->half[dir].known_max)); + fmt_amount_msat(this_ctx, ch->half[dir].known_max), + fmt_amount_msat(this_ctx, ch->half[dir].htlc_total)); } } tal_free(this_ctx); diff --git a/plugins/renepay/flow.c b/plugins/renepay/flow.c index 757c07af2..39b9864b1 100644 --- a/plugins/renepay/flow.c +++ b/plugins/renepay/flow.c @@ -34,6 +34,39 @@ function_fail: return tal_free(amounts); } +const char *fmt_flows(const tal_t *ctx, const struct gossmap *gossmap, + struct chan_extra_map *chan_extra_map, + struct flow **flows) +{ + tal_t *this_ctx = tal(ctx, tal_t); + double tot_prob = + flowset_probability(tmpctx, flows, gossmap, chan_extra_map, NULL); + assert(tot_prob >= 0); + char *buff = tal_fmt(ctx, "%zu subflows, prob %2lf\n", tal_count(flows), + tot_prob); + for (size_t i = 0; i < tal_count(flows); i++) { + struct amount_msat fee, delivered; + tal_append_fmt(&buff, " "); + for (size_t j = 0; j < tal_count(flows[i]->path); j++) { + struct short_channel_id scid = + gossmap_chan_scid(gossmap, flows[i]->path[j]); + tal_append_fmt(&buff, "%s%s", j ? "->" : "", + fmt_short_channel_id(this_ctx, scid)); + } + delivered = flows[i]->amount; + if (!flow_fee(&fee, flows[i])) { + abort(); + } + tal_append_fmt(&buff, " prob %.2f, %s delivered with fee %s\n", + flows[i]->success_prob, + fmt_amount_msat(this_ctx, delivered), + fmt_amount_msat(this_ctx, fee)); + } + + tal_free(this_ctx); + return buff; +} + /* Returns the greatest amount we can deliver to the destination using this * route. It takes into account the current knowledge, pending HTLC, * htlc_max and fees. diff --git a/plugins/renepay/flow.h b/plugins/renepay/flow.h index f097e631b..d0ad983d5 100644 --- a/plugins/renepay/flow.h +++ b/plugins/renepay/flow.h @@ -18,6 +18,10 @@ struct flow { struct amount_msat amount; }; +const char *fmt_flows(const tal_t *ctx, const struct gossmap *gossmap, + struct chan_extra_map *chan_extra_map, + struct flow **flows); + /* Helper to access the half chan at flow index idx */ const struct half_chan *flow_edge(const struct flow *flow, size_t idx); diff --git a/plugins/renepay/route.c b/plugins/renepay/route.c index 0e3c4589f..06ac2526f 100644 --- a/plugins/renepay/route.c +++ b/plugins/renepay/route.c @@ -97,13 +97,15 @@ function_fail: const char *fmt_route_path(const tal_t *ctx, const struct route *route) { + tal_t *this_ctx = tal(ctx, tal_t); char *s = tal_strdup(ctx, ""); const size_t pathlen = tal_count(route->hops); for (size_t i = 0; i < pathlen; i++) { const struct short_channel_id_dir scidd = hop_to_scidd(&route->hops[i]); - tal_append_fmt(&s, "-%s->", - fmt_short_channel_id(tmpctx, scidd.scid)); + tal_append_fmt(&s, "%s%s", i ? "->" : "", + fmt_short_channel_id(this_ctx, scidd.scid)); } + tal_free(this_ctx); return s; }