mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
Move json and param core functionality into common, for plugins.
json_escaped.[ch], param.[ch] and jsonrpc_errors.h move from lightningd/ to common/. Tests moved too. We add a new 'common/json_tok.[ch]' for the common parameter parsing routines which a plugin might want, taking them out of lightningd/json.c (which now only contains the lightningd-specific ones). The rest is mainly fixing up includes. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
c28cbf4a61
commit
d7e233e47d
37 changed files with 374 additions and 341 deletions
|
@ -25,10 +25,13 @@ COMMON_SRC_NOGEN := \
|
||||||
common/initial_commit_tx.c \
|
common/initial_commit_tx.c \
|
||||||
common/io_lock.c \
|
common/io_lock.c \
|
||||||
common/json.c \
|
common/json.c \
|
||||||
|
common/json_escaped.c \
|
||||||
|
common/json_tok.c \
|
||||||
common/key_derive.c \
|
common/key_derive.c \
|
||||||
common/keyset.c \
|
common/keyset.c \
|
||||||
common/memleak.c \
|
common/memleak.c \
|
||||||
common/msg_queue.c \
|
common/msg_queue.c \
|
||||||
|
common/param.c \
|
||||||
common/peer_billboard.c \
|
common/peer_billboard.c \
|
||||||
common/peer_failed.c \
|
common/peer_failed.c \
|
||||||
common/permute_tx.c \
|
common/permute_tx.c \
|
||||||
|
@ -52,7 +55,7 @@ COMMON_SRC_NOGEN := \
|
||||||
|
|
||||||
COMMON_SRC_GEN := common/gen_status_wire.c common/gen_peer_status_wire.c
|
COMMON_SRC_GEN := common/gen_status_wire.c common/gen_peer_status_wire.c
|
||||||
|
|
||||||
COMMON_HEADERS_NOGEN := $(COMMON_SRC_NOGEN:.c=.h) common/overflows.h common/htlc.h common/status_levels.h common/json_command.h
|
COMMON_HEADERS_NOGEN := $(COMMON_SRC_NOGEN:.c=.h) common/overflows.h common/htlc.h common/status_levels.h common/json_command.h common/jsonrpc_errors.h
|
||||||
COMMON_HEADERS_GEN := common/gen_htlc_state_names.h common/gen_status_wire.h common/gen_peer_status_wire.h
|
COMMON_HEADERS_GEN := common/gen_htlc_state_names.h common/gen_status_wire.h common/gen_peer_status_wire.h
|
||||||
|
|
||||||
COMMON_HEADERS := $(COMMON_HEADERS_GEN) $(COMMON_HEADERS_NOGEN)
|
COMMON_HEADERS := $(COMMON_HEADERS_GEN) $(COMMON_HEADERS_NOGEN)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <lightningd/json_escaped.h>
|
#include <common/json_escaped.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
struct json_escaped *json_escaped_string_(const tal_t *ctx,
|
struct json_escaped *json_escaped_string_(const tal_t *ctx,
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef LIGHTNING_LIGHTNINGD_JSON_ESCAPED_H
|
#ifndef LIGHTNING_COMMON_JSON_ESCAPED_H
|
||||||
#define LIGHTNING_LIGHTNINGD_JSON_ESCAPED_H
|
#define LIGHTNING_COMMON_JSON_ESCAPED_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <common/json.h>
|
#include <common/json.h>
|
||||||
|
|
||||||
|
@ -32,4 +32,4 @@ struct json_escaped *json_escaped_string_(const tal_t *ctx,
|
||||||
/* Be very careful here! Can fail! Doesn't handle \u: use UTF-8 please. */
|
/* Be very careful here! Can fail! Doesn't handle \u: use UTF-8 please. */
|
||||||
const char *json_escaped_unescape(const tal_t *ctx,
|
const char *json_escaped_unescape(const tal_t *ctx,
|
||||||
const struct json_escaped *esc);
|
const struct json_escaped *esc);
|
||||||
#endif /* LIGHTNING_LIGHTNINGD_JSON_ESCAPED_H */
|
#endif /* LIGHTNING_COMMON_JSON_ESCAPED_H */
|
184
common/json_tok.c
Normal file
184
common/json_tok.c
Normal file
|
@ -0,0 +1,184 @@
|
||||||
|
#include <ccan/mem/mem.h>
|
||||||
|
#include <ccan/str/hex/hex.h>
|
||||||
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/json_escaped.h>
|
||||||
|
#include <common/json_tok.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
|
#include <common/param.h>
|
||||||
|
|
||||||
|
bool json_tok_array(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
const jsmntok_t **arr)
|
||||||
|
{
|
||||||
|
if (tok->type == JSMN_ARRAY)
|
||||||
|
return (*arr = tok);
|
||||||
|
|
||||||
|
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
|
"'%s' should be an array, not '%.*s'",
|
||||||
|
name, tok->end - tok->start, buffer + tok->start);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_tok_bool(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
bool **b)
|
||||||
|
{
|
||||||
|
*b = tal(cmd, bool);
|
||||||
|
if (tok->type == JSMN_PRIMITIVE) {
|
||||||
|
if (memeqstr(buffer + tok->start, tok->end - tok->start, "true")) {
|
||||||
|
**b = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (memeqstr(buffer + tok->start, tok->end - tok->start, "false")) {
|
||||||
|
**b = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
|
"'%s' should be 'true' or 'false', not '%.*s'",
|
||||||
|
name, tok->end - tok->start, buffer + tok->start);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_tok_double(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
double **num)
|
||||||
|
{
|
||||||
|
*num = tal(cmd, double);
|
||||||
|
if (json_to_double(buffer, tok, *num))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
|
"'%s' should be a double, not '%.*s'",
|
||||||
|
name, tok->end - tok->start, buffer + tok->start);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_tok_escaped_string(struct command *cmd, const char *name,
|
||||||
|
const char * buffer, const jsmntok_t *tok,
|
||||||
|
const char **str)
|
||||||
|
{
|
||||||
|
struct json_escaped *esc = json_to_escaped_string(cmd, buffer, tok);
|
||||||
|
if (esc) {
|
||||||
|
*str = json_escaped_unescape(cmd, esc);
|
||||||
|
if (*str)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
|
"'%s' should be a string, not '%.*s'"
|
||||||
|
" (note, we don't allow \\u)",
|
||||||
|
name,
|
||||||
|
tok->end - tok->start, buffer + tok->start);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_tok_string(struct command *cmd, const char *name,
|
||||||
|
const char * buffer, const jsmntok_t *tok,
|
||||||
|
const char **str)
|
||||||
|
{
|
||||||
|
*str = tal_strndup(cmd, buffer + tok->start,
|
||||||
|
tok->end - tok->start);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_tok_label(struct command *cmd, const char *name,
|
||||||
|
const char * buffer, const jsmntok_t *tok,
|
||||||
|
struct json_escaped **label)
|
||||||
|
{
|
||||||
|
/* We accept both strings and number literals here. */
|
||||||
|
*label = json_escaped_string_(cmd, buffer + tok->start, tok->end - tok->start);
|
||||||
|
if (*label && (tok->type == JSMN_STRING || json_tok_is_num(buffer, tok)))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
|
"'%s' should be a string or number, not '%.*s'",
|
||||||
|
name, tok->end - tok->start, buffer + tok->start);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_tok_number(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
unsigned int **num)
|
||||||
|
{
|
||||||
|
*num = tal(cmd, unsigned int);
|
||||||
|
if (json_to_number(buffer, tok, *num))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
|
"'%s' should be an integer, not '%.*s'",
|
||||||
|
name, tok->end - tok->start, buffer + tok->start);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_tok_sha256(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
struct sha256 **hash)
|
||||||
|
{
|
||||||
|
*hash = tal(cmd, struct sha256);
|
||||||
|
if (hex_decode(buffer + tok->start,
|
||||||
|
tok->end - tok->start,
|
||||||
|
*hash, sizeof(**hash)))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
|
"'%s' should be a 32 byte hex value, not '%.*s'",
|
||||||
|
name, tok->end - tok->start, buffer + tok->start);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_tok_msat(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t * tok,
|
||||||
|
u64 **msatoshi_val)
|
||||||
|
{
|
||||||
|
if (json_tok_streq(buffer, tok, "any")) {
|
||||||
|
*msatoshi_val = NULL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
*msatoshi_val = tal(cmd, u64);
|
||||||
|
|
||||||
|
if (json_to_u64(buffer, tok, *msatoshi_val) && *msatoshi_val != 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
|
"'%s' should be a positive number or 'any', not '%.*s'",
|
||||||
|
name,
|
||||||
|
tok->end - tok->start,
|
||||||
|
buffer + tok->start);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_tok_percent(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
double **num)
|
||||||
|
{
|
||||||
|
*num = tal(cmd, double);
|
||||||
|
if (json_to_double(buffer, tok, *num) && **num >= 0.0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
|
"'%s' should be a positive double, not '%.*s'",
|
||||||
|
name, tok->end - tok->start, buffer + tok->start);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_tok_u64(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
uint64_t **num)
|
||||||
|
{
|
||||||
|
*num = tal(cmd, uint64_t);
|
||||||
|
if (json_to_u64(buffer, tok, *num))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
|
"'%s' should be an unsigned 64 bit integer, not '%.*s'",
|
||||||
|
name, tok->end - tok->start, buffer + tok->start);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_tok_tok(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t * tok,
|
||||||
|
const jsmntok_t **out)
|
||||||
|
{
|
||||||
|
return (*out = tok);
|
||||||
|
}
|
72
common/json_tok.h
Normal file
72
common/json_tok.h
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/* Helpers for use with param parsing. */
|
||||||
|
#ifndef LIGHTNING_COMMON_JSON_TOK_H
|
||||||
|
#define LIGHTNING_COMMON_JSON_TOK_H
|
||||||
|
#include "config.h"
|
||||||
|
#include <common/json.h>
|
||||||
|
|
||||||
|
struct command;
|
||||||
|
|
||||||
|
/* Extract json array token */
|
||||||
|
bool json_tok_array(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
const jsmntok_t **arr);
|
||||||
|
|
||||||
|
/* Extract boolean this (must be a true or false) */
|
||||||
|
bool json_tok_bool(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
bool **b);
|
||||||
|
|
||||||
|
/* Extract double from this (must be a number literal) */
|
||||||
|
bool json_tok_double(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
double **num);
|
||||||
|
|
||||||
|
/* Extract an escaped string (and unescape it) */
|
||||||
|
bool json_tok_escaped_string(struct command *cmd, const char *name,
|
||||||
|
const char * buffer, const jsmntok_t *tok,
|
||||||
|
const char **str);
|
||||||
|
|
||||||
|
/* Extract a string */
|
||||||
|
bool json_tok_string(struct command *cmd, const char *name,
|
||||||
|
const char * buffer, const jsmntok_t *tok,
|
||||||
|
const char **str);
|
||||||
|
|
||||||
|
/* Extract a label. It is either an escaped string or a number. */
|
||||||
|
bool json_tok_label(struct command *cmd, const char *name,
|
||||||
|
const char * buffer, const jsmntok_t *tok,
|
||||||
|
struct json_escaped **label);
|
||||||
|
|
||||||
|
/* Extract number from this (may be a string, or a number literal) */
|
||||||
|
bool json_tok_number(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
unsigned int **num);
|
||||||
|
|
||||||
|
/* Extract sha256 hash */
|
||||||
|
bool json_tok_sha256(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
struct sha256 **hash);
|
||||||
|
|
||||||
|
/* Extract positive integer, or NULL if tok is 'any'. */
|
||||||
|
bool json_tok_msat(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t * tok,
|
||||||
|
u64 **msatoshi_val);
|
||||||
|
|
||||||
|
/* Extract double in range [0.0, 100.0] */
|
||||||
|
bool json_tok_percent(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
double **num);
|
||||||
|
|
||||||
|
/* Extract number from this (may be a string, or a number literal) */
|
||||||
|
bool json_tok_u64(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t *tok,
|
||||||
|
uint64_t **num);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the address of @out to @tok. Used as a callback by handlers that
|
||||||
|
* want to unmarshal @tok themselves.
|
||||||
|
*/
|
||||||
|
bool json_tok_tok(struct command *cmd, const char *name,
|
||||||
|
const char *buffer, const jsmntok_t * tok,
|
||||||
|
const jsmntok_t **out);
|
||||||
|
|
||||||
|
#endif /* LIGHTNING_COMMON_JSON_TOK_H */
|
|
@ -1,8 +1,8 @@
|
||||||
/* lightningd/jsonrpc_errors.h
|
/* common/jsonrpc_errors.h
|
||||||
* Lists error codes for JSON-RPC.
|
* Lists error codes for JSON-RPC.
|
||||||
*/
|
*/
|
||||||
#ifndef LIGHTNING_LIGHTNINGD_JSONRPC_ERRORS_H
|
#ifndef LIGHTNING_COMMON_JSONRPC_ERRORS_H
|
||||||
#define LIGHTNING_LIGHTNINGD_JSONRPC_ERRORS_H
|
#define LIGHTNING_COMMON_JSONRPC_ERRORS_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
/* Standard errors defined by JSON-RPC 2.0 standard */
|
/* Standard errors defined by JSON-RPC 2.0 standard */
|
||||||
|
@ -44,4 +44,4 @@
|
||||||
#define INVOICE_LABEL_ALREADY_EXISTS 900
|
#define INVOICE_LABEL_ALREADY_EXISTS 900
|
||||||
#define INVOICE_PREIMAGE_ALREADY_EXISTS 901
|
#define INVOICE_PREIMAGE_ALREADY_EXISTS 901
|
||||||
|
|
||||||
#endif /* LIGHTNING_LIGHTNINGD_JSONRPC_ERRORS_H */
|
#endif /* LIGHTNING_COMMON_JSONRPC_ERRORS_H */
|
|
@ -1,12 +1,9 @@
|
||||||
#include <ccan/asort/asort.h>
|
#include <ccan/asort/asort.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/json_command.h>
|
#include <common/json_command.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <lightningd/json.h>
|
|
||||||
#include <lightningd/jsonrpc.h>
|
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/lightningd.h>
|
|
||||||
#include <lightningd/param.h>
|
|
||||||
|
|
||||||
struct param {
|
struct param {
|
||||||
const char *name;
|
const char *name;
|
|
@ -1,6 +1,9 @@
|
||||||
#ifndef LIGHTNING_LIGHTNINGD_PARAM_H
|
#ifndef LIGHTNING_COMMON_PARAM_H
|
||||||
#define LIGHTNING_LIGHTNINGD_PARAM_H
|
#define LIGHTNING_COMMON_PARAM_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <common/json.h>
|
||||||
|
#include <common/json_tok.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
/*~ Greetings adventurer!
|
/*~ Greetings adventurer!
|
||||||
*
|
*
|
||||||
|
@ -28,8 +31,9 @@
|
||||||
*
|
*
|
||||||
* All the command handlers throughout the code use this system.
|
* All the command handlers throughout the code use this system.
|
||||||
* json_invoice() is a great example. The common callbacks can be found in
|
* json_invoice() is a great example. The common callbacks can be found in
|
||||||
* lightningd/json.c. Use them directly or feel free to write your own.
|
* common/json_tok.c. Use them directly or feel free to write your own.
|
||||||
*/
|
*/
|
||||||
|
struct command;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the json tokens. @params can be an array of values or an object
|
* Parse the json tokens. @params can be an array of values or an object
|
||||||
|
@ -92,4 +96,4 @@ typedef bool(*param_cbx)(struct command *cmd,
|
||||||
|
|
||||||
/* Special flag for 'check' which allows any parameters. */
|
/* Special flag for 'check' which allows any parameters. */
|
||||||
#define p_opt_any() "", false, NULL, NULL
|
#define p_opt_any() "", false, NULL, NULL
|
||||||
#endif /* LIGHTNING_LIGHTNINGD_PARAM_H */
|
#endif /* LIGHTNING_COMMON_PARAM_H */
|
|
@ -1,12 +1,11 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "../json.c"
|
#include "../json.c"
|
||||||
#include "../json_escaped.c"
|
#include "../json_escaped.c"
|
||||||
#include "../json_stream.c"
|
#include "../json_tok.c"
|
||||||
#include "../param.c"
|
#include "../param.c"
|
||||||
#include <ccan/array_size/array_size.h>
|
#include <ccan/array_size/array_size.h>
|
||||||
#include <ccan/err/err.h>
|
#include <ccan/err/err.h>
|
||||||
#include <common/json.h>
|
#include <common/json.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -33,21 +32,20 @@ void command_fail(struct command *cmd, int code, const char *fmt, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AUTOGENERATED MOCKS START */
|
/* AUTOGENERATED MOCKS START */
|
||||||
/* Generated stub for feerate_from_style */
|
|
||||||
u32 feerate_from_style(u32 feerate UNNEEDED, enum feerate_style style UNNEEDED)
|
|
||||||
{ fprintf(stderr, "feerate_from_style called!\n"); abort(); }
|
|
||||||
/* Generated stub for feerate_name */
|
|
||||||
const char *feerate_name(enum feerate feerate UNNEEDED)
|
|
||||||
{ fprintf(stderr, "feerate_name called!\n"); abort(); }
|
|
||||||
/* Generated stub for fmt_wireaddr_without_port */
|
|
||||||
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
|
|
||||||
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
|
|
||||||
/* Generated stub for json_feerate_estimate */
|
|
||||||
bool json_feerate_estimate(struct command *cmd UNNEEDED,
|
|
||||||
u32 **feerate_per_kw UNNEEDED, enum feerate feerate UNNEEDED)
|
|
||||||
{ fprintf(stderr, "json_feerate_estimate called!\n"); abort(); }
|
|
||||||
/* AUTOGENERATED MOCKS END */
|
/* AUTOGENERATED MOCKS END */
|
||||||
|
|
||||||
|
/* We do this lightningd-style: */
|
||||||
|
enum command_mode {
|
||||||
|
CMD_NORMAL,
|
||||||
|
CMD_USAGE,
|
||||||
|
CMD_CHECK
|
||||||
|
};
|
||||||
|
|
||||||
|
struct command {
|
||||||
|
enum command_mode mode;
|
||||||
|
const char *usage;
|
||||||
|
};
|
||||||
|
|
||||||
void command_set_usage(struct command *cmd, const char *usage)
|
void command_set_usage(struct command *cmd, const char *usage)
|
||||||
{
|
{
|
||||||
cmd->usage = usage;
|
cmd->usage = usage;
|
||||||
|
@ -551,20 +549,9 @@ static void test_invoice(struct command *cmd,
|
||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
/* Do this to simulate a call to our pretend handler (test_invoice) */
|
|
||||||
struct json_command invoice_command = {
|
|
||||||
"invoice",
|
|
||||||
test_invoice,
|
|
||||||
"",
|
|
||||||
false,
|
|
||||||
""
|
|
||||||
};
|
|
||||||
|
|
||||||
cmd->mode = CMD_USAGE;
|
cmd->mode = CMD_USAGE;
|
||||||
cmd->json_cmd = &invoice_command;
|
|
||||||
|
|
||||||
cmd->json_cmd->dispatch(cmd, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
|
test_invoice(cmd, NULL, NULL, NULL);
|
||||||
assert(streq(cmd->usage,
|
assert(streq(cmd->usage,
|
||||||
"msatoshi label description "
|
"msatoshi label description "
|
||||||
"[expiry] [fallbacks] [preimage]"));
|
"[expiry] [fallbacks] [preimage]"));
|
|
@ -1,6 +1,7 @@
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/wallet_tx.h>
|
#include <common/wallet_tx.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
|
|
||||||
void wtx_init(struct command *cmd, struct wallet_tx * wtx)
|
void wtx_init(struct command *cmd, struct wallet_tx * wtx)
|
||||||
|
|
|
@ -34,8 +34,11 @@ LIGHTNINGD_COMMON_OBJS := \
|
||||||
common/key_derive.o \
|
common/key_derive.o \
|
||||||
common/io_lock.o \
|
common/io_lock.o \
|
||||||
common/json.o \
|
common/json.o \
|
||||||
|
common/json_escaped.o \
|
||||||
|
common/json_tok.o \
|
||||||
common/memleak.o \
|
common/memleak.o \
|
||||||
common/msg_queue.o \
|
common/msg_queue.o \
|
||||||
|
common/param.o \
|
||||||
common/permute_tx.o \
|
common/permute_tx.o \
|
||||||
common/pseudorand.o \
|
common/pseudorand.o \
|
||||||
common/sphinx.o \
|
common/sphinx.o \
|
||||||
|
@ -64,7 +67,6 @@ LIGHTNINGD_SRC := \
|
||||||
lightningd/htlc_end.c \
|
lightningd/htlc_end.c \
|
||||||
lightningd/invoice.c \
|
lightningd/invoice.c \
|
||||||
lightningd/json.c \
|
lightningd/json.c \
|
||||||
lightningd/json_escaped.c \
|
|
||||||
lightningd/json_stream.c \
|
lightningd/json_stream.c \
|
||||||
lightningd/jsonrpc.c \
|
lightningd/jsonrpc.c \
|
||||||
lightningd/lightningd.c \
|
lightningd/lightningd.c \
|
||||||
|
@ -74,7 +76,6 @@ LIGHTNINGD_SRC := \
|
||||||
lightningd/onchain_control.c \
|
lightningd/onchain_control.c \
|
||||||
lightningd/opening_control.c \
|
lightningd/opening_control.c \
|
||||||
lightningd/options.c \
|
lightningd/options.c \
|
||||||
lightningd/param.c \
|
|
||||||
lightningd/pay.c \
|
lightningd/pay.c \
|
||||||
lightningd/payalgo.c \
|
lightningd/payalgo.c \
|
||||||
lightningd/peer_control.c \
|
lightningd/peer_control.c \
|
||||||
|
@ -92,8 +93,7 @@ ALL_OBJS += $(LIGHTNINGD_OBJS)
|
||||||
# We accumulate all lightningd/ headers in these three:
|
# We accumulate all lightningd/ headers in these three:
|
||||||
LIGHTNINGD_HEADERS_NOGEN = \
|
LIGHTNINGD_HEADERS_NOGEN = \
|
||||||
$(LIGHTNINGD_SRC:.c=.h) \
|
$(LIGHTNINGD_SRC:.c=.h) \
|
||||||
lightningd/channel_state.h \
|
lightningd/channel_state.h
|
||||||
lightningd/jsonrpc_errors.h
|
|
||||||
|
|
||||||
# Generated headers
|
# Generated headers
|
||||||
LIGHTNINGD_HEADERS_GEN = \
|
LIGHTNINGD_HEADERS_GEN = \
|
||||||
|
|
|
@ -13,14 +13,15 @@
|
||||||
#include <ccan/build_assert/build_assert.h>
|
#include <ccan/build_assert/build_assert.h>
|
||||||
#include <ccan/io/io.h>
|
#include <ccan/io/io.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/channel_control.h>
|
#include <lightningd/channel_control.h>
|
||||||
#include <lightningd/gossip_control.h>
|
#include <lightningd/gossip_control.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/param.h>
|
|
||||||
|
|
||||||
/* Mutual recursion via timer. */
|
/* Mutual recursion via timer. */
|
||||||
static void try_extend_tip(struct chain_topology *topo);
|
static void try_extend_tip(struct chain_topology *topo);
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
#include <ccan/list/list.h>
|
#include <ccan/list/list.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/features.h>
|
#include <common/features.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/pseudorand.h>
|
#include <common/pseudorand.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <common/wireaddr.h>
|
#include <common/wireaddr.h>
|
||||||
|
@ -18,11 +21,9 @@
|
||||||
#include <lightningd/json.h>
|
#include <lightningd/json.h>
|
||||||
#include <lightningd/json_stream.h>
|
#include <lightningd/json_stream.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/opening_control.h>
|
#include <lightningd/opening_control.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
#include <wire/gen_peer_wire.h>
|
#include <wire/gen_peer_wire.h>
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
#include <ccan/take/take.h>
|
#include <ccan/take/take.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/features.h>
|
#include <common/features.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/json_escaped.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -22,12 +26,9 @@
|
||||||
#include <lightningd/gossip_msg.h>
|
#include <lightningd/gossip_msg.h>
|
||||||
#include <lightningd/hsm_control.h>
|
#include <lightningd/hsm_control.h>
|
||||||
#include <lightningd/json.h>
|
#include <lightningd/json.h>
|
||||||
#include <lightningd/json_escaped.h>
|
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/options.h>
|
#include <lightningd/options.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <lightningd/ping.h>
|
#include <lightningd/ping.h>
|
||||||
#include <sodium/randombytes.h>
|
#include <sodium/randombytes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "invoice.h"
|
#include "invoice.h"
|
||||||
#include "json.h"
|
#include "json.h"
|
||||||
#include "jsonrpc.h"
|
#include "jsonrpc.h"
|
||||||
#include "jsonrpc_errors.h"
|
|
||||||
#include "lightningd.h"
|
#include "lightningd.h"
|
||||||
#include <bitcoin/address.h>
|
#include <bitcoin/address.h>
|
||||||
#include <bitcoin/base58.h>
|
#include <bitcoin/base58.h>
|
||||||
|
@ -10,6 +9,10 @@
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/bech32.h>
|
#include <common/bech32.h>
|
||||||
#include <common/bolt11.h>
|
#include <common/bolt11.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/json_escaped.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/pseudorand.h>
|
#include <common/pseudorand.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -18,11 +21,8 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/channel.h>
|
#include <lightningd/channel.h>
|
||||||
#include <lightningd/hsm_control.h>
|
#include <lightningd/hsm_control.h>
|
||||||
#include <lightningd/json_escaped.h>
|
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/options.h>
|
#include <lightningd/options.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
#include <sodium/randombytes.h>
|
#include <sodium/randombytes.h>
|
||||||
|
|
|
@ -3,15 +3,17 @@
|
||||||
#include <ccan/str/hex/hex.h>
|
#include <ccan/str/hex/hex.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/json.h>
|
#include <common/json.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/json_escaped.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <common/wireaddr.h>
|
#include <common/wireaddr.h>
|
||||||
#include <gossipd/routing.h>
|
#include <gossipd/routing.h>
|
||||||
#include <lightningd/json.h>
|
#include <lightningd/json.h>
|
||||||
#include <lightningd/json_escaped.h>
|
|
||||||
#include <lightningd/json_stream.h>
|
#include <lightningd/json_stream.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/options.h>
|
#include <lightningd/options.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
|
@ -95,175 +97,6 @@ void json_add_txid(struct json_stream *result, const char *fieldname,
|
||||||
json_add_string(result, fieldname, hex);
|
json_add_string(result, fieldname, hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool json_tok_array(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
const jsmntok_t **arr)
|
|
||||||
{
|
|
||||||
if (tok->type == JSMN_ARRAY)
|
|
||||||
return (*arr = tok);
|
|
||||||
|
|
||||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
|
||||||
"'%s' should be an array, not '%.*s'",
|
|
||||||
name, tok->end - tok->start, buffer + tok->start);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_tok_bool(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
bool **b)
|
|
||||||
{
|
|
||||||
*b = tal(cmd, bool);
|
|
||||||
if (tok->type == JSMN_PRIMITIVE) {
|
|
||||||
if (memeqstr(buffer + tok->start, tok->end - tok->start, "true")) {
|
|
||||||
**b = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (memeqstr(buffer + tok->start, tok->end - tok->start, "false")) {
|
|
||||||
**b = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
|
||||||
"'%s' should be 'true' or 'false', not '%.*s'",
|
|
||||||
name, tok->end - tok->start, buffer + tok->start);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_tok_double(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
double **num)
|
|
||||||
{
|
|
||||||
*num = tal(cmd, double);
|
|
||||||
if (json_to_double(buffer, tok, *num))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
|
||||||
"'%s' should be a double, not '%.*s'",
|
|
||||||
name, tok->end - tok->start, buffer + tok->start);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_tok_escaped_string(struct command *cmd, const char *name,
|
|
||||||
const char * buffer, const jsmntok_t *tok,
|
|
||||||
const char **str)
|
|
||||||
{
|
|
||||||
struct json_escaped *esc = json_to_escaped_string(cmd, buffer, tok);
|
|
||||||
if (esc) {
|
|
||||||
*str = json_escaped_unescape(cmd, esc);
|
|
||||||
if (*str)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
|
||||||
"'%s' should be a string, not '%.*s'"
|
|
||||||
" (note, we don't allow \\u)",
|
|
||||||
name,
|
|
||||||
tok->end - tok->start, buffer + tok->start);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_tok_string(struct command *cmd, const char *name,
|
|
||||||
const char * buffer, const jsmntok_t *tok,
|
|
||||||
const char **str)
|
|
||||||
{
|
|
||||||
*str = tal_strndup(cmd, buffer + tok->start,
|
|
||||||
tok->end - tok->start);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_tok_label(struct command *cmd, const char *name,
|
|
||||||
const char * buffer, const jsmntok_t *tok,
|
|
||||||
struct json_escaped **label)
|
|
||||||
{
|
|
||||||
/* We accept both strings and number literals here. */
|
|
||||||
*label = json_escaped_string_(cmd, buffer + tok->start, tok->end - tok->start);
|
|
||||||
if (*label && (tok->type == JSMN_STRING || json_tok_is_num(buffer, tok)))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
|
||||||
"'%s' should be a string or number, not '%.*s'",
|
|
||||||
name, tok->end - tok->start, buffer + tok->start);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_tok_number(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
unsigned int **num)
|
|
||||||
{
|
|
||||||
*num = tal(cmd, unsigned int);
|
|
||||||
if (json_to_number(buffer, tok, *num))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
|
||||||
"'%s' should be an integer, not '%.*s'",
|
|
||||||
name, tok->end - tok->start, buffer + tok->start);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_tok_sha256(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
struct sha256 **hash)
|
|
||||||
{
|
|
||||||
*hash = tal(cmd, struct sha256);
|
|
||||||
if (hex_decode(buffer + tok->start,
|
|
||||||
tok->end - tok->start,
|
|
||||||
*hash, sizeof(**hash)))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
|
||||||
"'%s' should be a 32 byte hex value, not '%.*s'",
|
|
||||||
name, tok->end - tok->start, buffer + tok->start);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_tok_msat(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t * tok,
|
|
||||||
u64 **msatoshi_val)
|
|
||||||
{
|
|
||||||
if (json_tok_streq(buffer, tok, "any")) {
|
|
||||||
*msatoshi_val = NULL;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*msatoshi_val = tal(cmd, u64);
|
|
||||||
|
|
||||||
if (json_to_u64(buffer, tok, *msatoshi_val) && *msatoshi_val != 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
|
||||||
"'%s' should be a positive number or 'any', not '%.*s'",
|
|
||||||
name,
|
|
||||||
tok->end - tok->start,
|
|
||||||
buffer + tok->start);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_tok_percent(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
double **num)
|
|
||||||
{
|
|
||||||
*num = tal(cmd, double);
|
|
||||||
if (json_to_double(buffer, tok, *num) && **num >= 0.0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
|
||||||
"'%s' should be a positive double, not '%.*s'",
|
|
||||||
name, tok->end - tok->start, buffer + tok->start);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_tok_u64(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
uint64_t **num)
|
|
||||||
{
|
|
||||||
*num = tal(cmd, uint64_t);
|
|
||||||
if (json_to_u64(buffer, tok, *num))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
|
||||||
"'%s' should be an unsigned 64 bit integer, not '%.*s'",
|
|
||||||
name, tok->end - tok->start, buffer + tok->start);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool json_to_pubkey(const char *buffer, const jsmntok_t *tok,
|
bool json_to_pubkey(const char *buffer, const jsmntok_t *tok,
|
||||||
struct pubkey *pubkey)
|
struct pubkey *pubkey)
|
||||||
{
|
{
|
||||||
|
@ -470,13 +303,6 @@ void json_add_address_internal(struct json_stream *response,
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool json_tok_tok(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t * tok,
|
|
||||||
const jsmntok_t **out)
|
|
||||||
{
|
|
||||||
return (*out = tok);
|
|
||||||
}
|
|
||||||
|
|
||||||
void json_add_num(struct json_stream *result, const char *fieldname, unsigned int value)
|
void json_add_num(struct json_stream *result, const char *fieldname, unsigned int value)
|
||||||
{
|
{
|
||||||
json_add_member(result, fieldname, "%u", value);
|
json_add_member(result, fieldname, "%u", value);
|
||||||
|
|
|
@ -47,56 +47,6 @@ void json_add_pubkey(struct json_stream *response,
|
||||||
void json_add_txid(struct json_stream *result, const char *fieldname,
|
void json_add_txid(struct json_stream *result, const char *fieldname,
|
||||||
const struct bitcoin_txid *txid);
|
const struct bitcoin_txid *txid);
|
||||||
|
|
||||||
/* Extract json array token */
|
|
||||||
bool json_tok_array(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
const jsmntok_t **arr);
|
|
||||||
|
|
||||||
/* Extract boolean this (must be a true or false) */
|
|
||||||
bool json_tok_bool(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
bool **b);
|
|
||||||
|
|
||||||
/* Extract double from this (must be a number literal) */
|
|
||||||
bool json_tok_double(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
double **num);
|
|
||||||
|
|
||||||
/* Extract an escaped string (and unescape it) */
|
|
||||||
bool json_tok_escaped_string(struct command *cmd, const char *name,
|
|
||||||
const char * buffer, const jsmntok_t *tok,
|
|
||||||
const char **str);
|
|
||||||
|
|
||||||
/* Extract a string */
|
|
||||||
bool json_tok_string(struct command *cmd, const char *name,
|
|
||||||
const char * buffer, const jsmntok_t *tok,
|
|
||||||
const char **str);
|
|
||||||
|
|
||||||
/* Extract a label. It is either an escaped string or a number. */
|
|
||||||
bool json_tok_label(struct command *cmd, const char *name,
|
|
||||||
const char * buffer, const jsmntok_t *tok,
|
|
||||||
struct json_escaped **label);
|
|
||||||
|
|
||||||
/* Extract number from this (may be a string, or a number literal) */
|
|
||||||
bool json_tok_number(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
unsigned int **num);
|
|
||||||
|
|
||||||
/* Extract sha256 hash */
|
|
||||||
bool json_tok_sha256(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
struct sha256 **hash);
|
|
||||||
|
|
||||||
/* Extract positive integer, or NULL if tok is 'any'. */
|
|
||||||
bool json_tok_msat(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t * tok,
|
|
||||||
u64 **msatoshi_val);
|
|
||||||
|
|
||||||
/* Extract double in range [0.0, 100.0] */
|
|
||||||
bool json_tok_percent(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
double **num);
|
|
||||||
|
|
||||||
/* Extract a pubkey from this */
|
/* Extract a pubkey from this */
|
||||||
bool json_to_pubkey(const char *buffer, const jsmntok_t *tok,
|
bool json_to_pubkey(const char *buffer, const jsmntok_t *tok,
|
||||||
struct pubkey *pubkey);
|
struct pubkey *pubkey);
|
||||||
|
@ -113,11 +63,6 @@ bool json_tok_short_channel_id(struct command *cmd, const char *name,
|
||||||
const char *buffer, const jsmntok_t *tok,
|
const char *buffer, const jsmntok_t *tok,
|
||||||
struct short_channel_id **scid);
|
struct short_channel_id **scid);
|
||||||
|
|
||||||
/* Extract number from this (may be a string, or a number literal) */
|
|
||||||
bool json_tok_u64(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t *tok,
|
|
||||||
uint64_t **num);
|
|
||||||
|
|
||||||
enum feerate_style {
|
enum feerate_style {
|
||||||
FEERATE_PER_KSIPA,
|
FEERATE_PER_KSIPA,
|
||||||
FEERATE_PER_KBYTE
|
FEERATE_PER_KBYTE
|
||||||
|
@ -152,14 +97,6 @@ void json_add_address_internal(struct json_stream *response,
|
||||||
const char *fieldname,
|
const char *fieldname,
|
||||||
const struct wireaddr_internal *addr);
|
const struct wireaddr_internal *addr);
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the address of @out to @tok. Used as a callback by handlers that
|
|
||||||
* want to unmarshal @tok themselves.
|
|
||||||
*/
|
|
||||||
bool json_tok_tok(struct command *cmd, const char *name,
|
|
||||||
const char *buffer, const jsmntok_t * tok,
|
|
||||||
const jsmntok_t **out);
|
|
||||||
|
|
||||||
|
|
||||||
/* '"fieldname" : "value"' or '"value"' if fieldname is NULL. Turns
|
/* '"fieldname" : "value"' or '"value"' if fieldname is NULL. Turns
|
||||||
* any non-printable chars into JSON escapes, but leaves existing escapes alone.
|
* any non-printable chars into JSON escapes, but leaves existing escapes alone.
|
||||||
|
|
|
@ -24,7 +24,10 @@
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/bech32.h>
|
#include <common/bech32.h>
|
||||||
#include <common/json_command.h>
|
#include <common/json_command.h>
|
||||||
|
#include <common/json_escaped.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <common/wallet_tx.h>
|
#include <common/wallet_tx.h>
|
||||||
|
@ -33,12 +36,9 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <lightningd/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/json.h>
|
#include <lightningd/json.h>
|
||||||
#include <lightningd/json_escaped.h>
|
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/options.h>
|
#include <lightningd/options.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
|
@ -64,7 +64,7 @@ struct json_stream *json_stream_success(struct command *cmd);
|
||||||
/**
|
/**
|
||||||
* json_stream_fail - start streaming a failed json result.
|
* json_stream_fail - start streaming a failed json result.
|
||||||
* @cmd: the command we're running.
|
* @cmd: the command we're running.
|
||||||
* @code: the error code from lightningd/jsonrpc_errors.h
|
* @code: the error code from common/jsonrpc_errors.h
|
||||||
* @errmsg: the error string.
|
* @errmsg: the error string.
|
||||||
*
|
*
|
||||||
* The returned value should go to command_failed() when done;
|
* The returned value should go to command_failed() when done;
|
||||||
|
@ -77,7 +77,7 @@ struct json_stream *json_stream_fail(struct command *cmd,
|
||||||
/**
|
/**
|
||||||
* json_stream_fail_nodata - start streaming a failed json result.
|
* json_stream_fail_nodata - start streaming a failed json result.
|
||||||
* @cmd: the command we're running.
|
* @cmd: the command we're running.
|
||||||
* @code: the error code from lightningd/jsonrpc_errors.h
|
* @code: the error code from common/jsonrpc_errors.h
|
||||||
* @errmsg: the error string.
|
* @errmsg: the error string.
|
||||||
*
|
*
|
||||||
* This is used by command_fail(), which doesn't add any JSON data.
|
* This is used by command_fail(), which doesn't add any JSON data.
|
||||||
|
@ -89,8 +89,6 @@ struct json_stream *json_stream_fail_nodata(struct command *cmd,
|
||||||
struct json_stream *null_response(struct command *cmd);
|
struct json_stream *null_response(struct command *cmd);
|
||||||
void command_success(struct command *cmd, struct json_stream *response);
|
void command_success(struct command *cmd, struct json_stream *response);
|
||||||
void command_failed(struct command *cmd, struct json_stream *result);
|
void command_failed(struct command *cmd, struct json_stream *result);
|
||||||
void PRINTF_FMT(3, 4) command_fail(struct command *cmd, int code,
|
|
||||||
const char *fmt, ...);
|
|
||||||
|
|
||||||
/* Mainly for documentation, that we plan to close this later. */
|
/* Mainly for documentation, that we plan to close this later. */
|
||||||
void command_still_pending(struct command *cmd);
|
void command_still_pending(struct command *cmd);
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
/*~ This is common code: routines shared by one or more executables
|
/*~ This is common code: routines shared by one or more executables
|
||||||
* (separate daemons, or the lightning-cli program). */
|
* (separate daemons, or the lightning-cli program). */
|
||||||
#include <common/daemon.h>
|
#include <common/daemon.h>
|
||||||
|
#include <common/json_escaped.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
|
@ -68,7 +69,6 @@
|
||||||
#include <lightningd/channel_control.h>
|
#include <lightningd/channel_control.h>
|
||||||
#include <lightningd/connect_control.h>
|
#include <lightningd/connect_control.h>
|
||||||
#include <lightningd/invoice.h>
|
#include <lightningd/invoice.h>
|
||||||
#include <lightningd/json_escaped.h>
|
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/onchain_control.h>
|
#include <lightningd/onchain_control.h>
|
||||||
|
|
|
@ -10,17 +10,18 @@
|
||||||
#include <ccan/str/hex/hex.h>
|
#include <ccan/str/hex/hex.h>
|
||||||
#include <ccan/tal/link/link.h>
|
#include <ccan/tal/link/link.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/pseudorand.h>
|
#include <common/pseudorand.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/options.h>
|
#include <lightningd/options.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
#include <backtrace.h>
|
#include <backtrace.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/daemon.h>
|
#include <common/daemon.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/gen_connect_wire.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -12,11 +15,9 @@
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/gen_hsm_wire.h>
|
||||||
#include <lightningd/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/opening_control.h>
|
#include <lightningd/opening_control.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/channel_config.h>
|
#include <common/channel_config.h>
|
||||||
#include <common/funding_tx.h>
|
#include <common/funding_tx.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/key_derive.h>
|
#include <common/key_derive.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/wallet_tx.h>
|
#include <common/wallet_tx.h>
|
||||||
#include <common/wire_error.h>
|
#include <common/wire_error.h>
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/gen_connect_wire.h>
|
||||||
|
@ -16,11 +19,9 @@
|
||||||
#include <lightningd/hsm_control.h>
|
#include <lightningd/hsm_control.h>
|
||||||
#include <lightningd/json.h>
|
#include <lightningd/json.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/opening_control.h>
|
#include <lightningd/opening_control.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
#include <openingd/gen_opening_wire.h>
|
#include <openingd/gen_opening_wire.h>
|
||||||
|
|
|
@ -10,7 +10,11 @@
|
||||||
#include <ccan/tal/path/path.h>
|
#include <ccan/tal/path/path.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/configdir.h>
|
#include <common/configdir.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/json_escaped.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <common/wireaddr.h>
|
#include <common/wireaddr.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -19,13 +23,10 @@
|
||||||
#include <lightningd/bitcoind.h>
|
#include <lightningd/bitcoind.h>
|
||||||
#include <lightningd/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/json.h>
|
#include <lightningd/json.h>
|
||||||
#include <lightningd/json_escaped.h>
|
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/options.h>
|
#include <lightningd/options.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <lightningd/plugin.h>
|
#include <lightningd/plugin.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -2,16 +2,17 @@
|
||||||
#include <ccan/str/hex/hex.h>
|
#include <ccan/str/hex/hex.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/bolt11.h>
|
#include <common/bolt11.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <gossipd/gen_gossip_wire.h>
|
#include <gossipd/gen_gossip_wire.h>
|
||||||
#include <lightningd/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/json.h>
|
#include <lightningd/json.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/options.h>
|
#include <lightningd/options.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/peer_htlcs.h>
|
#include <lightningd/peer_htlcs.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <ccan/time/time.h>
|
#include <ccan/time/time.h>
|
||||||
#include <common/bolt11.h>
|
#include <common/bolt11.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/pseudorand.h>
|
#include <common/pseudorand.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
|
@ -12,10 +15,8 @@
|
||||||
#include <gossipd/routing.h>
|
#include <gossipd/routing.h>
|
||||||
#include <lightningd/json.h>
|
#include <lightningd/json.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
#include <sodium/randombytes.h>
|
#include <sodium/randombytes.h>
|
||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
|
|
|
@ -15,7 +15,10 @@
|
||||||
#include <common/dev_disconnect.h>
|
#include <common/dev_disconnect.h>
|
||||||
#include <common/features.h>
|
#include <common/features.h>
|
||||||
#include <common/initial_commit_tx.h>
|
#include <common/initial_commit_tx.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/key_derive.h>
|
#include <common/key_derive.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/status.h>
|
#include <common/status.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
|
@ -33,13 +36,11 @@
|
||||||
#include <lightningd/hsm_control.h>
|
#include <lightningd/hsm_control.h>
|
||||||
#include <lightningd/json.h>
|
#include <lightningd/json.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/memdump.h>
|
#include <lightningd/memdump.h>
|
||||||
#include <lightningd/onchain_control.h>
|
#include <lightningd/onchain_control.h>
|
||||||
#include <lightningd/opening_control.h>
|
#include <lightningd/opening_control.h>
|
||||||
#include <lightningd/options.h>
|
#include <lightningd/options.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <lightningd/peer_htlcs.h>
|
#include <lightningd/peer_htlcs.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wally_bip32.h>
|
#include <wally_bip32.h>
|
||||||
|
|
|
@ -5,19 +5,20 @@
|
||||||
#include <ccan/mem/mem.h>
|
#include <ccan/mem/mem.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <channeld/gen_channel_wire.h>
|
#include <channeld/gen_channel_wire.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/json_escaped.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/overflows.h>
|
#include <common/overflows.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/sphinx.h>
|
#include <common/sphinx.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <gossipd/gen_gossip_wire.h>
|
#include <gossipd/gen_gossip_wire.h>
|
||||||
#include <lightningd/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/htlc_end.h>
|
#include <lightningd/htlc_end.h>
|
||||||
#include <lightningd/json.h>
|
#include <lightningd/json.h>
|
||||||
#include <lightningd/json_escaped.h>
|
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <lightningd/pay.h>
|
#include <lightningd/pay.h>
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/peer_htlcs.h>
|
#include <lightningd/peer_htlcs.h>
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
#include <channeld/gen_channel_wire.h>
|
#include <channeld/gen_channel_wire.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/sphinx.h>
|
#include <common/sphinx.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <gossipd/gen_gossip_wire.h>
|
#include <gossipd/gen_gossip_wire.h>
|
||||||
#include <lightningd/htlc_end.h>
|
#include <lightningd/htlc_end.h>
|
||||||
#include <lightningd/json.h>
|
#include <lightningd/json.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/ping.h>
|
#include <lightningd/ping.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
|
|
|
@ -9,12 +9,14 @@
|
||||||
#include <ccan/tal/path/path.h>
|
#include <ccan/tal/path/path.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <ccan/utf8/utf8.h>
|
#include <ccan/utf8/utf8.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/memleak.h>
|
#include <common/memleak.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <lightningd/json.h>
|
#include <lightningd/json.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
|
@ -13,6 +13,7 @@ LIGHTNINGD_TEST_COMMON_OBJS := \
|
||||||
common/htlc_state.o \
|
common/htlc_state.o \
|
||||||
common/io_lock.o \
|
common/io_lock.o \
|
||||||
common/json.o \
|
common/json.o \
|
||||||
|
common/json_escaped.o \
|
||||||
common/key_derive.o \
|
common/key_derive.o \
|
||||||
common/pseudorand.o \
|
common/pseudorand.o \
|
||||||
common/memleak.o \
|
common/memleak.o \
|
||||||
|
|
|
@ -91,9 +91,6 @@ void hsm_init(struct lightningd *ld UNNEEDED)
|
||||||
/* Generated stub for htlcs_notify_new_block */
|
/* Generated stub for htlcs_notify_new_block */
|
||||||
void htlcs_notify_new_block(struct lightningd *ld UNNEEDED, u32 height UNNEEDED)
|
void htlcs_notify_new_block(struct lightningd *ld UNNEEDED, u32 height UNNEEDED)
|
||||||
{ fprintf(stderr, "htlcs_notify_new_block called!\n"); abort(); }
|
{ fprintf(stderr, "htlcs_notify_new_block called!\n"); abort(); }
|
||||||
/* Generated stub for json_escape */
|
|
||||||
struct json_escaped *json_escape(const tal_t *ctx UNNEEDED, const char *str TAKES UNNEEDED)
|
|
||||||
{ fprintf(stderr, "json_escape called!\n"); abort(); }
|
|
||||||
/* Generated stub for jsonrpc_listen */
|
/* Generated stub for jsonrpc_listen */
|
||||||
void jsonrpc_listen(struct jsonrpc *rpc UNNEEDED, struct lightningd *ld UNNEEDED)
|
void jsonrpc_listen(struct jsonrpc *rpc UNNEEDED, struct lightningd *ld UNNEEDED)
|
||||||
{ fprintf(stderr, "jsonrpc_listen called!\n"); abort(); }
|
{ fprintf(stderr, "jsonrpc_listen called!\n"); abort(); }
|
||||||
|
|
|
@ -164,9 +164,6 @@ void json_array_end(struct json_stream *js UNNEEDED)
|
||||||
/* Generated stub for json_array_start */
|
/* Generated stub for json_array_start */
|
||||||
void json_array_start(struct json_stream *js UNNEEDED, const char *fieldname UNNEEDED)
|
void json_array_start(struct json_stream *js UNNEEDED, const char *fieldname UNNEEDED)
|
||||||
{ fprintf(stderr, "json_array_start called!\n"); abort(); }
|
{ fprintf(stderr, "json_array_start called!\n"); abort(); }
|
||||||
/* Generated stub for json_escape */
|
|
||||||
struct json_escaped *json_escape(const tal_t *ctx UNNEEDED, const char *str TAKES UNNEEDED)
|
|
||||||
{ fprintf(stderr, "json_escape called!\n"); abort(); }
|
|
||||||
/* Generated stub for json_object_end */
|
/* Generated stub for json_object_end */
|
||||||
void json_object_end(struct json_stream *js UNNEEDED)
|
void json_object_end(struct json_stream *js UNNEEDED)
|
||||||
{ fprintf(stderr, "json_object_end called!\n"); abort(); }
|
{ fprintf(stderr, "json_object_end called!\n"); abort(); }
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include "../json_escaped.c"
|
|
||||||
#include "../json_stream.c"
|
#include "../json_stream.c"
|
||||||
#include "../jsonrpc.c"
|
#include "../jsonrpc.c"
|
||||||
#include "../json.c"
|
#include "../json.c"
|
||||||
|
@ -26,6 +25,21 @@ char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr
|
||||||
bool json_feerate_estimate(struct command *cmd UNNEEDED,
|
bool json_feerate_estimate(struct command *cmd UNNEEDED,
|
||||||
u32 **feerate_per_kw UNNEEDED, enum feerate feerate UNNEEDED)
|
u32 **feerate_per_kw UNNEEDED, enum feerate feerate UNNEEDED)
|
||||||
{ fprintf(stderr, "json_feerate_estimate called!\n"); abort(); }
|
{ fprintf(stderr, "json_feerate_estimate called!\n"); abort(); }
|
||||||
|
/* Generated stub for json_tok_number */
|
||||||
|
bool json_tok_number(struct command *cmd UNNEEDED, const char *name UNNEEDED,
|
||||||
|
const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
||||||
|
unsigned int **num UNNEEDED)
|
||||||
|
{ fprintf(stderr, "json_tok_number called!\n"); abort(); }
|
||||||
|
/* Generated stub for json_tok_sha256 */
|
||||||
|
bool json_tok_sha256(struct command *cmd UNNEEDED, const char *name UNNEEDED,
|
||||||
|
const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
||||||
|
struct sha256 **hash UNNEEDED)
|
||||||
|
{ fprintf(stderr, "json_tok_sha256 called!\n"); abort(); }
|
||||||
|
/* Generated stub for json_tok_tok */
|
||||||
|
bool json_tok_tok(struct command *cmd UNNEEDED, const char *name UNNEEDED,
|
||||||
|
const char *buffer UNNEEDED, const jsmntok_t * tok UNNEEDED,
|
||||||
|
const jsmntok_t **out UNNEEDED)
|
||||||
|
{ fprintf(stderr, "json_tok_tok called!\n"); abort(); }
|
||||||
/* Generated stub for log_ */
|
/* Generated stub for log_ */
|
||||||
void log_(struct log *log UNNEEDED, enum log_level level UNNEEDED, const char *fmt UNNEEDED, ...)
|
void log_(struct log *log UNNEEDED, enum log_level level UNNEEDED, const char *fmt UNNEEDED, ...)
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/json_escaped.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/json_escaped.h>
|
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
#include <bitcoin/script.h>
|
#include <bitcoin/script.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/bech32.h>
|
#include <common/bech32.h>
|
||||||
|
#include <common/json_command.h>
|
||||||
|
#include <common/jsonrpc_errors.h>
|
||||||
#include <common/key_derive.h>
|
#include <common/key_derive.h>
|
||||||
|
#include <common/param.h>
|
||||||
#include <common/status.h>
|
#include <common/status.h>
|
||||||
#include <common/utxo.h>
|
#include <common/utxo.h>
|
||||||
#include <common/wallet_tx.h>
|
#include <common/wallet_tx.h>
|
||||||
|
@ -16,10 +19,8 @@
|
||||||
#include <lightningd/hsm_control.h>
|
#include <lightningd/hsm_control.h>
|
||||||
#include <lightningd/json.h>
|
#include <lightningd/json.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/jsonrpc_errors.h>
|
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/param.h>
|
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
#include <wally_bip32.h>
|
#include <wally_bip32.h>
|
||||||
|
|
Loading…
Add table
Reference in a new issue