Browse Source

paymod: Add the final cltv delta to the getroute call

paymod-02
Christian Decker 5 years ago
parent
commit
57fd86902a
  1. 5
      plugins/libplugin-pay.c
  2. 4
      plugins/libplugin-pay.h
  3. 5
      plugins/pay.c

5
plugins/libplugin-pay.c

@ -7,6 +7,8 @@
#include <ccan/tal/str/str.h>
#include <common/json_stream.h>
#define DEFAULT_FINAL_CLTV_DELTA 9
/* Just a container to collect a subtree result so we can summarize all
* sub-payments and return a reasonable result to the caller of `pay` */
struct payment_tree_result {
@ -35,12 +37,14 @@ struct payment *payment_new(tal_t *ctx, struct command *cmd,
p->cmd = cmd;
p->start_time = time_now();
p->result = NULL;
p->getroute_cltv = DEFAULT_FINAL_CLTV_DELTA;
/* Copy over the relevant pieces of information. */
if (parent != NULL) {
assert(cmd == NULL);
tal_arr_expand(&parent->children, p);
p->destination = p->getroute_destination = parent->destination;
p->getroute_cltv = parent->getroute_cltv;
p->amount = parent->amount;
p->payment_hash = parent->payment_hash;
p->partid = payment_root(p->parent)->next_partid++;
@ -241,6 +245,7 @@ static void payment_getroute(struct payment *p)
json_add_node_id(req->js, "id", p->getroute_destination);
json_add_amount_msat_only(req->js, "msatoshi", p->amount);
json_add_num(req->js, "riskfactor", 1);
json_add_num(req->js, "cltv", p->getroute_cltv);
send_outreq(p->plugin, req);
}

4
plugins/libplugin-pay.h

@ -2,6 +2,7 @@
#define LIGHTNING_PLUGINS_LIBPLUGIN_PAY_H
#include "config.h"
#include <common/bolt11.h>
#include <plugins/libplugin.h>
#include <wire/gen_onion_wire.h>
@ -129,6 +130,7 @@ struct payment {
* the above destination if we use rendez-vous routing of blinded
* paths to amend the route later in a mixin. */
struct node_id *getroute_destination;
u32 getroute_cltv;
struct createonion_request *createonion_request;
struct createonion_response *createonion_response;
@ -164,6 +166,8 @@ struct payment {
void **modifier_data;
int current_modifier;
struct bolt11 *invoice;
struct payment_result *result;
};

5
plugins/pay.c

@ -1769,7 +1769,10 @@ static struct command_result *json_paymod(struct command *cmd,
p->json_toks = params;
p->destination = p->getroute_destination = &b11->receiver_id;
p->payment_hash = tal_dup(p, struct sha256, &b11->payment_hash);
p->payment_secret = tal_dup(p, struct secret, b11->payment_secret);
p->payment_secret = b11->payment_secret
? tal_dup(p, struct secret, b11->payment_secret)
: NULL;
p->invoice = tal_steal(p, b11);
payment_start(p);
list_add_tail(&payments, &p->list);

Loading…
Cancel
Save