mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
paymod: Add the final cltv delta to the getroute call
This commit is contained in:
@@ -7,6 +7,8 @@
|
|||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/json_stream.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
|
/* 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` */
|
* sub-payments and return a reasonable result to the caller of `pay` */
|
||||||
struct payment_tree_result {
|
struct payment_tree_result {
|
||||||
@@ -35,12 +37,14 @@ struct payment *payment_new(tal_t *ctx, struct command *cmd,
|
|||||||
p->cmd = cmd;
|
p->cmd = cmd;
|
||||||
p->start_time = time_now();
|
p->start_time = time_now();
|
||||||
p->result = NULL;
|
p->result = NULL;
|
||||||
|
p->getroute_cltv = DEFAULT_FINAL_CLTV_DELTA;
|
||||||
|
|
||||||
/* Copy over the relevant pieces of information. */
|
/* Copy over the relevant pieces of information. */
|
||||||
if (parent != NULL) {
|
if (parent != NULL) {
|
||||||
assert(cmd == NULL);
|
assert(cmd == NULL);
|
||||||
tal_arr_expand(&parent->children, p);
|
tal_arr_expand(&parent->children, p);
|
||||||
p->destination = p->getroute_destination = parent->destination;
|
p->destination = p->getroute_destination = parent->destination;
|
||||||
|
p->getroute_cltv = parent->getroute_cltv;
|
||||||
p->amount = parent->amount;
|
p->amount = parent->amount;
|
||||||
p->payment_hash = parent->payment_hash;
|
p->payment_hash = parent->payment_hash;
|
||||||
p->partid = payment_root(p->parent)->next_partid++;
|
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_node_id(req->js, "id", p->getroute_destination);
|
||||||
json_add_amount_msat_only(req->js, "msatoshi", p->amount);
|
json_add_amount_msat_only(req->js, "msatoshi", p->amount);
|
||||||
json_add_num(req->js, "riskfactor", 1);
|
json_add_num(req->js, "riskfactor", 1);
|
||||||
|
json_add_num(req->js, "cltv", p->getroute_cltv);
|
||||||
send_outreq(p->plugin, req);
|
send_outreq(p->plugin, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define LIGHTNING_PLUGINS_LIBPLUGIN_PAY_H
|
#define LIGHTNING_PLUGINS_LIBPLUGIN_PAY_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <common/bolt11.h>
|
||||||
#include <plugins/libplugin.h>
|
#include <plugins/libplugin.h>
|
||||||
#include <wire/gen_onion_wire.h>
|
#include <wire/gen_onion_wire.h>
|
||||||
|
|
||||||
@@ -129,6 +130,7 @@ struct payment {
|
|||||||
* the above destination if we use rendez-vous routing of blinded
|
* the above destination if we use rendez-vous routing of blinded
|
||||||
* paths to amend the route later in a mixin. */
|
* paths to amend the route later in a mixin. */
|
||||||
struct node_id *getroute_destination;
|
struct node_id *getroute_destination;
|
||||||
|
u32 getroute_cltv;
|
||||||
|
|
||||||
struct createonion_request *createonion_request;
|
struct createonion_request *createonion_request;
|
||||||
struct createonion_response *createonion_response;
|
struct createonion_response *createonion_response;
|
||||||
@@ -164,6 +166,8 @@ struct payment {
|
|||||||
void **modifier_data;
|
void **modifier_data;
|
||||||
int current_modifier;
|
int current_modifier;
|
||||||
|
|
||||||
|
struct bolt11 *invoice;
|
||||||
|
|
||||||
struct payment_result *result;
|
struct payment_result *result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1769,7 +1769,10 @@ static struct command_result *json_paymod(struct command *cmd,
|
|||||||
p->json_toks = params;
|
p->json_toks = params;
|
||||||
p->destination = p->getroute_destination = &b11->receiver_id;
|
p->destination = p->getroute_destination = &b11->receiver_id;
|
||||||
p->payment_hash = tal_dup(p, struct sha256, &b11->payment_hash);
|
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);
|
payment_start(p);
|
||||||
list_add_tail(&payments, &p->list);
|
list_add_tail(&payments, &p->list);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user