mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-21 16:14:23 +01:00
plugins/keysend: prevent leak detecting getting upset.
1. We don't keep a pointer to payments (unlike pay, which keeps a linked list), so mark it notleak. 2. plugin->our_features is overloaded for "features we want to set" (used by keysend) and then "features we have". Create a new field, which is cleaner. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
#include <ccan/asort/asort.h>
|
#include <ccan/asort/asort.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/json_tok.h>
|
#include <common/json_tok.h>
|
||||||
|
#include <common/memleak.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <plugins/libplugin-pay.h>
|
#include <plugins/libplugin-pay.h>
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
@@ -223,7 +224,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
|
|||||||
p->label = tal_steal(p, label);
|
p->label = tal_steal(p, label);
|
||||||
payment_start(p);
|
payment_start(p);
|
||||||
/* We're keeping this around now */
|
/* We're keeping this around now */
|
||||||
tal_steal(cmd->plugin, p);
|
tal_steal(cmd->plugin, notleak(p));
|
||||||
return command_still_pending(cmd);
|
return command_still_pending(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ struct plugin {
|
|||||||
|
|
||||||
/* Feature set for lightningd */
|
/* Feature set for lightningd */
|
||||||
struct feature_set *our_features;
|
struct feature_set *our_features;
|
||||||
|
/* Features we want to add to lightningd */
|
||||||
|
const struct feature_set *desired_features;
|
||||||
|
|
||||||
/* Location of the RPC filename in case we need to defer RPC
|
/* Location of the RPC filename in case we need to defer RPC
|
||||||
* initialization or need to recover from a disconnect. */
|
* initialization or need to recover from a disconnect. */
|
||||||
@@ -663,10 +665,10 @@ handle_getmanifest(struct command *getmanifest_cmd,
|
|||||||
}
|
}
|
||||||
json_array_end(params);
|
json_array_end(params);
|
||||||
|
|
||||||
if (p->our_features != NULL) {
|
if (p->desired_features != NULL) {
|
||||||
json_object_start(params, "featurebits");
|
json_object_start(params, "featurebits");
|
||||||
for (size_t i = 0; i < NUM_FEATURE_PLACE; i++) {
|
for (size_t i = 0; i < NUM_FEATURE_PLACE; i++) {
|
||||||
u8 *f = p->our_features->bits[i];
|
u8 *f = p->desired_features->bits[i];
|
||||||
const char *fieldname = feature_place_names[i];
|
const char *fieldname = feature_place_names[i];
|
||||||
if (fieldname == NULL)
|
if (fieldname == NULL)
|
||||||
continue;
|
continue;
|
||||||
@@ -1464,7 +1466,7 @@ static struct plugin *new_plugin(const tal_t *ctx,
|
|||||||
p->next_outreq_id = 0;
|
p->next_outreq_id = 0;
|
||||||
uintmap_init(&p->out_reqs);
|
uintmap_init(&p->out_reqs);
|
||||||
|
|
||||||
p->our_features = tal_steal(p, features);
|
p->desired_features = tal_steal(p, features);
|
||||||
if (init_rpc) {
|
if (init_rpc) {
|
||||||
/* Sync RPC FIXME: maybe go full async ? */
|
/* Sync RPC FIXME: maybe go full async ? */
|
||||||
p->rpc_conn = tal(p, struct rpc_conn);
|
p->rpc_conn = tal(p, struct rpc_conn);
|
||||||
|
|||||||
Reference in New Issue
Block a user