mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
gossipd: Add fuzz and seed to getroute request.
This commit is contained in:
parent
2b782ee436
commit
216c52940d
@ -1047,13 +1047,19 @@ static struct io_plan *getroute_req(struct io_conn *conn, struct daemon *daemon,
|
||||
u16 riskfactor;
|
||||
u8 *out;
|
||||
struct route_hop *hops;
|
||||
double fuzz;
|
||||
u8 *seed;
|
||||
|
||||
fromwire_gossip_getroute_request(msg, &source, &destination,
|
||||
&msatoshi, &riskfactor, &final_cltv);
|
||||
fromwire_gossip_getroute_request(tmpctx, msg,
|
||||
&source, &destination,
|
||||
&msatoshi, &riskfactor, &final_cltv,
|
||||
&fuzz, &seed);
|
||||
status_trace("Trying to find a route from %s to %s for %d msatoshi",
|
||||
pubkey_to_hexstr(tmpctx, &source),
|
||||
pubkey_to_hexstr(tmpctx, &destination), msatoshi);
|
||||
|
||||
(void) fuzz;
|
||||
(void) seed;
|
||||
hops = get_route(tmpctx, daemon->rstate, &source, &destination,
|
||||
msatoshi, 1, final_cltv);
|
||||
|
||||
|
@ -107,6 +107,9 @@ gossip_getroute_request,,destination,struct pubkey
|
||||
gossip_getroute_request,,msatoshi,u32
|
||||
gossip_getroute_request,,riskfactor,u16
|
||||
gossip_getroute_request,,final_cltv,u32
|
||||
gossip_getroute_request,,fuzz,double
|
||||
gossip_getroute_request,,seedlen,u16
|
||||
gossip_getroute_request,,seed,seedlen*u8
|
||||
|
||||
gossip_getroute_reply,3106
|
||||
gossip_getroute_reply,,num_hops,u16
|
||||
|
|
@ -7,6 +7,7 @@
|
||||
#include <ccan/array_size/array_size.h>
|
||||
#include <ccan/err/err.h>
|
||||
#include <ccan/fdpass/fdpass.h>
|
||||
#include <ccan/isaac/isaac64.h>
|
||||
#include <ccan/take/take.h>
|
||||
#include <ccan/tal/str/str.h>
|
||||
#include <common/features.h>
|
||||
@ -22,6 +23,8 @@
|
||||
#include <lightningd/hsm_control.h>
|
||||
#include <lightningd/jsonrpc.h>
|
||||
#include <lightningd/log.h>
|
||||
#include <sodium/randombytes.h>
|
||||
#include <string.h>
|
||||
#include <wire/gen_peer_wire.h>
|
||||
#include <wire/wire_sync.h>
|
||||
|
||||
@ -305,7 +308,7 @@ static void json_getroute(struct command *cmd, const char *buffer, const jsmntok
|
||||
unsigned cltv = 9;
|
||||
double riskfactor;
|
||||
double fuzz = 5.0;
|
||||
const char *seed = "default";
|
||||
u8 *seed = tal_arrz(cmd, u8, ISAAC64_SEED_SZ_MAX);
|
||||
|
||||
if (!json_get_params(cmd, buffer, params,
|
||||
"id", &idtok,
|
||||
@ -364,15 +367,14 @@ static void json_getroute(struct command *cmd, const char *buffer, const jsmntok
|
||||
/* Convert from percentage */
|
||||
fuzz = fuzz / 100.0;
|
||||
|
||||
if (seedtok)
|
||||
seed = tal_strndup(cmd, buffer + seedtok->start,
|
||||
seedtok->end - seedtok->start);
|
||||
if (seedtok) {
|
||||
tal_resize(&seed, seedtok->end - seedtok->start);
|
||||
memcpy(seed, buffer + seedtok->start,
|
||||
seedtok->end - seedtok->start);
|
||||
} else
|
||||
randombytes_buf(seed, tal_len(seed));
|
||||
|
||||
/* TODO: include in getroute request */
|
||||
(void) fuzz;
|
||||
(void) seed;
|
||||
|
||||
u8 *req = towire_gossip_getroute_request(cmd, &source, &destination, msatoshi, riskfactor*1000, cltv);
|
||||
u8 *req = towire_gossip_getroute_request(cmd, &source, &destination, msatoshi, riskfactor*1000, cltv, &fuzz, seed);
|
||||
subd_req(ld->gossip, ld->gossip, req, -1, 0, json_getroute_reply, cmd);
|
||||
command_still_pending(cmd);
|
||||
}
|
||||
|
@ -224,7 +224,8 @@ static bool json_pay_try(struct pay *pay)
|
||||
&pay->receiver_id,
|
||||
pay->msatoshi,
|
||||
pay->riskfactor,
|
||||
pay->min_final_cltv_expiry);
|
||||
pay->min_final_cltv_expiry,
|
||||
0, tal_arrz(pay, u8, 8));
|
||||
subd_req(pay, cmd->ld->gossip, req, -1, 0, json_pay_getroute_reply, pay);
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user