From 40516941af21926679660da7b44e40066f3801e7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 29 Nov 2017 13:47:35 +1030 Subject: [PATCH] channeld: fill in channel_update field in errors by asking gossipd. Signed-off-by: Rusty Russell --- channeld/Makefile | 7 ++++++- channeld/channel.c | 15 ++++++++++++--- gossipd/gossip.c | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/channeld/Makefile b/channeld/Makefile index 49b47adc7..53a60ba80 100644 --- a/channeld/Makefile +++ b/channeld/Makefile @@ -58,7 +58,12 @@ CHANNELD_COMMON_OBJS := \ common/timeout.o \ common/type_to_string.o \ common/utils.o \ - common/version.o + common/version.o \ + common/wireaddr.o \ + gossipd/gen_gossip_wire.o \ + lightningd/gossip_msg.o \ + wire/fromwire.o \ + wire/towire.o # Control daemon uses this: LIGHTNINGD_CHANNEL_CONTROL_HEADERS := $(LIGHTNINGD_CHANNEL_HEADERS_GEN) diff --git a/channeld/channel.c b/channeld/channel.c index 07d68e03c..86ac7751b 100644 --- a/channeld/channel.c +++ b/channeld/channel.c @@ -621,7 +621,7 @@ static u8 *master_wait_sync_reply(const tal_t *ctx, MASTER_FD, &peer->from_master, "master"); } -static UNNEEDED u8 *gossipd_wait_sync_reply(const tal_t *ctx, +static u8 *gossipd_wait_sync_reply(const tal_t *ctx, struct peer *peer, const u8 *msg, enum gossip_wire_type replytype) { @@ -1954,8 +1954,17 @@ static u8 *foreign_channel_update(const tal_t *ctx, struct peer *peer, const struct short_channel_id *scid) { - /* FIXME! */ - return NULL; + tal_t *tmpctx = tal_tmpctx(ctx); + u8 *msg, *update; + + msg = towire_gossip_get_update(tmpctx, scid); + msg = gossipd_wait_sync_reply(tmpctx, peer, take(msg), + WIRE_GOSSIP_GET_UPDATE_REPLY); + if (!fromwire_gossip_get_update_reply(ctx, msg, NULL, &update)) + status_failed(STATUS_FAIL_GOSSIP_IO, + "Invalid update reply"); + tal_free(tmpctx); + return update; } static u8 *make_failmsg(const tal_t *ctx, diff --git a/gossipd/gossip.c b/gossipd/gossip.c index 43d9b4309..89ae62621 100644 --- a/gossipd/gossip.c +++ b/gossipd/gossip.c @@ -641,7 +641,7 @@ static void handle_get_update(struct peer *peer, const u8 *msg) reply: msg = towire_gossip_get_update_reply(msg, update); - msg_enqueue(&peer->peer_out, take(msg)); + daemon_conn_send(&peer->owner_conn, take(msg)); } /**