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

Function json_add_bolt11

common/bolt11_json.c:46–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

json_decodeFunction · 0.50

Calls 15

json_add_fallbackFunction · 0.85
tal_freeFunction · 0.85
fmt_signatureFunction · 0.85
json_add_stringFunction · 0.70
json_add_u64Function · 0.70
json_add_node_idFunction · 0.70
json_add_sha256Function · 0.70
json_add_numFunction · 0.70
json_add_secretFunction · 0.70
json_add_hex_talarrFunction · 0.70
json_array_startFunction · 0.70

Tested by

no test coverage detected