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

Function decode_d

common/bolt11.c:184–202  ·  view source on GitHub ↗

BOLT #11: * * `d` (13): `data_length` variable. Short description of purpose of payment * (UTF-8), e.g. '1 cup of coffee' or 'ナンセンス 1杯' */

Source from the content-addressed store, hash-verified

182 * (UTF-8), e.g. '1 cup of coffee' or 'ナンセンス 1杯'
183 */
184static char *decode_d(struct bolt11 *b11,
185 struct hash_u5 *hu5,
186 u5 **data, size_t *data_len,
187 size_t data_length, bool *have_d)
188{
189 u8 *desc;
190 if (*have_d)
191 return unknown_field(b11, hu5, data, data_len, 'd', data_length);
192
193 desc = tal_arr(NULL, u8, data_length * 5 / 8);
194 pull_bits_certain(hu5, data, data_len, desc, data_length*5, false);
195
196 *have_d = true;
197 b11->description = utf8_str(b11, take(desc), tal_bytelen(desc));
198 if (b11->description)
199 return NULL;
200
201 return tal_fmt(b11, "d: invalid utf8");
202}
203
204/* BOLT #11:
205 *

Callers 1

bolt11_decode_nosigFunction · 0.85

Calls 3

unknown_fieldFunction · 0.85
utf8_strFunction · 0.85
tal_bytelenFunction · 0.85

Tested by

no test coverage detected