diff --git a/plugins/Makefile b/plugins/Makefile index 2199a5688..f3f75208f 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -22,6 +22,7 @@ PLUGIN_COMMON_OBJS := \ common/hash_u5.o \ common/json.o \ common/json_escaped.o \ + common/json_helpers.o \ common/json_tok.o \ common/memleak.o \ common/param.o \ diff --git a/plugins/pay.c b/plugins/pay.c index 1f27096f5..3469a7b2d 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -6,6 +6,9 @@ #include #include +/* Public key of this node. */ +static struct pubkey my_id; + struct pay_attempt { const char *route; const char *failure; @@ -325,6 +328,15 @@ static struct command_result *handle_pay(struct command *cmd, " "); } +static void init(struct plugin_conn *rpc) +{ + const char *field; + + field = rpc_delve(tmpctx, "getinfo", "", rpc, ".id"); + if (!pubkey_from_hexstr(field, strlen(field), &my_id)) + plugin_err("getinfo didn't contain valid id: '%s'", field); +} + static const struct plugin_command commands[] = { { "pay2", "Send payment specified by {bolt11} with {msatoshi}", @@ -335,5 +347,5 @@ static const struct plugin_command commands[] = { { int main(int argc, char *argv[]) { - plugin_main(argv, NULL, commands, ARRAY_SIZE(commands)); + plugin_main(argv, init, commands, ARRAY_SIZE(commands)); }