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

Function patch_channel_update

plugins/libplugin-pay.c:1396–1412  ·  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

1394 * one. See ElementsProject/lightning#1730 and lightningnetwork/lnd#1599 for the
1395 * in-depth discussion on why we break message parsing here... */
1396static u8 *patch_channel_update(const tal_t *ctx, u8 *channel_update TAKES)
1397{
1398 u8 *fixed;
1399 if (channel_update != NULL &&
1400 fromwire_peektype(channel_update) != WIRE_CHANNEL_UPDATE) {
1401 /* This should be a channel_update, prefix with the
1402 * WIRE_CHANNEL_UPDATE type, but isn't. Let's prefix it. */
1403 fixed = tal_arr(ctx, u8, 0);
1404 towire_u16(&fixed, WIRE_CHANNEL_UPDATE);
1405 towire(&fixed, channel_update, tal_bytelen(channel_update));
1406 if (taken(channel_update))
1407 tal_free(channel_update);
1408 return fixed;
1409 } else {
1410 return tal_dup_talarr(ctx, u8, channel_update);
1411 }
1412}
1413
1414/* Return NULL if the wrapped onion error message has no channel_update field,
1415 * or return the embedded channel_update message otherwise. */

Callers 1

Calls 6

tal_bytelenFunction · 0.85
takenFunction · 0.85
tal_freeFunction · 0.85
fromwire_peektypeFunction · 0.50
towire_u16Function · 0.50
towireFunction · 0.50

Tested by

no test coverage detected