mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
pay: add a dev-only parameter to deactivate shadow routing
Had to make a special pylightning function to avoid rewriting all calls to 'pay()' with 'rpc.call()' in the next commit..
This commit is contained in:
@@ -103,6 +103,11 @@ struct pay_command {
|
||||
/* Any remaining routehints to try. */
|
||||
struct route_info **routehints;
|
||||
|
||||
#if DEVELOPER
|
||||
/* Disable the use of shadow route ? */
|
||||
double use_shadow;
|
||||
#endif
|
||||
|
||||
/* Current node during shadow route calculation. */
|
||||
const char *shadow_dest;
|
||||
};
|
||||
@@ -873,6 +878,10 @@ static struct command_result *add_shadow_route(struct command *cmd,
|
||||
static struct command_result *shadow_route(struct command *cmd,
|
||||
struct pay_command *pc)
|
||||
{
|
||||
#if DEVELOPER
|
||||
if (!pc->use_shadow)
|
||||
return start_pay_attempt(cmd, pc, "Initial attempt");
|
||||
#endif
|
||||
if (pseudorand(2) == 0)
|
||||
return start_pay_attempt(cmd, pc, "Initial attempt");
|
||||
|
||||
@@ -1034,6 +1043,9 @@ static struct command_result *json_pay(struct command *cmd,
|
||||
double *maxfeepercent;
|
||||
unsigned int *maxdelay;
|
||||
struct amount_msat *exemptfee;
|
||||
#if DEVELOPER
|
||||
bool *use_shadow;
|
||||
#endif
|
||||
|
||||
if (!param(cmd, buf, params,
|
||||
p_req("bolt11", param_string, &b11str),
|
||||
@@ -1045,6 +1057,9 @@ static struct command_result *json_pay(struct command *cmd,
|
||||
p_opt_def("maxdelay", param_number, &maxdelay,
|
||||
maxdelay_default),
|
||||
p_opt_def("exemptfee", param_msat, &exemptfee, AMOUNT_MSAT(5000)),
|
||||
#if DEVELOPER
|
||||
p_opt_def("use_shadow", param_bool, &use_shadow, true),
|
||||
#endif
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
@@ -1096,6 +1111,9 @@ static struct command_result *json_pay(struct command *cmd,
|
||||
pc->current_routehint = NULL;
|
||||
pc->routehints = filter_routehints(pc, b11->routes);
|
||||
pc->expensive_route = NULL;
|
||||
#if DEVELOPER
|
||||
pc->use_shadow = *use_shadow;
|
||||
#endif
|
||||
|
||||
/* Get capacities of local channels (no parameters) */
|
||||
return send_outreq(cmd, "listpeers", listpeers_done, forward_error, pc,
|
||||
|
||||
Reference in New Issue
Block a user