Fix up the channel_update to include the type if it doesn't currently have * one. See ElementsProject/lightning#1730 and lightningnetwork/lnd#1599 for the * in-depth discussion on why we break message parsing here... */
| 1538 | * one. See ElementsProject/lightning#1730 and lightningnetwork/lnd#1599 for the |
| 1539 | * in-depth discussion on why we break message parsing here... */ |
| 1540 | static u8 *patch_channel_update(const tal_t *ctx, u8 *channel_update TAKES) |
| 1541 | { |
| 1542 | u8 *fixed; |
| 1543 | if (channel_update != NULL && |
| 1544 | fromwire_peektype(channel_update) != WIRE_CHANNEL_UPDATE) { |
| 1545 | /* This should be a channel_update, prefix with the |
| 1546 | * WIRE_CHANNEL_UPDATE type, but isn't. Let's prefix it. */ |
| 1547 | fixed = tal_arr(ctx, u8, 0); |
| 1548 | towire_u16(&fixed, WIRE_CHANNEL_UPDATE); |
| 1549 | towire(&fixed, channel_update, tal_bytelen(channel_update)); |
| 1550 | tal_free_if_taken(channel_update); |
| 1551 | return fixed; |
| 1552 | } else { |
| 1553 | return tal_dup_talarr(ctx, u8, channel_update); |
| 1554 | } |
| 1555 | } |
| 1556 | |
| 1557 | /* Return NULL if the wrapped onion error message has no channel_update field, |
| 1558 | * or return the embedded channel_update message otherwise. */ |
no test coverage detected