Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions plugins/renepay/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ PLUGIN_RENEPAY_SRC := \
plugins/renepay/routebuilder.c \
plugins/renepay/routetracker.c \
plugins/renepay/routefail.c \
plugins/renepay/sendpay.c \
plugins/renepay/uncertainty.c \
plugins/renepay/mods.c \
plugins/renepay/errorcodes.c \
Expand All @@ -30,7 +29,6 @@ PLUGIN_RENEPAY_HDRS := \
plugins/renepay/routebuilder.h \
plugins/renepay/routetracker.h \
plugins/renepay/routefail.h \
plugins/renepay/sendpay.h \
plugins/renepay/uncertainty.h \
plugins/renepay/mods.h \
plugins/renepay/errorcodes.h \
Expand Down
5 changes: 0 additions & 5 deletions plugins/renepay/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <plugins/renepay/mods.h>
#include <plugins/renepay/payplugin.h>
#include <plugins/renepay/routetracker.h>
#include <plugins/renepay/sendpay.h>
#include <stdio.h>

// TODO(eduardo): notice that pending attempts performed with another
Expand Down Expand Up @@ -460,10 +459,6 @@ static const struct plugin_command commands[] = {
"renepay",
json_renepay
},
{
"renesendpay",
json_renesendpay
},
};

static const struct plugin_notification notifications[] = {
Expand Down
49 changes: 42 additions & 7 deletions plugins/renepay/mods.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,10 +753,30 @@ REGISTER_PAYMENT_MODIFIER(compute_routes, compute_routes_cb);
* request calling sendpay.
*/

static struct command_result *send_routes_cb(struct payment *payment)
static struct command_result *waitblockheight_done(struct command *cmd,
const char *method UNUSED,
const char *buf,
const jsmntok_t *result,
struct payment *payment)
{
assert(payment);
struct routetracker *routetracker = payment->routetracker;
const char *err;
struct command *aux_cmd;
struct route *route;
struct routetracker *routetracker;

err = json_scan(tmpctx, buf, result, "{blockheight:%}",
JSON_SCAN(json_to_u32, &payment->blockheight));
payment->blockheight += 1;

if (err) {
plugin_err(pay_plugin->plugin,
"Failed to read blockheight from waitblockheight "
"response: %s",
err);
return payment_continue(payment);
}

routetracker = payment->routetracker;
assert(routetracker);
if (!routetracker->computed_routes ||
tal_count(routetracker->computed_routes) == 0) {
Expand All @@ -765,12 +785,11 @@ static struct command_result *send_routes_cb(struct payment *payment)
__func__);
return payment_continue(payment);
}
struct command *cmd = payment_command(payment);
assert(cmd);
for (size_t i = 0; i < tal_count(routetracker->computed_routes); i++) {
struct route *route = routetracker->computed_routes[i];
aux_cmd = aux_command(cmd);
route = routetracker->computed_routes[i];

route_sendpay_request(cmd, take(route), payment);
route_sendpay_request(aux_cmd, take(route), payment);

payment_note(payment, LOG_INFORM,
"Sent route request: partid=%" PRIu64
Expand All @@ -785,6 +804,22 @@ static struct command_result *send_routes_cb(struct payment *payment)
return payment_continue(payment);
}

static struct command_result *send_routes_cb(struct payment *payment)
{
struct command *cmd;
struct out_req *req;
assert(payment);
cmd = payment_command(payment);
if (!cmd)
plugin_err(pay_plugin->plugin,
"send_routes_pay_mod: cannot get a valid cmd.");
req =
jsonrpc_request_start(cmd, "waitblockheight", waitblockheight_done,
payment_rpc_failure, payment);
json_add_num(req->js, "blockheight", 0);
return send_outreq(req);
}

REGISTER_PAYMENT_MODIFIER(send_routes, send_routes_cb);

/*****************************************************************************
Expand Down
3 changes: 3 additions & 0 deletions plugins/renepay/payment.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ struct payment {
struct plugin_timer *waitresult_timer;

struct routetracker *routetracker;

/* use this to build the onions */
u32 blockheight;
};

static inline const struct sha256 payment_hash(const struct payment *p)
Expand Down
Loading
Loading