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

Function bech32_decode_alloc

common/bolt11.c:707–727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

705}
706
707static bool bech32_decode_alloc(const tal_t *ctx,
708 const char **hrp_ret,
709 const u5 **data_ret,
710 size_t *data_len,
711 const char *str)
712{
713 char *hrp = tal_arr(ctx, char, strlen(str) - 6);
714 u5 *data = tal_arr(ctx, u5, strlen(str) - 8);
715
716 if (bech32_decode(hrp, data, data_len, str, (size_t)-1)
717 != BECH32_ENCODING_BECH32) {
718 tal_free(hrp);
719 tal_free(data);
720 return false;
721 }
722
723 /* We needed temporaries because these are const */
724 *hrp_ret = hrp;
725 *data_ret = data;
726 return true;
727}
728
729static bool has_lightning_prefix(const char *invstring)
730{

Callers 1

bolt11_decode_nosigFunction · 0.85

Calls 2

tal_freeFunction · 0.85
bech32_decodeFunction · 0.70

Tested by

no test coverage detected