Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 4 additions & 37 deletions common/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,44 +830,11 @@ void json_add_time(struct json_stream *result, const char *fieldname,
void json_add_tok(struct json_stream *result, const char *fieldname,
const jsmntok_t *tok, const char *buffer)
{
int i = 0;
const jsmntok_t *t;

switch (tok->type) {
case JSMN_PRIMITIVE:
if (json_tok_is_num(buffer, tok)) {
json_to_int(buffer, tok, &i);
json_add_num(result, fieldname, i);
}
return;

case JSMN_STRING:
if (json_tok_streq(buffer, tok, "true"))
json_add_bool(result, fieldname, true);
else if (json_tok_streq(buffer, tok, "false"))
json_add_bool(result, fieldname, false);
else
json_add_string(result, fieldname, json_strdup(tmpctx, buffer, tok));
return;
char *space;
assert(tok->type != JSMN_UNDEFINED);

case JSMN_ARRAY:
json_array_start(result, fieldname);
json_for_each_arr(i, t, tok)
json_add_tok(result, NULL, t, buffer);
json_array_end(result);
return;

case JSMN_OBJECT:
json_object_start(result, fieldname);
json_for_each_obj(i, t, tok)
json_add_tok(result, json_strdup(tmpctx, buffer, t), t+1, buffer);
json_object_end(result);
return;

case JSMN_UNDEFINED:
break;
}
abort();
space = json_member_direct(result, fieldname, json_tok_full_len(tok));
memcpy(space, json_tok_full(buffer, tok), json_tok_full_len(tok));
}

void json_add_errcode(struct json_stream *result, const char *fieldname,
Expand Down
1 change: 0 additions & 1 deletion plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
autoclean
bcli
fundchannel
pay
spenderp

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spenderp?

multifundchannel
21 changes: 6 additions & 15 deletions plugins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ PLUGIN_PAY_OBJS := $(PLUGIN_PAY_SRC:.c=.o)
PLUGIN_AUTOCLEAN_SRC := plugins/autoclean.c
PLUGIN_AUTOCLEAN_OBJS := $(PLUGIN_AUTOCLEAN_SRC:.c=.o)

PLUGIN_FUNDCHANNEL_SRC := plugins/fundchannel.c
PLUGIN_FUNDCHANNEL_OBJS := $(PLUGIN_FUNDCHANNEL_SRC:.c=.o)

PLUGIN_TXPREPARE_SRC := plugins/txprepare.c
PLUGIN_TXPREPARE_OBJS := $(PLUGIN_TXPREPARE_SRC:.c=.o)

Expand All @@ -24,24 +21,24 @@ PLUGIN_PAY_LIB_SRC := plugins/libplugin-pay.c
PLUGIN_PAY_LIB_HEADER := plugins/libplugin-pay.h
PLUGIN_PAY_LIB_OBJS := $(PLUGIN_PAY_LIB_SRC:.c=.o)

PLUGIN_MULTIFUNDCHANNEL_SRC := plugins/multifundchannel.c
PLUGIN_MULTIFUNDCHANNEL_OBJS := $(PLUGIN_MULTIFUNDCHANNEL_SRC:.c=.o)

PLUGIN_SPENDER_SRC := \
plugins/spender/fundchannel.c \
plugins/spender/main.c \
plugins/spender/multifundchannel.c \
plugins/spender/multiwithdraw.c
PLUGIN_SPENDER_HEADER := \
plugins/spender/multiwithdraw.h
plugins/spender/multifundchannel.h \
plugins/spender/multiwithdraw.h \
plugins/spender/fundchannel.h \
plugins/spender/multifundchannel.h
PLUGIN_SPENDER_OBJS := $(PLUGIN_SPENDER_SRC:.c=.o)

PLUGIN_ALL_SRC := \
$(PLUGIN_AUTOCLEAN_SRC) \
$(PLUGIN_BCLI_SRC) \
$(PLUGIN_FUNDCHANNEL_SRC) \
$(PLUGIN_KEYSEND_SRC) \
$(PLUGIN_TXPREPARE_SRC) \
$(PLUGIN_LIB_SRC) \
$(PLUGIN_MULTIFUNDCHANNEL_SRC) \
$(PLUGIN_PAY_LIB_SRC) \
$(PLUGIN_PAY_SRC) \
$(PLUGIN_SPENDER_SRC)
Expand All @@ -54,10 +51,8 @@ PLUGIN_ALL_OBJS := $(PLUGIN_ALL_SRC:.c=.o)
PLUGINS := \
plugins/autoclean \
plugins/bcli \
plugins/fundchannel \
plugins/keysend \
plugins/pay \
plugins/multifundchannel \
plugins/txprepare \
plugins/spenderp

Expand Down Expand Up @@ -111,17 +106,13 @@ $(PLUGIN_PAY_OBJS): $(PLUGIN_PAY_LIB_HEADER)

plugins/autoclean: bitcoin/chainparams.o $(PLUGIN_AUTOCLEAN_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS)

plugins/fundchannel: common/addr.o $(PLUGIN_FUNDCHANNEL_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS)

plugins/txprepare: bitcoin/chainparams.o $(PLUGIN_TXPREPARE_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS)

plugins/bcli: bitcoin/chainparams.o $(PLUGIN_BCLI_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS)

plugins/keysend: bitcoin/chainparams.o wire/tlvstream.o wire/onion$(EXP)_wiregen.o $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS)
$(PLUGIN_KEYSEND_OBJS): $(PLUGIN_PAY_LIB_HEADER)

plugins/multifundchannel: bitcoin/chainparams.o common/addr.o $(PLUGIN_MULTIFUNDCHANNEL_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS)

plugins/spenderp: bitcoin/chainparams.o $(PLUGIN_SPENDER_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS)

$(PLUGIN_ALL_OBJS): $(PLUGIN_LIB_HEADER)
Loading