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

Function push_varlen_field

common/bolt11.c:955–969  ·  view source on GitHub ↗

BOLT #11: * * - if `x` is included: * - SHOULD use the minimum `data_length` possible. * - MUST include one `c` field (`min_final_cltv_expiry`). *... * - SHOULD use the minimum `data_length` possible. */

Source from the content-addressed store, hash-verified

953 * - SHOULD use the minimum `data_length` possible.
954 */
955static void push_varlen_field(u5 **data, char type, u64 val)
956{
957 assert(bech32_charset_rev[(unsigned char)type] >= 0);
958 push_varlen_uint(data, bech32_charset_rev[(unsigned char)type], 5);
959
960 for (size_t nbits = 5; nbits < 65; nbits += 5) {
961 if ((val >> nbits) == 0) {
962 push_varlen_uint(data, nbits / 5, 10);
963 push_varlen_uint(data, val, nbits);
964 return;
965 }
966 }
967 /* Can't be encoded in <= 60 bits. */
968 abort();
969}
970
971/* BOLT #11:
972 *

Callers 2

encode_xFunction · 0.85
encode_cFunction · 0.85

Calls 2

push_varlen_uintFunction · 0.85
abortFunction · 0.85

Tested by

no test coverage detected