pay: Strip the type prefix from nested channel_updates

This is the counterpart for the previous commit, stripping the type prefix
channel_update, to be consistent with lnd and eclair which do it like this.
This commit is contained in:
Christian Decker 2018-07-30 13:16:20 +02:00 committed by Rusty Russell
parent f449f9d3ef
commit 6bbea741d1
2 changed files with 16 additions and 2 deletions

View File

@ -818,7 +818,7 @@ static u8 *foreign_channel_update(const tal_t *ctx,
struct peer *peer,
const struct short_channel_id *scid)
{
u8 *msg, *update;
u8 *msg, *update, *channel_update;
msg = towire_gossip_get_update(NULL, scid);
msg = gossipd_wait_sync_reply(tmpctx, peer, take(msg),
@ -826,8 +826,21 @@ static u8 *foreign_channel_update(const tal_t *ctx,
if (!fromwire_gossip_get_update_reply(ctx, msg, &update))
status_failed(STATUS_FAIL_GOSSIP_IO,
"Invalid update reply");
/* Strip the type from the channel_update. Due to the specification
* being underspecified, some implementations skipped the type
* prefix. Since we are in the minority we adapt (See #1730 and
* lightningnetwork/lnd#1599 for details). */
if (update && fromwire_peektype(update) == WIRE_CHANNEL_UPDATE) {
assert(tal_bytelen(update) > 2);
channel_update = tal_arr(ctx, u8, 0);
towire(&channel_update, update + 2, tal_bytelen(update) - 2);
tal_free(update);
return channel_update;
} else {
return update;
}
}
static u8 *make_failmsg(const tal_t *ctx,
struct peer *peer,

View File

@ -402,6 +402,7 @@ static void report_routing_failure(struct log *log,
type_to_string(tmpctx, struct short_channel_id,
&fail->erring_channel),
tal_hex(tmpctx, fail->channel_update));
gossip_msg = towire_gossip_routing_failure(tmpctx,
&fail->erring_node,
&fail->erring_channel,