plugins/spender/multifundchannel.c: Move multifundchannel to the spenderp plugin.

This commit is contained in:
ZmnSCPxj jxPCSnmZ 2020-08-21 17:31:33 +08:00 committed by Rusty Russell
parent 976c6e5c83
commit f6c145d2df
4 changed files with 16 additions and 36 deletions

View File

@ -24,13 +24,12 @@ 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/main.c \
plugins/spender/multifundchannel.c \
plugins/spender/multiwithdraw.c
PLUGIN_SPENDER_HEADER := \
plugins/spender/multifundchannel.h \
plugins/spender/multiwithdraw.h
PLUGIN_SPENDER_OBJS := $(PLUGIN_SPENDER_SRC:.c=.o)
@ -41,7 +40,6 @@ PLUGIN_ALL_SRC := \
$(PLUGIN_KEYSEND_SRC) \
$(PLUGIN_TXPREPARE_SRC) \
$(PLUGIN_LIB_SRC) \
$(PLUGIN_MULTIFUNDCHANNEL_SRC) \
$(PLUGIN_PAY_LIB_SRC) \
$(PLUGIN_PAY_SRC) \
$(PLUGIN_SPENDER_SRC)
@ -57,7 +55,6 @@ PLUGINS := \
plugins/fundchannel \
plugins/keysend \
plugins/pay \
plugins/multifundchannel \
plugins/txprepare \
plugins/spenderp
@ -120,8 +117,6 @@ plugins/bcli: bitcoin/chainparams.o $(PLUGIN_BCLI_OBJS) $(PLUGIN_LIB_OBJS) $(PLU
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)

View File

@ -1,6 +1,7 @@
#include <common/utils.h>
#include <plugins/libplugin.h>
#include <plugins/spender/multiwithdraw.h>
#include <plugins/spender/multifundchannel.h>
/*~ The spender plugin contains various commands that handle
* spending from the onchain wallet. */
@ -21,6 +22,7 @@ int main(int argc, char **argv)
commands = tal_arr(owner, struct plugin_command, 0);
tal_expand(&commands, multiwithdraw_commands, num_multiwithdraw_commands);
tal_expand(&commands, multifundchannel_commands, num_multifundchannel_commands);
/* tal_expand(&commands, whatever_commands, num_whatever_commands); */
plugin_main(argv, &spender_init, PLUGIN_STATIC, true,

View File

@ -19,7 +19,7 @@
#include <common/pseudorand.h>
#include <common/type_to_string.h>
#include <common/utils.h>
#include <plugins/libplugin.h>
#include <plugins/spender/multifundchannel.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
@ -2006,7 +2006,6 @@ json_multifundchannel(struct command *cmd,
return perform_multifundchannel(mfc);
}
static
const struct plugin_command multifundchannel_commands[] = {
{
"multifundchannel",
@ -2022,32 +2021,6 @@ const struct plugin_command multifundchannel_commands[] = {
json_multifundchannel
}
};
static
const unsigned int num_multifundchannel_commands =
const size_t num_multifundchannel_commands =
ARRAY_SIZE(multifundchannel_commands);
static
void multifundchannel_init(struct plugin *plugin,
const char *buf UNUSED,
const jsmntok_t *config UNUSED)
{
/* Save our chainparams. */
const char *network_name;
network_name = rpc_delve(tmpctx, plugin, "listconfigs",
take(json_out_obj(NULL, "config",
"network")),
".network");
chainparams = chainparams_for_network(network_name);
}
int main(int argc, char **argv)
{
setup_locale();
plugin_main(argv,
&multifundchannel_init, PLUGIN_RESTARTABLE,
true,
NULL,
multifundchannel_commands, num_multifundchannel_commands,
NULL, 0, NULL, 0, NULL);
}

View File

@ -0,0 +1,10 @@
#ifndef LIGHTNING_PLUGINS_SPENDER_MULTIFUNDCHANNEL_H
#define LIGHTNING_PLUGINS_SPENDER_MULTIFUNDCHANNEL_H
#include "config.h"
#include <plugins/libplugin.h>
extern const struct plugin_command multifundchannel_commands[];
extern const size_t num_multifundchannel_commands;
#endif /* LIGHTNING_PLUGINS_SPENDER_MULTIFUNDCHANNEL_H */