1- #include "ccan/tal/tal.h"
21#include "config.h"
3- #include "jsmn.h"
42#include <assert.h>
53#include <bitcoin/address.h>
64#include <bitcoin/base58.h>
1917#include <common/route.h>
2018#include <stdbool.h>
2119#include <stddef.h>
20+ #include <stdint.h>
21+ #include <stdio.h>
2222
2323struct param {
2424 const char * name ;
@@ -342,7 +342,7 @@ const char *param_subcommand(struct command *cmd, const char *buffer,
342342}
343343
344344bool param (struct command * cmd , const char * buffer ,
345- const jsmntok_t tokens [] , ...)
345+ const jsmntok_t * tokens , ...)
346346{
347347 struct param * params = tal_arr (tmpctx , struct param , 0 );
348348 const char * name ;
@@ -357,15 +357,8 @@ bool param(struct command *cmd, const char *buffer,
357357 if (streq (name , "" )) {
358358 allow_extra = true;
359359 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 ;
368360 }
361+
369362 if (!param_add (& params , name , style , cbx , arg )) {
370363 /* We really do ignore this return! */
371364 struct command_result * ignore ;
@@ -1111,23 +1104,33 @@ struct command_result *param_pubkey(struct command *cmd, const char *name,
11111104}
11121105
11131106struct command_result * param_paginator (struct command * cmd , const char * name ,
1114- const char * buffer , const jsmntok_t * tok )
1107+ const char * buffer , const jsmntok_t * tok ,
1108+ struct jsonrpc_paginator * * paginator )
11151109{
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)
1110+ const jsmntok_t * batch_tok , * offset_tok , * limit_tok ;
1111+ u64 * limit , * offset ;
1112+ const char * * batch ;
1113+
1114+ batch = NULL ;
1115+ batch_tok = json_get_member (buffer , tok , "batch" );
1116+ if (batch_tok )
1117+ json_to_strarr (cmd , buffer , batch_tok , & batch );
1118+
1119+ offset = tal (cmd , uint64_t );
1120+ offset_tok = json_get_member (buffer , tok , "offset" );
1121+ if (offset_tok )
1122+ json_to_u64 (buffer , offset_tok , offset );
1123+
1124+ limit = tal (cmd , uint64_t );
1125+ limit_tok = json_get_member (buffer , tok , "limit" );
1126+ if (limit_tok )
1127+ json_to_u64 (buffer , limit_tok , limit );
1128+
1129+ if (batch || (limit && offset )) {
1130+ * paginator = new_paginator (cmd , batch , limit , offset );
1131+ assert (paginator );
11241132 return NULL ;
1125-
1126- tok_tmp = json_get_member(buffer, tok, "limit");
1127- if (tok_tmp)
1128- return NULL;
1129-
1133+ }
11301134 return command_fail_badparam (cmd , name , buffer , tok ,
1131- "paginator request format in the wrong way!");*/
1132- return NULL ;
1135+ "paginator request format in the wrong way!" );
11331136}
0 commit comments