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

Function json_listsendpays

lightningd/pay.c:2204–2294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

param_checkFunction · 0.85
bolt11_decodeFunction · 0.85
invoice_decodeFunction · 0.85
json_array_startFunction · 0.85
payments_by_hashFunction · 0.85
payments_by_statusFunction · 0.85
payments_firstFunction · 0.85
payments_nextFunction · 0.85
json_object_startFunction · 0.85
json_add_payment_fieldsFunction · 0.85
payment_get_detailsFunction · 0.85
json_object_endFunction · 0.85

Tested by

no test coverage detected