|
5 | 5 | #include "../features.c"
|
6 | 6 | #include "../node_id.c"
|
7 | 7 | #include "../hash_u5.c"
|
| 8 | +#include "../wire/fromwire.c" |
| 9 | +#include "../wire/towire.c" |
8 | 10 | #include <ccan/err/err.h>
|
9 | 11 | #include <ccan/mem/mem.h>
|
10 | 12 | #include <ccan/str/hex/hex.h>
|
11 | 13 | #include <stdio.h>
|
12 | 14 | #include <wally_core.h>
|
13 | 15 |
|
14 | 16 | /* AUTOGENERATED MOCKS START */
|
15 |
| -/* Generated stub for fromwire_fail */ |
16 |
| -const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) |
17 |
| -{ fprintf(stderr, "fromwire_fail called!\n"); abort(); } |
18 |
| -/* Generated stub for fromwire_node_id */ |
19 |
| -void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED) |
20 |
| -{ fprintf(stderr, "fromwire_node_id called!\n"); abort(); } |
21 |
| -/* Generated stub for fromwire_short_channel_id */ |
22 |
| -void fromwire_short_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, |
23 |
| - struct short_channel_id *short_channel_id UNNEEDED) |
24 |
| -{ fprintf(stderr, "fromwire_short_channel_id called!\n"); abort(); } |
25 |
| -/* Generated stub for fromwire_u16 */ |
26 |
| -u16 fromwire_u16(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) |
27 |
| -{ fprintf(stderr, "fromwire_u16 called!\n"); abort(); } |
28 |
| -/* Generated stub for fromwire_u32 */ |
29 |
| -u32 fromwire_u32(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) |
30 |
| -{ fprintf(stderr, "fromwire_u32 called!\n"); abort(); } |
31 |
| -/* Generated stub for towire_node_id */ |
32 |
| -void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED) |
33 |
| -{ fprintf(stderr, "towire_node_id called!\n"); abort(); } |
34 |
| -/* Generated stub for towire_short_channel_id */ |
35 |
| -void towire_short_channel_id(u8 **pptr UNNEEDED, |
36 |
| - const struct short_channel_id *short_channel_id UNNEEDED) |
37 |
| -{ fprintf(stderr, "towire_short_channel_id called!\n"); abort(); } |
38 |
| -/* Generated stub for towire_u16 */ |
39 |
| -void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) |
40 |
| -{ fprintf(stderr, "towire_u16 called!\n"); abort(); } |
41 |
| -/* Generated stub for towire_u32 */ |
42 |
| -void towire_u32(u8 **pptr UNNEEDED, u32 v UNNEEDED) |
43 |
| -{ fprintf(stderr, "towire_u32 called!\n"); abort(); } |
| 17 | +/* Generated stub for bigsize_get */ |
| 18 | +size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) |
| 19 | +{ fprintf(stderr, "bigsize_get called!\n"); abort(); } |
| 20 | +/* Generated stub for bigsize_put */ |
| 21 | +size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) |
| 22 | +{ fprintf(stderr, "bigsize_put called!\n"); abort(); } |
44 | 23 | /* Generated stub for type_to_string_ */
|
45 | 24 | const char *type_to_string_(const tal_t *ctx UNNEEDED, const char *typename UNNEEDED,
|
46 | 25 | union printable_types u UNNEEDED)
|
@@ -386,6 +365,64 @@ int main(void)
|
386 | 365 | assert(!bolt11_decode(tmpctx, badstr, NULL, &fail));
|
387 | 366 | assert(streq(fail, "9: unknown feature bit 100"));
|
388 | 367 |
|
| 368 | + /* BOLT-1fbccd30bb503203e4a255de67f9adb504563425 #11: |
| 369 | + * |
| 370 | + * > ### Please send 0.00967878534 BTC for a list of items within one week, amount in pico-BTC |
| 371 | + * > lnbc9678785340p1pwmna7lpp5gc3xfm08u9qy06djf8dfflhugl6p7lgza6dsjxq454gxhj9t7a0sd8dgfkx7cmtwd68yetpd5s9xar0wfjn5gpc8qhrsdfq24f5ggrxdaezqsnvda3kkum5wfjkzmfqf3jkgem9wgsyuctwdus9xgrcyqcjcgpzgfskx6eqf9hzqnteypzxz7fzypfhg6trddjhygrcyqezcgpzfysywmm5ypxxjemgw3hxjmn8yptk7untd9hxwg3q2d6xjcmtv4ezq7pqxgsxzmnyyqcjqmt0wfjjq6t5v4khxxqyjw5qcqp2rzjq0gxwkzc8w6323m55m4jyxcjwmy7stt9hwkwe2qxmy8zpsgg7jcuwz87fcqqeuqqqyqqqqlgqqqqn3qq9qn07ytgrxxzad9hc4xt3mawjjt8znfv8xzscs7007v9gh9j569lencxa8xeujzkxs0uamak9aln6ez02uunw6rd2ht2sqe4hz8thcdagpleym0j |
| 372 | + * |
| 373 | + * Breakdown: |
| 374 | + * |
| 375 | + * * `lnbc`: prefix, Lightning on bitcoin mainnet |
| 376 | + * * `9678785340p`: amount (9678785340 pico-bitcoin = 967878534 milli satoshi) |
| 377 | + * * `1`: Bech32 separator |
| 378 | + * * `pwmna7l`: timestamp (1572468703) |
| 379 | + * * `p`: payment hash. |
| 380 | + * * `p5`: `data_length` (`p` = 1, `5` = 20; 1 * 32 + 20 == 52) |
| 381 | + * * `gc3xfm08u9qy06djf8dfflhugl6p7lgza6dsjxq454gxhj9t7a0s`: payment hash 462264ede7e14047e9b249da94fefc47f41f7d02ee9b091815a5506bc8abf75f |
| 382 | + * * `d`: short description |
| 383 | + * * `8d`: `data_length` (`8` = 7, `d` = 13; 7 * 32 + 13 == 237) |
| 384 | + * * `gfkx7cmtwd68yetpd5s9xar0wfjn5gpc8qhrsdfq24f5ggrxdaezqsnvda3kkum5wfjkzmfqf3jkgem9wgsyuctwdus9xgrcyqcjcgpzgfskx6eqf9hzqnteypzxz7fzypfhg6trddjhygrcyqezcgpzfysywmm5ypxxjemgw3hxjmn8yptk7untd9hxwg3q2d6xjcmtv4ezq7pqxgsxzmnyyqcjqmt0wfjjq6t5v4khx`: 'Blockstream Store: 88.85 USD for Blockstream Ledger Nano S x 1, \"Back In My Day\" Sticker x 2, \"I Got Lightning Working\" Sticker x 2 and 1 more items' |
| 385 | + * * `x`: expiry time |
| 386 | + * * `qy`: `data_length` (`q` = 0, `y` = 2; 0 * 32 + 4 == 4) |
| 387 | + * * `jw5q`: 604800 seconds (`j` = 18, `w` = 14, `5` = 20, `q` = 0; 18 * 32^3 + 14 * 32^2 + 20 * 32 + 0 == 604800) |
| 388 | + * * `c`: `min_final_cltv_expiry` |
| 389 | + * * `qp`: `data_length` (`q` = 0, `p` = 1; 0 * 32 + 1 == 1) |
| 390 | + * * `2`: min_final_cltv_expiry = 10 |
| 391 | + * * `r`: tagged field: route information |
| 392 | + * * `zj`: `data_length` (`z` = 2, `j` = 18; 2 * 32 + 18 == 82) |
| 393 | + * * `q0gxwkzc8w6323m55m4jyxcjwmy7stt9hwkwe2qxmy8zpsgg7jcuwz87fcqqeuqqqyqqqqlgqqqqn3qq9q`: |
| 394 | + * * pubkey: 03d06758583bb5154774a6eb221b1276c9e82d65bbaceca806d90e20c108f4b1c7 |
| 395 | + * * short_channel_id: 589390x3312x1 |
| 396 | + * * fee_base_msat = 1000 |
| 397 | + * * fee_proportional_millionths = 2500 |
| 398 | + * * cltv_expiry_delta = 40 |
| 399 | + * * `n07ytgrxxzad9hc4xt3mawjjt8znfv8xzscs7007v9gh9j569lencxa8xeujzkxs0uamak9aln6ez02uunw6rd2ht2sqe4hz8thcdagp`: signature |
| 400 | + * * `leym0j`: Bech32 checksum |
| 401 | + */ |
| 402 | + msatoshi = AMOUNT_MSAT(967878534); |
| 403 | + b11 = new_bolt11(tmpctx, &msatoshi); |
| 404 | + b11->chain = chainparams_for_network("bitcoin"); |
| 405 | + b11->timestamp = 1572468703; |
| 406 | + b11->expiry = 604800; |
| 407 | + b11->min_final_cltv_expiry = 10; |
| 408 | + if (!hex_decode("462264ede7e14047e9b249da94fefc47f41f7d02ee9b091815a5506bc8abf75f", |
| 409 | + strlen("462264ede7e14047e9b249da94fefc47f41f7d02ee9b091815a5506bc8abf75f"), |
| 410 | + &b11->payment_hash, sizeof(b11->payment_hash))) |
| 411 | + abort(); |
| 412 | + b11->receiver_id = node; |
| 413 | + b11->description = "Blockstream Store: 88.85 USD for Blockstream Ledger Nano S x 1, \"Back In My Day\" Sticker x 2, \"I Got Lightning Working\" Sticker x 2 and 1 more items"; |
| 414 | + b11->routes = tal_arr(tmpctx, struct route_info *, 1); |
| 415 | + b11->routes[0] = tal(b11->routes, struct route_info); |
| 416 | + if (!node_id_from_hexstr("03d06758583bb5154774a6eb221b1276c9e82d65bbaceca806d90e20c108f4b1c7", strlen("03d06758583bb5154774a6eb221b1276c9e82d65bbaceca806d90e20c108f4b1c7"), &b11->routes[0]->pubkey)) |
| 417 | + abort(); |
| 418 | + if (!short_channel_id_from_str("589390x3312x1", strlen("589390x3312x1"), |
| 419 | + &b11->routes[0]->short_channel_id)) |
| 420 | + abort(); |
| 421 | + b11->routes[0]->fee_base_msat = 1000; |
| 422 | + b11->routes[0]->fee_proportional_millionths = 2500; |
| 423 | + b11->routes[0]->cltv_expiry_delta = 40; |
| 424 | + test_b11("lnbc9678785340p1pwmna7lpp5gc3xfm08u9qy06djf8dfflhugl6p7lgza6dsjxq454gxhj9t7a0sd8dgfkx7cmtwd68yetpd5s9xar0wfjn5gpc8qhrsdfq24f5ggrxdaezqsnvda3kkum5wfjkzmfqf3jkgem9wgsyuctwdus9xgrcyqcjcgpzgfskx6eqf9hzqnteypzxz7fzypfhg6trddjhygrcyqezcgpzfysywmm5ypxxjemgw3hxjmn8yptk7untd9hxwg3q2d6xjcmtv4ezq7pqxgsxzmnyyqcjqmt0wfjjq6t5v4khxxqyjw5qcqp2rzjq0gxwkzc8w6323m55m4jyxcjwmy7stt9hwkwe2qxmy8zpsgg7jcuwz87fcqqeuqqqyqqqqlgqqqqn3qq9qn07ytgrxxzad9hc4xt3mawjjt8znfv8xzscs7007v9gh9j569lencxa8xeujzkxs0uamak9aln6ez02uunw6rd2ht2sqe4hz8thcdagpleym0j", b11, NULL); |
| 425 | + |
389 | 426 | /* FIXME: Test the others! */
|
390 | 427 | wally_cleanup(0);
|
391 | 428 | tal_free(tmpctx);
|
|
0 commit comments