Browse Source

gossipd: fix riskfactor passing.

We used a u16, and a 1000 multiplier, which meant we wrapped at
riskfactor 66.  We also never undid the multiplier, so we ended up
applying 1000x the riskfactor they specified.

This changes us to pass the riskfactor with a 1M multiplier.  The next
patch changes the definition of riskfactor to be more useful.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
fix-test_pay_direct-flake
Rusty Russell 6 years ago
committed by Christian Decker
parent
commit
662bb0c565
  1. 3
      gossipd/gossip_wire.csv
  2. 6
      gossipd/gossipd.c
  3. 3
      lightningd/gossip_control.c

3
gossipd/gossip_wire.csv

@ -29,7 +29,8 @@ gossip_getroute_request,3006
gossip_getroute_request,,source,struct pubkey
gossip_getroute_request,,destination,struct pubkey
gossip_getroute_request,,msatoshi,u64
gossip_getroute_request,,riskfactor,u16
# We don't pass doubles, so pass riskfactor * 1000000.
gossip_getroute_request,,riskfactor_by_million,u64
gossip_getroute_request,,final_cltv,u32
gossip_getroute_request,,fuzz,double
gossip_getroute_request,,num_excluded,u16

Can't render this file because it has a wrong number of fields in line 6.

6
gossipd/gossipd.c

@ -1894,7 +1894,7 @@ static struct io_plan *getroute_req(struct io_conn *conn, struct daemon *daemon,
struct pubkey source, destination;
u64 msatoshi;
u32 final_cltv;
u16 riskfactor;
u64 riskfactor_by_million;
u32 max_hops;
u8 *out;
struct route_hop *hops;
@ -1909,7 +1909,7 @@ static struct io_plan *getroute_req(struct io_conn *conn, struct daemon *daemon,
* avoid being too predictable. */
if (!fromwire_gossip_getroute_request(msg, msg,
&source, &destination,
&msatoshi, &riskfactor,
&msatoshi, &riskfactor_by_million,
&final_cltv, &fuzz,
&excluded,
&max_hops))
@ -1921,7 +1921,7 @@ static struct io_plan *getroute_req(struct io_conn *conn, struct daemon *daemon,
/* routing.c does all the hard work; can return NULL. */
hops = get_route(tmpctx, daemon->rstate, &source, &destination,
msatoshi, riskfactor, final_cltv,
msatoshi, riskfactor_by_million / 1000000.0, final_cltv,
fuzz, pseudorand_u64(), excluded, max_hops);
out = towire_gossip_getroute_reply(NULL, hops);

3
lightningd/gossip_control.c

@ -352,7 +352,8 @@ static struct command_result *json_getroute(struct command *cmd,
}
u8 *req = towire_gossip_getroute_request(cmd, source, destination,
*msatoshi, *riskfactor * 1000,
*msatoshi,
*riskfactor * 1000000.0,
*cltv, fuzz,
excluded,
*max_hops);

Loading…
Cancel
Save