plugins/spender/: New plugin that will eventually absorb all onchain-spending commands.

This commit is contained in:
ZmnSCPxj jxPCSnmZ 2020-09-09 19:55:20 +09:30 committed by Rusty Russell
parent 210734f1b6
commit e04febfe0c
3 changed files with 47 additions and 3 deletions

1
plugins/.gitignore vendored
View File

@ -2,4 +2,5 @@ autoclean
bcli
fundchannel
pay
spenderp
multifundchannel

View File

@ -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)

33
plugins/spender/main.c Normal file
View File

@ -0,0 +1,33 @@
#include <common/utils.h>
#include <plugins/libplugin.h>
/*~ 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;
}