|
| 1 | +#include "ccan/tal/tal.h" |
1 | 2 | #include "config.h" |
| 3 | +#include "jsmn.h" |
| 4 | +#include <assert.h> |
2 | 5 | #include <bitcoin/address.h> |
3 | 6 | #include <bitcoin/base58.h> |
4 | 7 | #include <bitcoin/feerate.h> |
|
14 | 17 | #include <common/json_command.h> |
15 | 18 | #include <common/json_param.h> |
16 | 19 | #include <common/route.h> |
| 20 | +#include <stdbool.h> |
| 21 | +#include <stddef.h> |
17 | 22 |
|
18 | 23 | struct param { |
19 | 24 | const char *name; |
@@ -352,6 +357,14 @@ bool param(struct command *cmd, const char *buffer, |
352 | 357 | if (streq(name, "")) { |
353 | 358 | allow_extra = true; |
354 | 359 | continue; |
| 360 | + } else if (streq(name, "paginator")) { |
| 361 | + struct command_result *result; |
| 362 | + if ((result = cbx(cmd, name, buffer, NULL, arg))) |
| 363 | + return result; |
| 364 | + /* we allow extra but we already made a check that are |
| 365 | + * paginator keys, so this should be safe! */ |
| 366 | + allow_extra = true; |
| 367 | + continue; |
355 | 368 | } |
356 | 369 | if (!param_add(¶ms, name, style, cbx, arg)) { |
357 | 370 | /* We really do ignore this return! */ |
@@ -439,6 +452,37 @@ struct command_result *param_string(struct command *cmd, const char *name, |
439 | 452 | return NULL; |
440 | 453 | } |
441 | 454 |
|
| 455 | +struct command_result *param_arr_str(struct command *cmd, const char *name, |
| 456 | + const char *buffer, const jsmntok_t *tok, |
| 457 | + const char ***arr) |
| 458 | +{ |
| 459 | + const jsmntok_t *curr; |
| 460 | + size_t i; |
| 461 | + |
| 462 | + if (tok->type != JSMN_ARRAY) |
| 463 | + return command_fail_badparam(cmd, name, buffer, tok, |
| 464 | + "schould be an array of string"); |
| 465 | + |
| 466 | + *arr = tal_arr(cmd, const char *, 0); |
| 467 | + json_for_each_arr(i, curr, tok) { |
| 468 | + struct json_escape *esc; |
| 469 | + const char *str; |
| 470 | + |
| 471 | + if (curr->type != JSMN_STRING) |
| 472 | + return command_fail_badparam(cmd, name, buffer, tok, |
| 473 | + "the item of the array should be a string"); |
| 474 | + |
| 475 | + esc = json_escape_string_(cmd, buffer + curr->start, |
| 476 | + curr->end - curr->start); |
| 477 | + str = json_escape_unescape(cmd, esc); |
| 478 | + tal_arr_expand(arr, str); |
| 479 | + } |
| 480 | + |
| 481 | + return NULL; |
| 482 | +} |
| 483 | + |
| 484 | + |
| 485 | + |
442 | 486 | struct command_result *param_ignore(struct command *cmd, const char *name, |
443 | 487 | const char *buffer, const jsmntok_t *tok, |
444 | 488 | const void *unused) |
@@ -1066,3 +1110,24 @@ struct command_result *param_pubkey(struct command *cmd, const char *name, |
1066 | 1110 | "should be a compressed pubkey"); |
1067 | 1111 | } |
1068 | 1112 |
|
| 1113 | +struct command_result *param_paginator(struct command *cmd, const char *name, |
| 1114 | + const char *buffer, const jsmntok_t *tok) |
| 1115 | +{ |
| 1116 | + /* |
| 1117 | + const jsmntok_t *tok_tmp; |
| 1118 | +
|
| 1119 | + tok_tmp = json_get_member(buffer, tok, "batch"); |
| 1120 | + if (tok_tmp) |
| 1121 | + return NULL; |
| 1122 | + tok_tmp = json_get_member(buffer, tok, "offset"); |
| 1123 | + if (tok_tmp) |
| 1124 | + return NULL; |
| 1125 | +
|
| 1126 | + tok_tmp = json_get_member(buffer, tok, "limit"); |
| 1127 | + if (tok_tmp) |
| 1128 | + return NULL; |
| 1129 | +
|
| 1130 | + return command_fail_badparam(cmd, name, buffer, tok, |
| 1131 | + "paginator request format in the wrong way!");*/ |
| 1132 | + return NULL; |
| 1133 | +} |
0 commit comments