|
|
@ -100,6 +100,12 @@ static void test_b11(const char *b11str, |
|
|
|
else |
|
|
|
assert(streq(b11->description, expect_b11->description)); |
|
|
|
|
|
|
|
if (!b11->payment_secret) |
|
|
|
assert(!expect_b11->payment_secret); |
|
|
|
else |
|
|
|
assert(memeq(b11->payment_secret, sizeof(*b11->payment_secret), |
|
|
|
expect_b11->payment_secret, |
|
|
|
sizeof(*expect_b11->payment_secret))); |
|
|
|
assert(memeq(b11->features, tal_bytelen(b11->features), |
|
|
|
expect_b11->features, tal_bytelen(expect_b11->features))); |
|
|
|
assert(b11->expiry == expect_b11->expiry); |
|
|
@ -312,10 +318,10 @@ int main(void) |
|
|
|
|
|
|
|
test_b11("lntb30m1pw2f2yspp5s59w4a0kjecw3zyexm7zur8l8n4scw674w8sftjhwec33km882gsdpa2pshjmt9de6zqun9w96k2um5ypmkjargypkh2mr5d9cxzun5ypeh2ursdae8gxqruyqvzddp68gup69uhnzwfj9cejuvf3xshrwde68qcrswf0d46kcarfwpshyaplw3skw0tdw4k8g6tsv9e8g4a3hx0v945csrmpm7yxyaamgt2xu7mu4xyt3vp7045n4k4czxf9kj0vw0m8dr5t3pjxuek04rtgyy8uzss5eet5gcyekd6m7u0mzv5sp7mdsag", b11, NULL); |
|
|
|
|
|
|
|
/* BOLT-a76d61dc9893eec75b2e9c4a361354c356c46894 #11:
|
|
|
|
/* BOLT-d8d45ed403e54cffdb049d2e44d1100e41df013c #11:
|
|
|
|
* |
|
|
|
* > ### Please send $30 for coffee beans to the same peer, which supports features 1 and 9 |
|
|
|
* > lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdees9qzsze992adudgku8p05pstl6zh7av6rx2f297pv89gu5q93a0hf3g7lynl3xq56t23dpvah6u7y9qey9lccrdml3gaqwc6nxsl5ktzm464sq73t7cl |
|
|
|
* > ### Please send $30 for coffee beans to the same peer, which supports features 15 and 99, using secret 0x1111111111111111111111111111111111111111111111111111111111111111 |
|
|
|
* > lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q5sqqqqqqqqqqqqqqqpqqq4u9s93jtgysm3mrwll70zr697y3mf902hvxwej0v7c62rsltw83ng0pu8w3j230sluc5gxkdmm9dvpy9y6ggtjd2w544mzdrcs42t7sqdkcy8h |
|
|
|
* |
|
|
|
* Breakdown: |
|
|
|
* |
|
|
@ -327,11 +333,14 @@ int main(void) |
|
|
|
* * `d`: short description |
|
|
|
* * `q5`: `data_length` (`q` = 0, `5` = 20; 0 * 32 + 20 == 20) |
|
|
|
* * `vdhkven9v5sxyetpdees`: 'coffee beans' |
|
|
|
* * `s`: payment secret |
|
|
|
* * `p5`: `data_length` (`p` = 1, `5` = 20; 1 * 32 + 20 == 52) |
|
|
|
* * `zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs`: 0x1111111111111111111111111111111111111111111111111111111111111111 |
|
|
|
* * `9`: features |
|
|
|
* * `qz`: `data_length` (`q` = 0, `z` = 2; 0 * 32 + 2 == 2) |
|
|
|
* * `sz`: b1000000010 |
|
|
|
* * `e992adudgku8p05pstl6zh7av6rx2f297pv89gu5q93a0hf3g7lynl3xq56t23dpvah6u7y9qey9lccrdml3gaqwc6nxsl5ktzm464sq`: signature |
|
|
|
* * `73t7cl`: Bech32 checksum |
|
|
|
* * `q5`: `data_length` (`q` = 0, `5` = 20; 0 * 32 + 20 == 20) 4 |
|
|
|
* * `sqqqqqqqqqqqqqqqpqqq`: b1000....00001000000000000000 |
|
|
|
* * `pqqq4u9s93jtgysm3mrwll70zr697y3mf902hvxwej0v7c62rsltw83ng0pu8w3j230sluc5gxkdmm9dvpy9y6ggtjd2w544mzdrcs42t7sq`: signature |
|
|
|
* * `dkcy8h`: Bech32 checksum |
|
|
|
*/ |
|
|
|
msatoshi = AMOUNT_MSAT(25 * (1000ULL * 100000000) / 1000); |
|
|
|
b11 = new_bolt11(tmpctx, &msatoshi); |
|
|
@ -343,20 +352,22 @@ int main(void) |
|
|
|
abort(); |
|
|
|
b11->receiver_id = node; |
|
|
|
b11->description = "coffee beans"; |
|
|
|
set_feature_bit(&b11->features, 1); |
|
|
|
set_feature_bit(&b11->features, 9); |
|
|
|
b11->payment_secret = tal(b11, struct secret); |
|
|
|
memset(b11->payment_secret, 0x11, sizeof(*b11->payment_secret)); |
|
|
|
set_feature_bit(&b11->features, 15); |
|
|
|
set_feature_bit(&b11->features, 99); |
|
|
|
|
|
|
|
test_b11("lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdees9qzsze992adudgku8p05pstl6zh7av6rx2f297pv89gu5q93a0hf3g7lynl3xq56t23dpvah6u7y9qey9lccrdml3gaqwc6nxsl5ktzm464sq73t7cl", b11, NULL); |
|
|
|
test_b11("lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q5sqqqqqqqqqqqqqqqpqqq4u9s93jtgysm3mrwll70zr697y3mf902hvxwej0v7c62rsltw83ng0pu8w3j230sluc5gxkdmm9dvpy9y6ggtjd2w544mzdrcs42t7sqdkcy8h", b11, NULL); |
|
|
|
|
|
|
|
/* BOLT-a76d61dc9893eec75b2e9c4a361354c356c46894 #11:
|
|
|
|
/* BOLT-d8d45ed403e54cffdb049d2e44d1100e41df013c #11:
|
|
|
|
* |
|
|
|
* > # Same, but using invalid unknown feature 100 |
|
|
|
* > lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdees9q4pqqqqqqqqqqqqqqqqqqszk3ed62snp73037h4py4gry05eltlp0uezm2w9ajnerhmxzhzhsu40g9mgyx5v3ad4aqwkmvyftzk4k9zenz90mhjcy9hcevc7r3lx2sphzfxz7 |
|
|
|
* > # Same, but adding invalid unknown feature 100 |
|
|
|
* > lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqpqqqqu7fz6pjqczdm3jp3qps7xntj2w2mm70e0ckhw3c5xk9p36pvk3sewn7ncaex6uzfq0vtqzy28se6pcwn790vxex7xystzumhg55p6qq9wq7td |
|
|
|
*/ |
|
|
|
/* This one can be encoded, but not decoded */ |
|
|
|
set_feature_bit(&b11->features, 100); |
|
|
|
badstr = bolt11_encode(tmpctx, b11, false, test_sign, NULL); |
|
|
|
assert(streq(badstr, "lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdees9q4pqqqqqqqqqqqqqqqqqqszk3ed62snp73037h4py4gry05eltlp0uezm2w9ajnerhmxzhzhsu40g9mgyx5v3ad4aqwkmvyftzk4k9zenz90mhjcy9hcevc7r3lx2sphzfxz7")); |
|
|
|
assert(streq(badstr, "lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqpqqqqu7fz6pjqczdm3jp3qps7xntj2w2mm70e0ckhw3c5xk9p36pvk3sewn7ncaex6uzfq0vtqzy28se6pcwn790vxex7xystzumhg55p6qq9wq7td")); |
|
|
|
assert(!bolt11_decode(tmpctx, badstr, NULL, &fail)); |
|
|
|
assert(streq(fail, "9: unknown feature bit 100")); |
|
|
|
|
|
|
|