| 44 | } |
| 45 | |
| 46 | void 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); |
no test coverage detected