Skip to content

Commit dbccb8d

Browse files
committed
renepay: add a global payment layer
Changelog-None. Signed-off-by: Lagrang3 <[email protected]>
1 parent bd0bff7 commit dbccb8d

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

plugins/renepay/main.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ static void memleak_mark(struct plugin *p, struct htable *memtable)
3636
memleak_scan_htable(memtable, &pay_plugin->pending_routes->raw);
3737
}
3838

39+
static struct command_result *createlayer_done(struct command *aux_cmd,
40+
const char *method,
41+
const char *buf,
42+
const jsmntok_t *result,
43+
void *unused)
44+
{
45+
return aux_command_done(aux_cmd);
46+
}
47+
3948
static const char *init(struct command *init_cmd,
4049
const char *buf UNUSED, const jsmntok_t *config UNUSED)
4150
{
@@ -92,6 +101,12 @@ static const char *init(struct command *init_cmd,
92101
__func__, skipped_count);
93102

94103
plugin_set_memleak_handler(p, memleak_mark);
104+
struct out_req *req =
105+
jsonrpc_request_start(aux_command(init_cmd), "askrene-create-layer",
106+
createlayer_done, plugin_broken_cb, NULL);
107+
json_add_string(req->js, "layer", RENEPAY_LAYER);
108+
json_add_bool(req->js, "persistent", true);
109+
send_outreq(req);
95110
return NULL;
96111
}
97112

plugins/renepay/mods.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ static struct command_result *getroutes_cb(struct payment *payment)
734734
json_add_string(req->js, NULL, "auto.localchans");
735735
json_add_string(req->js, NULL, "auto.sourcefree");
736736
json_add_string(req->js, NULL, payment->payment_layer);
737+
json_add_string(req->js, NULL, RENEPAY_LAYER);
737738
json_array_end(req->js);
738739
// FIXME: add further constraints here if necessary when they become
739740
// available in getroutes

plugins/renepay/renepayconfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#define LIGHTNING_PLUGINS_RENEPAY_RENEPAYCONFIG_H
33
#include "config.h"
44

5+
#define RENEPAY_LAYER "renepay"
6+
57
#define MAX_NUM_ATTEMPTS 10
68

79
/* Knowledge is proportionally decreased with time up to TIMER_FORGET_SEC when

0 commit comments

Comments
 (0)