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

Function routehint_candidates

lightningd/routehint.c:21–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21struct routehint_candidate *
22routehint_candidates(const tal_t *ctx,
23 struct lightningd *ld,
24 const char *buf,
25 const jsmntok_t *toks,
26 const bool *expose_all_private,
27 const struct short_channel_id *hints,
28 bool *none_public,
29 struct amount_msat *avail_capacity,
30 struct amount_msat *private_capacity,
31 struct amount_msat *deadend_capacity,
32 struct amount_msat *offline_capacity)
33{
34 struct routehint_candidate *candidates, *privcandidates;
35 const jsmntok_t *t, *arr;
36 size_t i;
37
38 log_debug(ld->log, "routehint: %.*s",
39 json_tok_full_len(toks),
40 json_tok_full(buf, toks));
41
42 /* We get the full JSON, including result. */
43 t = json_get_member(buf, toks, "result");
44 if (!t)
45 fatal("Missing result from listincoming: %.*s",
46 json_tok_full_len(toks),
47 json_tok_full(buf, toks));
48 arr = json_get_member(buf, t, "incoming");
49
50 candidates = tal_arr(ctx, struct routehint_candidate, 0);
51 privcandidates = tal_arr(tmpctx, struct routehint_candidate, 0);
52 *none_public = true;
53 *deadend_capacity = AMOUNT_MSAT(0);
54 *offline_capacity = AMOUNT_MSAT(0);
55 *avail_capacity = AMOUNT_MSAT(0);
56 *private_capacity = AMOUNT_MSAT(0);
57
58 /* We combine the JSON output which knows the peers' details,
59 * with our internal information */
60 json_for_each_arr(i, t, arr) {
61 struct amount_msat capacity;
62 const char *err;
63 struct routehint_candidate candidate;
64 struct amount_msat fee_base, htlc_max;
65 struct route_info *r;
66 struct peer *peer;
67 bool is_public;
68
69 r = tal(tmpctx, struct route_info);
70
71 err = json_scan(tmpctx, buf, t,
72 "{id:%"
73 ",short_channel_id:%"
74 ",fee_base_msat:%"
75 ",fee_proportional_millionths:%"
76 ",cltv_expiry_delta:%"
77 ",htlc_max_msat:%"
78 ",incoming_capacity_msat:%"

Callers 1

add_routehintsFunction · 0.85

Calls 15

peer_by_idFunction · 0.85
amount_msat_greaterFunction · 0.85
scid_in_arrFunction · 0.85
amount_msat_addFunction · 0.85
tal_freeFunction · 0.85
fatalFunction · 0.70
find_channel_by_scidFunction · 0.70
find_channel_by_aliasFunction · 0.70
amount_msatClass · 0.70
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50

Tested by

no test coverage detected