Skip to content

Commit

Permalink
common: remove json_tok.
Browse files Browse the repository at this point in the history
Make local copies for tests, and fundchannel plugin (which just passes
params through).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell authored and niftynei committed Jul 15, 2022
1 parent a9b992f commit f12f0d6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
8 changes: 0 additions & 8 deletions common/json_tok.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,6 @@ struct command_result *param_u64(struct command *cmd, const char *name,
"should be an unsigned 64 bit integer");
}

struct command_result *param_tok(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t * tok,
const jsmntok_t **out)
{
*out = tok;
return NULL;
}

struct command_result *param_msat(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t *tok,
struct amount_msat **msat)
Expand Down
11 changes: 0 additions & 11 deletions common/json_tok.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,6 @@ struct command_result *param_short_channel_id(struct command *cmd,
const jsmntok_t *tok,
struct short_channel_id **scid);

/*
* Set the address of @out to @tok. Used as a callback by handlers that
* want to unmarshal @tok themselves.
*
* Usage of this is discouraged. Writing a local static bespoke handler is
* preferred.
*/
struct command_result *param_tok(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t * tok,
const jsmntok_t **out);

/* Ignore the token. Not usually used. */
struct command_result *param_ignore(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t *tok,
Expand Down
8 changes: 8 additions & 0 deletions common/test/run-param.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ static void sanity(void)
}
}

static struct command_result *param_tok(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t * tok,
const jsmntok_t **out)
{
*out = tok;
return NULL;
}

/*
* Make sure toks are passed through correctly, and also make sure
* optional missing toks are set to NULL.
Expand Down
9 changes: 9 additions & 0 deletions plugins/spender/fundchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ fundchannel_get_result(struct command *cmd,
const jsmntok_t *result,
void *nothing UNUSED);

/* Generally a bad idea, but makes sense here. */
static struct command_result *param_tok(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t * tok,
const jsmntok_t **out)
{
*out = tok;
return NULL;
}

/* Thin wrapper aroud multifundchannel. */
static struct command_result *
json_fundchannel(struct command *cmd,
Expand Down

0 comments on commit f12f0d6

Please sign in to comment.