pay: Make the channel_hints global

We attach the hints to the plugin, so they get shared across multiple
payments.
This commit is contained in:
Christian Decker 2024-07-29 15:02:51 +02:00
parent 5225218094
commit b897b4365d
3 changed files with 8 additions and 4 deletions

View file

@ -94,10 +94,6 @@ static bool dijkstra_to_hops(struct route_hop **hops,
/* OK, populate other fields. */
c = dijkstra_best_chan(dij, curidx);
gossmap_chan_get_capacity(gossmap, c, &total);
if (!amount_sat_to_msat(&(*hops)[num_hops].total_amount, total))
abort();
if (c->half[0].nodeidx == curidx) {
(*hops)[num_hops].direction = 0;
} else {
@ -113,6 +109,8 @@ static bool dijkstra_to_hops(struct route_hop **hops,
if (!dijkstra_to_hops(hops, gossmap, dij, next, amount, cltv))
return false;
gossmap_chan_get_capacity(gossmap, c, &total);
(*hops)[num_hops].total_amount.millisatoshis = total.satoshis * 1000; /* Raw: simpler. */
(*hops)[num_hops].amount = *amount;
(*hops)[num_hops].delay = *cltv;

View file

@ -1618,6 +1618,7 @@ handle_intermediate_failure(struct command *cmd,
break;
case WIRE_TEMPORARY_CHANNEL_FAILURE: {
memcheck(&errchan->amount, sizeof(struct amount_msat));
estimated = errchan->amount;
/* Subtract one msat more, since we know that the amount did not

View file

@ -22,6 +22,7 @@ static struct node_id my_id;
static unsigned int maxdelay_default;
static bool exp_offers;
static bool disablempp = false;
static struct channel_hint *global_hints;
static LIST_HEAD(payments);
@ -582,6 +583,10 @@ static const char *init(struct plugin *p,
*/
/* FIXME: Typo in spec for CLTV in descripton! But it breaks our spelling check, so we omit it above */
maxdelay_default = 2016;
global_hints =
notleak_with_children(tal_arr(p, struct channel_hint, 0));
/* max-locktime-blocks deprecated in v24.05, but still grab it! */
rpc_scan(p, "listconfigs",
take(json_out_obj(NULL, NULL, NULL)),