From 2d198e22d07b9b68390520dbb17f59bb248759b9 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 15 Mar 2017 13:36:35 +0100 Subject: [PATCH] jsonrpc: Added nested messages for the getroute reply The `route_hop` struct introduced in the previous refactoring is reused when returning the reply to a `getroute` request. Since these are nested messages I added the serialization and deserialization methods. --- lightningd/gossip_msg.c | 14 ++++++++++++++ lightningd/gossip_msg.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/lightningd/gossip_msg.c b/lightningd/gossip_msg.c index 3722b844f..8b16cd30d 100644 --- a/lightningd/gossip_msg.c +++ b/lightningd/gossip_msg.c @@ -25,3 +25,17 @@ void towire_gossip_getnodes_entry(u8 **pptr, const struct gossip_getnodes_entry } towire_u16(pptr, entry->port); } + +void fromwire_route_hop(const u8 **pptr, size_t *max, struct route_hop *entry) +{ + fromwire_pubkey(pptr, max, &entry->nodeid); + 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_u32(pptr, entry->amount); + towire_u32(pptr, entry->delay); +} + diff --git a/lightningd/gossip_msg.h b/lightningd/gossip_msg.h index 40e7843d6..cb3908bb6 100644 --- a/lightningd/gossip_msg.h +++ b/lightningd/gossip_msg.h @@ -2,6 +2,7 @@ #define LIGHTNING_LIGHTNINGD_GOSSIP_MSG_H #include "config.h" #include +#include struct gossip_getnodes_entry { struct pubkey nodeid; @@ -12,4 +13,7 @@ struct gossip_getnodes_entry { void fromwire_gossip_getnodes_entry(const tal_t *ctx, const u8 **pptr, size_t *max, struct gossip_getnodes_entry *entry); void towire_gossip_getnodes_entry(u8 **pptr, const struct gossip_getnodes_entry *entry); +void fromwire_route_hop(const u8 **pprt, size_t *max, struct route_hop *entry); +void towire_route_hop(u8 **pprt, const struct route_hop *entry); + #endif /* LIGHTNING_LIGHTGNINGD_GOSSIP_MSG_H */