diff --git a/daemon/json.c b/daemon/json.c index 169869b97..b5c64a5a0 100644 --- a/daemon/json.c +++ b/daemon/json.c @@ -445,6 +445,14 @@ void json_add_pubkey(struct json_result *response, json_add_hex(response, fieldname, der, sizeof(der)); } +void json_add_short_channel_id(struct json_result *response, + const char *fieldname, + const struct short_channel_id *id) +{ + char *str = tal_fmt(response, "%d:%d:%d", id->blocknum, id->txnum, id->outnum); + json_add_string(response, fieldname, str); +} + void json_add_object(struct json_result *result, ...) { va_list ap; diff --git a/daemon/json.h b/daemon/json.h index dcf108351..178c26856 100644 --- a/daemon/json.h +++ b/daemon/json.h @@ -3,6 +3,7 @@ #include "config.h" #include #include +#include #include #include #include @@ -106,6 +107,11 @@ void json_add_pubkey(struct json_result *response, const char *fieldname, const struct pubkey *key); +/* '"fieldname" : "1234/5/6"' */ +void json_add_short_channel_id(struct json_result *response, + const char *fieldname, + const struct short_channel_id *id); + void json_add_object(struct json_result *result, ...); const char *json_result_string(const struct json_result *result); diff --git a/daemon/routing.c b/daemon/routing.c index 17324d9a8..e838872a3 100644 --- a/daemon/routing.c +++ b/daemon/routing.c @@ -911,6 +911,7 @@ struct route_hop *get_route(tal_t *ctx, struct routing_state *rstate, total_delay = 0; for (i = tal_count(route) - 1; i >= 0; i--) { + hops[i + 1].channel_id = route[i]->short_channel_id; hops[i + 1].nodeid = route[i]->dst->id; hops[i + 1].amount = total_amount; total_amount += connection_fee(route[i], total_amount); @@ -921,6 +922,7 @@ struct route_hop *get_route(tal_t *ctx, struct routing_state *rstate, hops[i + 1].delay = total_delay; } /* Backfill the first hop manually */ + hops[0].channel_id = first_conn->short_channel_id; hops[0].nodeid = first_conn->dst->id; /* We don't charge ourselves any fees. */ hops[0].amount = total_amount; diff --git a/daemon/routing.h b/daemon/routing.h index b52fe99b7..a4584c2db 100644 --- a/daemon/routing.h +++ b/daemon/routing.h @@ -90,6 +90,7 @@ struct routing_state { }; struct route_hop { + struct short_channel_id channel_id; struct pubkey nodeid; u32 amount; u32 delay; diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 8af5f4829..9ba1c3a6d 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -252,9 +252,11 @@ static bool json_getroute_reply(struct subd *gossip, const u8 *reply, const int response = new_json_result(cmd); json_object_start(response, NULL); json_array_start(response, "route"); - for (i=0; inodeid); + fromwire_short_channel_id(pptr, max, &entry->channel_id); entry->amount = fromwire_u32(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_u32(pptr, entry->amount); towire_u32(pptr, entry->delay); }