| 90 | } |
| 91 | |
| 92 | static struct command_result *json_renepaystatus(struct command *cmd, |
| 93 | const char *buf, |
| 94 | const jsmntok_t *params) |
| 95 | { |
| 96 | const char *invstring; |
| 97 | struct json_stream *ret; |
| 98 | |
| 99 | if (!param(cmd, buf, params, |
| 100 | p_opt("invstring", param_invstring, &invstring), |
| 101 | NULL)) |
| 102 | return command_param_failed(); |
| 103 | |
| 104 | ret = jsonrpc_stream_success(cmd); |
| 105 | json_array_start(ret, "paystatus"); |
| 106 | if(invstring) |
| 107 | { |
| 108 | /* select the payment that matches this invoice */ |
| 109 | |
| 110 | if (bolt12_has_prefix(invstring)) |
| 111 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 112 | "BOLT12 invoices are not yet supported."); |
| 113 | |
| 114 | const char *fail; |
| 115 | struct bolt11 *b11 = |
| 116 | bolt11_decode(tmpctx, invstring, plugin_feature_set(cmd->plugin), |
| 117 | NULL, chainparams, &fail); |
| 118 | if (b11 == NULL) |
| 119 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 120 | "Invalid bolt11: %s", fail); |
| 121 | |
| 122 | struct payment *payment = |
| 123 | payment_map_get(pay_plugin->payment_map, b11->payment_hash); |
| 124 | |
| 125 | if(payment) |
| 126 | { |
| 127 | json_object_start(ret, NULL); |
| 128 | json_add_payment(ret, payment); |
| 129 | json_object_end(ret); |
| 130 | } |
| 131 | }else |
| 132 | { |
| 133 | /* show all payments */ |
| 134 | struct payment_map_iter it; |
| 135 | for (struct payment *p = |
| 136 | payment_map_first(pay_plugin->payment_map, &it); |
| 137 | p; p = payment_map_next(pay_plugin->payment_map, &it)) { |
| 138 | json_object_start(ret, NULL); |
| 139 | json_add_payment(ret, p); |
| 140 | json_object_end(ret); |
| 141 | } |
| 142 | } |
| 143 | json_array_end(ret); |
| 144 | |
| 145 | return command_finished(cmd, ret); |
| 146 | } |
| 147 | |
| 148 | static struct command_result * payment_start(struct payment *p) |
| 149 | { |
nothing calls this directly
no test coverage detected