| 1961 | } |
| 1962 | |
| 1963 | static void add_routehint(struct request_batch *batch, |
| 1964 | struct command *aux_cmd, |
| 1965 | struct payment *payment, |
| 1966 | const struct route_info *route) |
| 1967 | { |
| 1968 | struct xpay *xpay = xpay_of(payment->plugin); |
| 1969 | struct amount_msat big_cap; |
| 1970 | struct node_id me; |
| 1971 | |
| 1972 | node_id_from_pubkey(&me, &xpay->local_id); |
| 1973 | |
| 1974 | /* We add these channels to our private layer. We start with assuming |
| 1975 | * they have 100x the capacity we need (including fees!): we'll figure |
| 1976 | * it out quickly if we're wrong, but this gives a success probability |
| 1977 | * of 99%. */ |
| 1978 | if (!amount_msat_add(&big_cap, payment->amount, payment->maxfee) |
| 1979 | || !amount_msat_mul(&big_cap, big_cap, 100)) |
| 1980 | big_cap = payment->amount; /* Going to fail route anyway! */ |
| 1981 | |
| 1982 | for (size_t i = 0; i < tal_count(route); i++) { |
| 1983 | struct node_id next; |
| 1984 | |
| 1985 | if (i + 1 < tal_count(route)) { |
| 1986 | next = route[i+1].pubkey; |
| 1987 | } else { |
| 1988 | node_id_from_pubkey(&next, &payment->destination); |
| 1989 | } |
| 1990 | |
| 1991 | /* Don't add hints from ourselves, since we know all those, |
| 1992 | * and the error from this would be confusing! */ |
| 1993 | if (node_id_eq(&route[i].pubkey, &me)) |
| 1994 | continue; |
| 1995 | |
| 1996 | add_fake_channel(aux_cmd, batch, payment, |
| 1997 | &route[i].pubkey, &next, |
| 1998 | route[i].short_channel_id, |
| 1999 | big_cap, |
| 2000 | /* We don't know htlc_min/max */ |
| 2001 | AMOUNT_MSAT(0), big_cap, |
| 2002 | amount_msat(route[i].fee_base_msat), |
| 2003 | route[i].fee_proportional_millionths, |
| 2004 | route[i].cltv_expiry_delta); |
| 2005 | } |
| 2006 | } |
| 2007 | |
| 2008 | /* If it fails, returns error, otherwise NULL */ |
| 2009 | static char *add_blindedpath(const tal_t *ctx, |
no test coverage detected