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

Function json_add_bolt11

common/bolt11_json.c:38–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38void json_add_bolt11(struct json_stream *response,
39 const struct bolt11 *b11)
40{
41 json_add_string(response, "currency", b11->chain->lightning_hrp);
42 json_add_u64(response, "created_at", b11->timestamp);
43 json_add_u64(response, "expiry", b11->expiry);
44 json_add_node_id(response, "payee", &b11->receiver_id);
45 if (b11->msat)
46 json_add_amount_msat(response, "amount_msat", *b11->msat);
47 if (b11->description)
48 json_add_string(response, "description", b11->description);
49 if (b11->description_hash)
50 json_add_sha256(response, "description_hash",
51 b11->description_hash);
52 json_add_num(response, "min_final_cltv_expiry",
53 b11->min_final_cltv_expiry);
54 if (b11->payment_secret)
55 json_add_secret(response, "payment_secret",
56 b11->payment_secret);
57 if (b11->features)
58 json_add_hex_talarr(response, "features", b11->features);
59 if (b11->metadata)
60 json_add_hex_talarr(response, "payment_metadata", b11->metadata);
61 if (tal_count(b11->fallbacks)) {
62 json_array_start(response, "fallbacks");
63 for (size_t i = 0; i < tal_count(b11->fallbacks); i++)
64 json_add_fallback(response, NULL,
65 b11->fallbacks[i], b11->chain);
66 json_array_end(response);
67 }
68
69 if (tal_count(b11->routes)) {
70 size_t i, n;
71
72 json_array_start(response, "routes");
73 for (i = 0; i < tal_count(b11->routes); i++) {
74 json_array_start(response, NULL);
75 for (n = 0; n < tal_count(b11->routes[i]); n++) {
76 json_object_start(response, NULL);
77 json_add_node_id(response, "pubkey",
78 &b11->routes[i][n].pubkey);
79 json_add_short_channel_id(response,
80 "short_channel_id",
81 b11->routes[i][n]
82 .short_channel_id);
83 json_add_u64(response, "fee_base_msat",
84 b11->routes[i][n].fee_base_msat);
85 json_add_u64(response, "fee_proportional_millionths",
86 b11->routes[i][n].fee_proportional_millionths);
87 json_add_num(response, "cltv_expiry_delta",
88 b11->routes[i][n]
89 .cltv_expiry_delta);
90 json_object_end(response);
91 }
92 json_array_end(response);
93 }
94 json_array_end(response);
95 }

Callers 1

json_decodeFunction · 0.85

Calls 15

json_add_u64Function · 0.85
json_add_node_idFunction · 0.85
json_add_amount_msatFunction · 0.85
json_add_sha256Function · 0.85
json_add_numFunction · 0.85
json_add_secretFunction · 0.85
json_add_hex_talarrFunction · 0.85
json_array_startFunction · 0.85
json_add_fallbackFunction · 0.85
json_array_endFunction · 0.85
json_object_startFunction · 0.85

Tested by

no test coverage detected