diff --git a/CHANGELOG.md b/CHANGELOG.md index d65ced9ef..a464c061d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -109,6 +109,8 @@ changes. ### Removed +- JSON API: the optional 'seed' parameter to `getroute` was removed. + ### Fixed - Startup: more coherent complaint if daemon already running. diff --git a/doc/lightning-getroute.7 b/doc/lightning-getroute.7 index fa218b613..69658de21 100644 --- a/doc/lightning-getroute.7 +++ b/doc/lightning-getroute.7 @@ -2,12 +2,12 @@ .\" Title: lightning-getroute .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 -.\" Date: 09/17/2018 +.\" Date: 12/17/2018 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "LIGHTNING\-GETROUTE" "7" "09/17/2018" "\ \&" "\ \&" +.TH "LIGHTNING\-GETROUTE" "7" "12/17/2018" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -31,7 +31,7 @@ lightning-getroute \- Command for routing a payment (low\-level)\&. .SH "SYNOPSIS" .sp -\fBgetroute\fR \fIid\fR \fImsatoshi\fR \fIriskfactor\fR [\fIcltv\fR] [\fIfuzzpercent\fR] [\fIseed\fR] +\fBgetroute\fR \fIid\fR \fImsatoshi\fR \fIriskfactor\fR [\fIcltv\fR] [\fIfromid\fR] [\fIfuzzpercent\fR] .SH "DESCRIPTION" .sp The \fBgetroute\fR RPC command attempts to find the best route for the payment of \fImsatoshi\fR to lightning node \fIid\fR, such that the payment will arrive at \fIid\fR with \fIcltv\fR\-blocks to spare (default 9)\&. @@ -42,9 +42,9 @@ For example, if you thought there was a 1% chance that a node would fail, and it .sp If you didn\(cqt care about risk, \fIriskfactor\fR would be zero\&. .sp -The \fIfuzzpercent\fR is a positive floating\-point number, representing a percentage of the actual fee\&. The \fIfuzzpercent\fR is used to distort computed fees along each channel, to provide some randomization to the route generated\&. 0\&.0 means the exact fee of that channel is used, while 100\&.0 means the fee used might be from 0 to twice the actual fee\&. The default is 5\&.0, or up to 5% fee distortion\&. +\fIfromid\fR is the node to start the route from: default is this node\&. .sp -The \fIseed\fR is a string whose bytes are used to seed the RNG for the route randomization\&. If not specified, a random string is used\&. +The \fIfuzzpercent\fR is a positive floating\-point number, representing a percentage of the actual fee\&. The \fIfuzzpercent\fR is used to distort computed fees along each channel, to provide some randomization to the route generated\&. 0\&.0 means the exact fee of that channel is used, while 100\&.0 means the fee used might be from 0 to twice the actual fee\&. The default is 5\&.0, or up to 5% fee distortion\&. .SH "RISKFACTOR EFFECT ON ROUTING" .sp The risk factor is treated as if it were an additional fee on the route, for the purposes of comparing routes\&. diff --git a/doc/lightning-getroute.7.txt b/doc/lightning-getroute.7.txt index 8a62a9d1b..53a3f674f 100644 --- a/doc/lightning-getroute.7.txt +++ b/doc/lightning-getroute.7.txt @@ -9,7 +9,7 @@ lightning-getroute - Command for routing a payment (low-level). SYNOPSIS -------- -*getroute* 'id' 'msatoshi' 'riskfactor' ['cltv'] ['fuzzpercent'] ['seed'] +*getroute* 'id' 'msatoshi' 'riskfactor' ['cltv'] ['fromid'] ['fuzzpercent'] DESCRIPTION ----------- @@ -29,6 +29,8 @@ fail, and it would cost you 20% per annum if that happened, If you didn't care about risk, 'riskfactor' would be zero. +'fromid' is the node to start the route from: default is this node. + The 'fuzzpercent' is a positive floating-point number, representing a percentage of the actual fee. The 'fuzzpercent' is used to distort computed fees along each channel, to provide some randomization to the route generated. @@ -36,10 +38,6 @@ to provide some randomization to the route generated. while 100.0 means the fee used might be from 0 to twice the actual fee. The default is 5.0, or up to 5% fee distortion. -The 'seed' is a string whose bytes are used to seed the RNG for -the route randomization. -If not specified, a random string is used. - RISKFACTOR EFFECT ON ROUTING ---------------------------- diff --git a/gossipd/gossip_wire.csv b/gossipd/gossip_wire.csv index 67fc54bc4..a82c00902 100644 --- a/gossipd/gossip_wire.csv +++ b/gossipd/gossip_wire.csv @@ -32,7 +32,6 @@ gossip_getroute_request,,msatoshi,u64 gossip_getroute_request,,riskfactor,u16 gossip_getroute_request,,final_cltv,u32 gossip_getroute_request,,fuzz,double -gossip_getroute_request,,seed,struct siphash_seed gossip_getroute_reply,3106 gossip_getroute_reply,,num_hops,u16 diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index 7dbddca70..ba2472c54 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -1870,7 +1870,6 @@ static struct io_plan *getroute_req(struct io_conn *conn, struct daemon *daemon, u8 *out; struct route_hop *hops; double fuzz; - struct siphash_seed seed; /* To choose between variations, we need to know how much we're * sending (eliminates too-small channels, and also effects the fees @@ -1881,7 +1880,7 @@ static struct io_plan *getroute_req(struct io_conn *conn, struct daemon *daemon, if (!fromwire_gossip_getroute_request(msg, &source, &destination, &msatoshi, &riskfactor, - &final_cltv, &fuzz, &seed)) + &final_cltv, &fuzz)) master_badmsg(WIRE_GOSSIP_GETROUTE_REQUEST, msg); status_trace("Trying to find a route from %s to %s for %"PRIu64" msatoshi", @@ -1891,7 +1890,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, - fuzz, &seed); + fuzz, siphash_seed()); out = towire_gossip_getroute_reply(NULL, hops); daemon_conn_send(daemon->master, take(out)); diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 544ba0af6..3ceb59143 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -300,7 +300,6 @@ static struct command_result *json_getroute(struct command *cmd, struct lightningd *ld = cmd->ld; struct pubkey *destination; struct pubkey *source; - const jsmntok_t *seedtok; u64 *msatoshi; unsigned *cltv; double *riskfactor; @@ -310,7 +309,6 @@ static struct command_result *json_getroute(struct command *cmd, * be selected) at the cost of increasing the probability of * selecting the higher-fee paths. */ double *fuzz; - struct siphash_seed seed; if (!param(cmd, buffer, params, p_req("id", param_pubkey, &destination), @@ -318,29 +316,16 @@ static struct command_result *json_getroute(struct command *cmd, p_req("riskfactor", param_double, &riskfactor), p_opt_def("cltv", param_number, &cltv, 9), p_opt_def("fromid", param_pubkey, &source, ld->id), - p_opt("seed", param_tok, &seedtok), - p_opt_def("fuzzpercent", param_percent, &fuzz, 75.0), + p_opt_def("fuzzpercent", param_percent, &fuzz, 5.0), NULL)) return command_param_failed(); /* Convert from percentage */ *fuzz = *fuzz / 100.0; - if (seedtok) { - if (seedtok->end - seedtok->start > sizeof(seed)) - return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "seed must be < %zu bytes", - sizeof(seed)); - - memset(&seed, 0, sizeof(seed)); - memcpy(&seed, buffer + seedtok->start, - seedtok->end - seedtok->start); - } else - randombytes_buf(&seed, sizeof(seed)); - u8 *req = towire_gossip_getroute_request(cmd, source, destination, *msatoshi, *riskfactor * 1000, - *cltv, fuzz, &seed); + *cltv, fuzz); subd_req(ld->gossip, ld->gossip, req, -1, 0, json_getroute_reply, cmd); return command_still_pending(cmd); } diff --git a/lightningd/payalgo.c b/lightningd/payalgo.c index 4b7e3f319..ac943afec 100644 --- a/lightningd/payalgo.c +++ b/lightningd/payalgo.c @@ -508,7 +508,6 @@ static struct command_result *json_pay_try(struct pay *pay) u8 *req; struct command *cmd = pay->cmd; struct timeabs now = time_now(); - struct siphash_seed seed; u64 maxoverpayment; u64 overpayment; @@ -534,9 +533,6 @@ static struct command_result *json_pay_try(struct pay *pay) /* Clear route */ pay->route = tal_free(pay->route); - /* Generate random seed */ - randombytes_buf(&seed, sizeof(seed)); - /* Generate an overpayment, from fuzz * maxfee. */ /* Now normally the use of double for money is very bad. * Note however that a later stage will ensure that @@ -561,8 +557,7 @@ static struct command_result *json_pay_try(struct pay *pay) pay->msatoshi + overpayment, pay->riskfactor, pay->min_final_cltv_expiry, - &pay->fuzz, - &seed); + &pay->fuzz); subd_req(pay->try_parent, cmd->ld->gossip, req, -1, 0, json_pay_getroute_reply, pay); return NULL;