| 2199 | } |
| 2200 | |
| 2201 | static struct command_result *json_listsendpays(struct command *cmd, |
| 2202 | const char *buffer, |
| 2203 | const jsmntok_t *obj UNNEEDED, |
| 2204 | const jsmntok_t *params) |
| 2205 | { |
| 2206 | struct json_stream *response; |
| 2207 | struct sha256 *rhash; |
| 2208 | const char *invstring; |
| 2209 | enum payment_status *status; |
| 2210 | struct db_stmt *stmt; |
| 2211 | enum wait_index *listindex; |
| 2212 | u64 *liststart; |
| 2213 | u32 *listlimit; |
| 2214 | |
| 2215 | if (!param_check(cmd, buffer, params, |
| 2216 | /* FIXME: parameter should be invstring now */ |
| 2217 | p_opt("bolt11", param_invstring, &invstring), |
| 2218 | p_opt("payment_hash", param_sha256, &rhash), |
| 2219 | p_opt("status", param_payment_status, &status), |
| 2220 | p_opt("index", param_index, &listindex), |
| 2221 | p_opt_def("start", param_u64, &liststart, 0), |
| 2222 | p_opt("limit", param_u32, &listlimit), |
| 2223 | NULL)) |
| 2224 | return command_param_failed(); |
| 2225 | |
| 2226 | if (rhash && invstring) { |
| 2227 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 2228 | "Can only specify one of" |
| 2229 | " {bolt11} or {payment_hash}"); |
| 2230 | } |
| 2231 | |
| 2232 | if (*liststart != 0 && !listindex) { |
| 2233 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 2234 | "Can only specify {start} with {index}"); |
| 2235 | } |
| 2236 | if (listlimit && !listindex) { |
| 2237 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 2238 | "Can only specify {limit} with {index}"); |
| 2239 | } |
| 2240 | |
| 2241 | if ((rhash || invstring) && *liststart != 0) { |
| 2242 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 2243 | "Cannot use start with bolt11 or payment_hash"); |
| 2244 | } |
| 2245 | |
| 2246 | if (invstring) { |
| 2247 | struct bolt11 *b11; |
| 2248 | const char *fail; |
| 2249 | |
| 2250 | b11 = bolt11_decode(cmd, invstring, cmd->ld->our_features, NULL, |
| 2251 | chainparams, &fail); |
| 2252 | if (b11) { |
| 2253 | rhash = &b11->payment_hash; |
| 2254 | } else { |
| 2255 | struct tlv_invoice *b12; |
| 2256 | |
| 2257 | b12 = invoice_decode(cmd, invstring, strlen(invstring), |
| 2258 | cmd->ld->our_features, |
nothing calls this directly
no test coverage detected