From e04febfe0ceba83cabc62da56d27a5aee84ae694 Mon Sep 17 00:00:00 2001 From: ZmnSCPxj jxPCSnmZ Date: Wed, 9 Sep 2020 19:55:20 +0930 Subject: [PATCH] plugins/spender/: New plugin that will eventually absorb all onchain-spending commands. --- plugins/.gitignore | 1 + plugins/Makefile | 16 +++++++++++++--- plugins/spender/main.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 plugins/spender/main.c diff --git a/plugins/.gitignore b/plugins/.gitignore index 8f5d88a60..4a5a3c669 100644 --- a/plugins/.gitignore +++ b/plugins/.gitignore @@ -2,4 +2,5 @@ autoclean bcli fundchannel pay +spenderp multifundchannel diff --git a/plugins/Makefile b/plugins/Makefile index 28e6e7b53..5dfa46a86 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -27,6 +27,11 @@ 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/main.c +PLUGIN_SPENDER_HEADER := +PLUGIN_SPENDER_OBJS := $(PLUGIN_SPENDER_SRC:.c=.o) + PLUGIN_ALL_SRC := \ $(PLUGIN_AUTOCLEAN_SRC) \ $(PLUGIN_BCLI_SRC) \ @@ -36,10 +41,12 @@ PLUGIN_ALL_SRC := \ $(PLUGIN_LIB_SRC) \ $(PLUGIN_MULTIFUNDCHANNEL_SRC) \ $(PLUGIN_PAY_LIB_SRC) \ - $(PLUGIN_PAY_SRC) + $(PLUGIN_PAY_SRC) \ + $(PLUGIN_SPENDER_SRC) PLUGIN_ALL_HEADER := \ $(PLUGIN_LIB_HEADER) \ - $(PLUGIN_PAY_LIB_HEADER) + $(PLUGIN_PAY_LIB_HEADER) \ + $(PLUGIN_SPENDER_HEADER) PLUGIN_ALL_OBJS := $(PLUGIN_ALL_SRC:.c=.o) PLUGINS := \ @@ -49,7 +56,8 @@ PLUGINS := \ plugins/keysend \ plugins/pay \ plugins/multifundchannel \ - plugins/txprepare + plugins/txprepare \ + plugins/spenderp # Make sure these depend on everything. ALL_C_SOURCES += $(PLUGIN_ALL_SRC) @@ -112,4 +120,6 @@ $(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) diff --git a/plugins/spender/main.c b/plugins/spender/main.c new file mode 100644 index 000000000..98d742d33 --- /dev/null +++ b/plugins/spender/main.c @@ -0,0 +1,33 @@ +#include +#include + +/*~ The spender plugin contains various commands that handle + * spending from the onchain wallet. */ + +static +void spender_init(struct plugin *p, const char *b, const jsmntok_t *t) +{ + /* whatever_init(p, b, t); */ +} + +int main(int argc, char **argv) +{ + char *owner = tal(NULL, char); + struct plugin_command *commands; + + setup_locale(); + + commands = tal_arr(owner, struct plugin_command, 0); + + /* tal_expand(&commands, whatever_commands, num_whatever_commands); */ + + plugin_main(argv, &spender_init, PLUGIN_STATIC, true, + NULL, + commands, tal_count(commands), + NULL, 0, + NULL, 0, + NULL); + + tal_free(owner); + return 0; +}