mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
paymod: Expose riskfactor and wire through to getroute
This commit is contained in:
parent
d8b8a0b31e
commit
da8eb6fb4c
4 changed files with 11 additions and 2 deletions
|
@ -23,6 +23,7 @@ struct payment *payment_new(tal_t *ctx, struct command *cmd,
|
|||
p->getroute = tal(p, struct getroute_request);
|
||||
p->label = NULL;
|
||||
p->failreason = NULL;
|
||||
p->getroute->riskfactorppm = 10000000;
|
||||
|
||||
/* Copy over the relevant pieces of information. */
|
||||
if (parent != NULL) {
|
||||
|
@ -433,9 +434,10 @@ static void payment_getroute(struct payment *p)
|
|||
payment_getroute_error, p);
|
||||
json_add_node_id(req->js, "id", p->getroute->destination);
|
||||
json_add_amount_msat_only(req->js, "msatoshi", p->getroute->amount);
|
||||
json_add_num(req->js, "riskfactor", 1);
|
||||
json_add_num(req->js, "cltv", p->getroute->cltv);
|
||||
json_add_num(req->js, "maxhops", p->getroute->max_hops);
|
||||
json_add_member(req->js, "riskfactor", false, "%lf",
|
||||
p->getroute->riskfactorppm / 1000000.0);
|
||||
payment_getroute_add_excludes(p, req->js);
|
||||
send_outreq(p->plugin, req);
|
||||
}
|
||||
|
|
|
@ -129,6 +129,9 @@ struct getroute_request {
|
|||
struct amount_msat amount;
|
||||
u32 cltv;
|
||||
u32 max_hops;
|
||||
|
||||
/* Riskfactor milionths */
|
||||
u64 riskfactorppm;
|
||||
};
|
||||
|
||||
struct payment_constraints {
|
||||
|
|
|
@ -1863,6 +1863,7 @@ static struct command_result *json_paymod(struct command *cmd,
|
|||
struct amount_msat *exemptfee, *msat;
|
||||
const char *label;
|
||||
unsigned int *retryfor;
|
||||
u64 *riskfactor_millionths;
|
||||
#if DEVELOPER
|
||||
bool *use_shadow;
|
||||
#endif
|
||||
|
@ -1875,6 +1876,8 @@ static struct command_result *json_paymod(struct command *cmd,
|
|||
if (!param(cmd, buf, params, p_req("bolt11", param_string, &b11str),
|
||||
p_opt("msatoshi", param_msat, &msat),
|
||||
p_opt("label", param_string, &label),
|
||||
p_opt_def("riskfactor", param_millionths,
|
||||
&riskfactor_millionths, 10000000),
|
||||
p_opt_def("exemptfee", param_msat, &exemptfee, AMOUNT_MSAT(5000)),
|
||||
p_opt_def("maxdelay", param_number, &maxdelay,
|
||||
maxdelay_default),
|
||||
|
@ -1937,6 +1940,7 @@ static struct command_result *json_paymod(struct command *cmd,
|
|||
p->why = "Initial attempt";
|
||||
p->constraints.cltv_budget = *maxdelay;
|
||||
p->deadline = timeabs_add(time_now(), time_from_sec(*retryfor));
|
||||
p->getroute->riskfactorppm = *riskfactor_millionths;
|
||||
|
||||
if (!amount_msat_fee(&p->constraints.fee_budget, p->amount, 0,
|
||||
*maxfee_pct_millionths / 100)) {
|
||||
|
|
|
@ -3077,7 +3077,7 @@ def test_pay_modifiers(node_factory):
|
|||
# Make sure that the dummy param is in the help (and therefore assigned to
|
||||
# the modifier data).
|
||||
hlp = l1.rpc.help("paymod")['help'][0]
|
||||
assert(hlp['command'] == 'paymod bolt11 [msatoshi] [label] [exemptfee] [maxdelay] [retry_for] [maxfeepercent] [use_shadow]')
|
||||
assert(hlp['command'] == 'paymod bolt11 [msatoshi] [label] [riskfactor] [exemptfee] [maxdelay] [retry_for] [maxfeepercent] [use_shadow]')
|
||||
|
||||
inv = l2.rpc.invoice(123, 'lbl', 'desc')['bolt11']
|
||||
r = l1.rpc.paymod(inv)
|
||||
|
|
Loading…
Add table
Reference in a new issue