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

Function main

common/test/run-bolt11.c:284–954  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282}
283
284int main(int argc, char *argv[])
285{
286 struct bolt11 *b11;
287 struct node_id node;
288 struct amount_msat msatoshi;
289 const char *badstr;
290 struct bolt11_field *extra;
291 const char *fail;
292 struct feature_set *fset;
293
294 common_setup(argv[0]);
295
296 /* BOLT #11:
297 *
298 * # Examples
299 *
300 * NB: all the following examples are signed with `priv_key`=`e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734`.
301 */
302 if (!hex_decode("e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734",
303 strlen("e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734"),
304 &privkey, sizeof(privkey)))
305 abort();
306
307 /* BOLT #11:
308 *
309 * > ### Please make a donation of any amount using payment_hash 0001020304050607080900010203040506070809000102030405060708090102 to me @03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad
310 * > lnbc1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq9qrsgq357wnc5r2ueh7ck6q93dj32dlqnls087fxdwk8qakdyafkq3yap9us6v52vjjsrvywa6rt52cm9r9zqt8r2t7mlcwspyetp5h2tztugp9lfyql
311 */
312 if (!node_id_from_hexstr("03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad", strlen("03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad"), &node))
313 abort();
314
315 /* BOLT #11:
316 *
317 * Breakdown:
318 *
319 * * `lnbc`: prefix, Lightning on Bitcoin mainnet
320 * * `1`: Bech32 separator
321 * * `pvjluez`: timestamp (1496314658)
322 * * `s`: payment secret
323 * * `p5`: `data_length` (`p` = 1, `5` = 20; 1 * 32 + 20 == 52)
324 * * `zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs`: payment secret 1111111111111111111111111111111111111111111111111111111111111111
325 * * `p`: payment hash
326 * * `p5`: `data_length` (`p` = 1, `5` = 20; 1 * 32 + 20 == 52)
327 * * `qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypq`: payment hash 0001020304050607080900010203040506070809000102030405060708090102
328 * * `d`: short description
329 * * `pl`: `data_length` (`p` = 1, `l` = 31; 1 * 32 + 31 == 63)
330 * * `2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq`: 'Please consider supporting this project'
331 * * `9`: features
332 * * `qr`: `data_length` (`q` = 0, `r` = 3; 0 * 32 + 3 == 3)
333 * * `sgq`: b100000100000000
334 * * `357wnc5r2ueh7ck6q93dj32dlqnls087fxdwk8qakdyafkq3yap9us6v52vjjsrvywa6rt52cm9r9zqt8r2t7mlcwspyetp5h2tztugp`: signature
335 */
336 b11 = new_bolt11(tmpctx, NULL);
337 b11->chain = chainparams_for_network("bitcoin");
338 b11->timestamp = 1496314658;
339 if (!hex_decode("0001020304050607080900010203040506070809000102030405060708090102",
340 strlen("0001020304050607080900010203040506070809000102030405060708090102"),
341 &b11->payment_hash, sizeof(b11->payment_hash)))

Callers

nothing calls this directly

Calls 15

common_setupFunction · 0.85
hex_decodeFunction · 0.85
abortFunction · 0.85
new_bolt11Function · 0.85
chainparams_for_networkFunction · 0.85
set_feature_bitFunction · 0.85
test_b11Function · 0.85
fallbacksFunction · 0.85
bolt11_decodeFunction · 0.85
list_head_initFunction · 0.85
clear_feature_bitFunction · 0.85

Tested by

no test coverage detected