diff --git a/plugins/Makefile b/plugins/Makefile index 5df70670c..ca1222bbd 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -12,7 +12,6 @@ PLUGIN_LIB_HEADER := plugins/libplugin.h PLUGIN_LIB_OBJS := $(PLUGIN_LIB_SRC:.c=.o) PLUGIN_COMMON_OBJS := \ - bitcoin/chainparams.o \ bitcoin/pubkey.o \ bitcoin/pullpush.o \ bitcoin/script.o \ @@ -42,11 +41,11 @@ PLUGIN_COMMON_OBJS := \ wire/fromwire.o \ wire/towire.o -plugins/pay: $(PLUGIN_PAY_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) +plugins/pay: bitcoin/chainparams.o $(PLUGIN_PAY_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) -plugins/autoclean: $(PLUGIN_AUTOCLEAN_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) +plugins/autoclean: bitcoin/chainparams.o $(PLUGIN_AUTOCLEAN_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) -plugins/fundchannel: $(PLUGIN_FUNDCHANNEL_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) $(PLUGIN_PAY_OBJS) $(PLUGIN_AUTOCLEAN_OBJS) $(PLUGIN_FUNDCHANNEL_OBJS) $(PLUGIN_LIB_OBJS): $(PLUGIN_LIB_HEADER) diff --git a/plugins/fundchannel.c b/plugins/fundchannel.c index a5b0a544a..6d7374f09 100644 --- a/plugins/fundchannel.c +++ b/plugins/fundchannel.c @@ -1,7 +1,9 @@ +#include #include #include #include #include +#include #include #include #include @@ -9,8 +11,8 @@ #include #include -const char *placeholder_funding_addr = "bcrt1qh9vpp7pylppexnaqg2kdp0kt55sg0qf7yc8d4m4ug26uhx47z3jqvgnzrj"; const char *placeholder_script = "0020b95810f824f843934fa042acd0becba52087813e260edaeebc42b5cb9abe1464"; +const char *placeholder_funding_addr; /* FIXME: dynamically query */ const struct amount_sat max_funding = AMOUNT_SAT_INIT((1 << 24) - 1); @@ -403,7 +405,19 @@ static struct command_result *json_fundchannel(struct command *cmd, static void init(struct plugin_conn *rpc, const char *buf UNUSED, const jsmntok_t *config UNUSED) { - /* This method left intentionally blank. */ + /* Figure out what the 'placeholder' addr is */ + const char *network_name; + const struct chainparams *chainparams; + u8 *placeholder = tal_hexdata(tmpctx, placeholder_script, strlen(placeholder_script)); + + network_name = rpc_delve(tmpctx, "listconfigs", + take(json_out_obj(NULL, "config", + "network")), + rpc, ".network"); + chainparams = chainparams_for_network(network_name); + placeholder_funding_addr = encode_scriptpubkey_to_addr(NULL, + chainparams->bip173_name, + placeholder); }