MCPcopy Create free account
hub / github.com/ElementsProject/lightning / patch_channel_update

Function patch_channel_update

plugins/renepay/routefail.c:66–81  ·  view source on GitHub ↗

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... */

Source from the content-addressed store, hash-verified

64 * one. See ElementsProject/lightning#1730 and lightningnetwork/lnd#1599 for the
65 * in-depth discussion on why we break message parsing here... */
66static u8 *patch_channel_update(const tal_t *ctx, u8 *channel_update TAKES)
67{
68 u8 *fixed;
69 if (channel_update != NULL &&
70 fromwire_peektype(channel_update) != WIRE_CHANNEL_UPDATE) {
71 /* This should be a channel_update, prefix with the
72 * WIRE_CHANNEL_UPDATE type, but isn't. Let's prefix it. */
73 fixed = tal_arr(ctx, u8, 0);
74 towire_u16(&fixed, WIRE_CHANNEL_UPDATE);
75 towire(&fixed, channel_update, tal_bytelen(channel_update));
76 tal_free_if_taken(channel_update);
77 return fixed;
78 } else {
79 return tal_dup_talarr(ctx, u8, channel_update);
80 }
81}
82
83/* Return NULL if the wrapped onion error message has no channel_update field,
84 * or return the embedded channel_update message otherwise. */

Callers 1

Calls 5

fromwire_peektypeFunction · 0.85
tal_bytelenFunction · 0.85
tal_free_if_takenFunction · 0.85
towire_u16Function · 0.50
towireFunction · 0.50

Tested by

no test coverage detected