getroute: add direction to route returned.

We also ignore it in sendpay.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-01-15 20:34:07 +10:30 committed by Christian Decker
parent 0a8b4f8935
commit e2777642c0
5 changed files with 10 additions and 1 deletions

View File

@ -1561,6 +1561,7 @@ struct route_hop *get_route(const tal_t *ctx, struct routing_state *rstate,
hops[i].nodeid = n->id;
hops[i].amount = total_amount;
hops[i].delay = total_delay;
hops[i].direction = idx;
total_amount += connection_fee(c, total_amount);
total_delay += c->delay;
n = other_node(n, route[i]);

View File

@ -207,6 +207,7 @@ get_channel(const struct routing_state *rstate,
struct route_hop {
struct short_channel_id channel_id;
int direction;
struct pubkey nodeid;
u64 amount;
u32 delay;

View File

@ -64,13 +64,16 @@ void fromwire_route_hop(const u8 **pptr, size_t *max, struct route_hop *entry)
{
fromwire_pubkey(pptr, max, &entry->nodeid);
fromwire_short_channel_id(pptr, max, &entry->channel_id);
entry->direction = fromwire_u8(pptr, max);
entry->amount = fromwire_u64(pptr, max);
entry->delay = fromwire_u32(pptr, max);
}
void towire_route_hop(u8 **pptr, const struct route_hop *entry)
{
towire_pubkey(pptr, &entry->nodeid);
towire_short_channel_id(pptr, &entry->channel_id);
towire_u8(pptr, entry->direction);
towire_u64(pptr, entry->amount);
towire_u32(pptr, entry->delay);
}

View File

@ -30,6 +30,7 @@ json_add_route_hop(struct json_stream *r, char const *n,
json_add_pubkey(r, "id", &h->nodeid);
json_add_short_channel_id(r, "channel",
&h->channel_id);
json_add_num(r, "direction", h->direction);
json_add_u64(r, "msatoshi", h->amount);
json_add_num(r, "delay", h->delay);
json_object_end(r);

View File

@ -1004,13 +1004,14 @@ static struct command_result *json_sendpay(struct command *cmd,
u64 *amount;
struct pubkey *id;
struct short_channel_id *channel;
unsigned *delay;
unsigned *delay, *direction;
if (!param(cmd, buffer, t,
p_req("msatoshi", param_u64, &amount),
p_req("id", param_pubkey, &id),
p_req("delay", param_number, &delay),
p_req("channel", param_short_channel_id, &channel),
p_opt("direction", param_number, &direction),
NULL))
return command_param_failed();
@ -1020,6 +1021,8 @@ static struct command_result *json_sendpay(struct command *cmd,
route[n_hops].nodeid = *id;
route[n_hops].delay = *delay;
route[n_hops].channel_id = *channel;
/* FIXME: Actually ignored by sending code! */
route[n_hops].direction = direction ? *direction : 0;
n_hops++;
}