2021-12-04 12:23:56 +01:00
# include "config.h"
2019-02-21 03:38:35 +01:00
# include "../amount.c"
2017-11-24 05:12:55 +01:00
# include "../bech32.c"
2018-04-23 16:20:55 +02:00
# include "../bech32_util.c"
2017-11-24 05:12:55 +01:00
# include "../bolt11.c"
2019-09-05 03:07:16 +02:00
# include "../features.c"
2019-04-08 11:58:32 +02:00
# include "../node_id.c"
2017-11-24 05:12:55 +01:00
# include "../hash_u5.c"
2020-03-31 00:39:00 +02:00
# include "../memleak.c"
2020-02-03 01:29:28 +01:00
# include "../wire/fromwire.c"
# include "../wire/towire.c"
2017-11-24 05:12:55 +01:00
# include <ccan/err/err.h>
2020-12-02 01:10:04 +01:00
# include <common/setup.h>
2017-11-24 05:12:55 +01:00
/* AUTOGENERATED MOCKS START */
/* AUTOGENERATED MOCKS END */
static struct privkey privkey ;
static bool test_sign ( const u5 * u5bytes ,
const u8 * hrpu8 ,
secp256k1_ecdsa_recoverable_signature * rsig ,
2018-02-21 16:06:07 +01:00
void * unused UNUSED )
2017-11-24 05:12:55 +01:00
{
struct hash_u5 hu5 ;
char * hrp ;
struct sha256 sha ;
2018-07-28 08:00:16 +02:00
hrp = tal_dup_arr ( NULL , char , ( char * ) hrpu8 , tal_count ( hrpu8 ) , 1 ) ;
hrp [ tal_count ( hrpu8 ) ] = ' \0 ' ;
2017-11-24 05:12:55 +01:00
hash_u5_init ( & hu5 , hrp ) ;
2018-07-28 08:00:16 +02:00
hash_u5 ( & hu5 , u5bytes , tal_count ( u5bytes ) ) ;
2017-11-24 05:12:55 +01:00
hash_u5_done ( & hu5 , & sha ) ;
tal_free ( hrp ) ;
if ( ! secp256k1_ecdsa_sign_recoverable ( secp256k1_ctx , rsig ,
( const u8 * ) & sha ,
privkey . secret . data ,
NULL , NULL ) )
abort ( ) ;
return true ;
}
static void test_b11 ( const char * b11str ,
const struct bolt11 * expect_b11 ,
const char * hashed_desc )
{
struct bolt11 * b11 ;
2023-09-21 07:36:26 +02:00
char * fail , * reproduce ;
2019-05-10 03:17:49 +02:00
struct bolt11_field * b11_extra , * expect_extra ;
2017-11-24 05:12:55 +01:00
2020-09-23 03:07:19 +02:00
b11 = bolt11_decode ( tmpctx , b11str , NULL , hashed_desc ,
expect_b11 - > chain , & fail ) ;
2017-11-24 05:12:55 +01:00
if ( ! b11 )
errx ( 1 , " %s:%u:%s " , __FILE__ , __LINE__ , fail ) ;
assert ( b11 - > chain = = expect_b11 - > chain ) ;
assert ( b11 - > timestamp = = expect_b11 - > timestamp ) ;
2019-02-21 03:38:35 +01:00
if ( ! b11 - > msat )
assert ( ! expect_b11 - > msat ) ;
2017-11-24 05:12:55 +01:00
else
2019-02-21 03:38:35 +01:00
assert ( amount_msat_eq ( * b11 - > msat , * expect_b11 - > msat ) ) ;
2018-07-04 07:30:02 +02:00
assert ( sha256_eq ( & b11 - > payment_hash , & expect_b11 - > payment_hash ) ) ;
2017-11-24 05:12:55 +01:00
if ( ! b11 - > description )
assert ( ! expect_b11 - > description ) ;
else
assert ( streq ( b11 - > description , expect_b11 - > description ) ) ;
2019-11-23 01:19:23 +01:00
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 ) ) ) ;
2019-09-05 03:07:16 +02:00
assert ( memeq ( b11 - > features , tal_bytelen ( b11 - > features ) ,
expect_b11 - > features , tal_bytelen ( expect_b11 - > features ) ) ) ;
2017-11-24 05:12:55 +01:00
assert ( b11 - > expiry = = expect_b11 - > expiry ) ;
assert ( b11 - > min_final_cltv_expiry = = expect_b11 - > min_final_cltv_expiry ) ;
2018-04-05 07:13:51 +02:00
assert ( tal_count ( b11 - > fallbacks ) = = tal_count ( expect_b11 - > fallbacks ) ) ;
for ( size_t i = 0 ; i < tal_count ( b11 - > fallbacks ) ; i + + )
2018-07-28 08:00:16 +02:00
assert ( memeq ( b11 - > fallbacks [ i ] , tal_count ( b11 - > fallbacks [ i ] ) ,
2018-04-05 07:13:51 +02:00
expect_b11 - > fallbacks [ i ] ,
2018-07-28 08:00:16 +02:00
tal_count ( expect_b11 - > fallbacks [ i ] ) ) ) ;
2017-11-24 05:12:55 +01:00
assert ( tal_count ( b11 - > routes ) = = tal_count ( expect_b11 - > routes ) ) ;
2020-02-03 00:39:26 +01:00
for ( size_t i = 0 ; i < tal_count ( b11 - > routes ) ; i + + ) {
assert ( tal_count ( b11 - > routes [ i ] )
= = tal_count ( expect_b11 - > routes [ i ] ) ) ;
for ( size_t j = 0 ; j < tal_count ( b11 - > routes [ i ] ) ; j + + ) {
const struct route_info * r = & b11 - > routes [ i ] [ j ] ,
* er = & expect_b11 - > routes [ i ] [ j ] ;
assert ( node_id_eq ( & er - > pubkey , & r - > pubkey ) ) ;
assert ( er - > cltv_expiry_delta = = r - > cltv_expiry_delta ) ;
assert ( short_channel_id_eq ( & er - > short_channel_id ,
& r - > short_channel_id ) ) ;
assert ( er - > fee_base_msat = = r - > fee_base_msat ) ;
assert ( er - > fee_proportional_millionths
= = r - > fee_proportional_millionths ) ;
}
}
2017-11-24 05:12:55 +01:00
2019-05-10 03:17:49 +02:00
expect_extra = list_top ( & expect_b11 - > extra_fields , struct bolt11_field ,
list ) ;
list_for_each ( & b11 - > extra_fields , b11_extra , list ) {
assert ( expect_extra - > tag = = b11_extra - > tag ) ;
2024-02-14 10:38:33 +01:00
assert ( tal_arr_eq ( expect_extra - > data , b11_extra - > data ) ) ;
2019-05-10 03:17:49 +02:00
expect_extra = list_next ( & expect_b11 - > extra_fields ,
expect_extra , list ) ;
}
assert ( ! expect_extra ) ;
2017-11-24 05:12:55 +01:00
/* Re-encode to check */
reproduce = bolt11_encode ( tmpctx , b11 , false , test_sign , NULL ) ;
for ( size_t i = 0 ; i < strlen ( reproduce ) ; i + + ) {
2018-10-31 03:00:11 +01:00
if ( reproduce [ i ] ! = b11str [ i ]
& & reproduce [ i ] ! = tolower ( b11str [ i ] ) )
2017-11-24 05:12:55 +01:00
abort ( ) ;
}
2018-10-31 03:00:11 +01:00
assert ( strlen ( reproduce ) = = strlen ( b11str ) ) ;
2017-11-24 05:12:55 +01:00
}
2020-12-02 01:10:04 +01:00
int main ( int argc , char * argv [ ] )
2017-11-24 05:12:55 +01:00
{
struct bolt11 * b11 ;
2019-04-08 11:58:32 +02:00
struct node_id node ;
2019-02-21 03:38:35 +01:00
struct amount_msat msatoshi ;
2018-10-31 02:21:01 +01:00
const char * badstr ;
2019-05-10 03:17:49 +02:00
struct bolt11_field * extra ;
2019-09-05 03:07:16 +02:00
char * fail ;
2020-04-02 06:04:47 +02:00
struct feature_set * fset ;
2017-11-24 05:12:55 +01:00
2020-12-02 01:10:04 +01:00
common_setup ( argv [ 0 ] ) ;
2017-11-24 05:12:55 +01:00
/* BOLT #11:
*
* # Examples
*
* NB : all the following examples are signed with ` priv_key ` = ` e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734 ` .
*/
if ( ! hex_decode ( " e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734 " ,
strlen ( " e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734 " ) ,
& privkey , sizeof ( privkey ) ) )
abort ( ) ;
/* BOLT #11:
*
* > # # # Please make a donation of any amount using payment_hash 00010203040506070 80900010203040506070809000102030405060708090102 to me @ 03e7156 ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad
2022-03-31 11:10:50 +02:00
* > lnbc1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq9qrsgq357wnc5r2ueh7ck6q93dj32dlqnls087fxdwk8qakdyafkq3yap9us6v52vjjsrvywa6rt52cm9r9zqt8r2t7mlcwspyetp5h2tztugp9lfyql
2017-11-24 05:12:55 +01:00
*/
2019-04-08 11:58:32 +02:00
if ( ! node_id_from_hexstr ( " 03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad " , strlen ( " 03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad " ) , & node ) )
2017-11-24 05:12:55 +01:00
abort ( ) ;
/* BOLT #11:
*
* Breakdown :
*
2019-01-14 03:26:25 +01:00
* * ` lnbc ` : prefix , Lightning on Bitcoin mainnet
2017-11-24 05:12:55 +01:00
* * ` 1 ` : Bech32 separator
* * ` pvjluez ` : timestamp ( 1496314658 )
2021-09-08 02:07:14 +02:00
* * ` s ` : payment secret
* * ` p5 ` : ` data_length ` ( ` p ` = 1 , ` 5 ` = 20 ; 1 * 32 + 20 = = 52 )
* * ` zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs ` : payment secret 1111111111111111111111111111111111111111111111111111111111111111
2017-11-24 05:12:55 +01:00
* * ` p ` : payment hash
2018-06-17 12:10:53 +02:00
* * ` p5 ` : ` data_length ` ( ` p ` = 1 , ` 5 ` = 20 ; 1 * 32 + 20 = = 52 )
2017-11-24 05:12:55 +01:00
* * ` qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypq ` : payment hash 00010203040506070 80900010203040506070809000102030405060708090102
* * ` d ` : short description
2018-06-17 12:10:53 +02:00
* * ` pl ` : ` data_length ` ( ` p ` = 1 , ` l ` = 31 ; 1 * 32 + 31 = = 63 )
2017-11-24 05:12:55 +01:00
* * ` 2 pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq ` : ' Please consider supporting this project '
2022-03-31 11:10:50 +02:00
* * ` 9 ` : features
* * ` qr ` : ` data_length ` ( ` q ` = 0 , ` r ` = 3 ; 0 * 32 + 3 = = 3 )
* * ` sgq ` : b100000100000000
* * ` 357 wnc5r2ueh7ck6q93dj32dlqnls087fxdwk8qakdyafkq3yap9us6v52vjjsrvywa6rt52cm9r9zqt8r2t7mlcwspyetp5h2tztugp ` : signature
2017-11-24 05:12:55 +01:00
*/
2018-03-15 07:10:20 +01:00
b11 = new_bolt11 ( tmpctx , NULL ) ;
2017-11-24 05:12:55 +01:00
b11 - > chain = chainparams_for_network ( " bitcoin " ) ;
b11 - > timestamp = 1496314658 ;
if ( ! hex_decode ( " 0001020304050607080900010203040506070809000102030405060708090102 " ,
strlen ( " 0001020304050607080900010203040506070809000102030405060708090102 " ) ,
& b11 - > payment_hash , sizeof ( b11 - > payment_hash ) ) )
abort ( ) ;
b11 - > receiver_id = node ;
2021-09-08 02:07:14 +02:00
b11 - > payment_secret = tal ( b11 , struct secret ) ;
memset ( b11 - > payment_secret , 0x11 , sizeof ( * b11 - > payment_secret ) ) ;
2017-11-24 05:12:55 +01:00
b11 - > description = " Please consider supporting this project " ;
2022-03-31 11:10:50 +02:00
set_feature_bit ( & b11 - > features , 8 ) ;
set_feature_bit ( & b11 - > features , 14 ) ;
2017-11-24 05:12:55 +01:00
2023-09-21 07:36:26 +02:00
dev_bolt11_omit_c_value = true ;
2022-03-31 11:10:50 +02:00
test_b11 ( " lnbc1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq9qrsgq357wnc5r2ueh7ck6q93dj32dlqnls087fxdwk8qakdyafkq3yap9us6v52vjjsrvywa6rt52cm9r9zqt8r2t7mlcwspyetp5h2tztugp9lfyql " , b11 , NULL ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_omit_c_value = false ;
2017-11-24 05:12:55 +01:00
/* BOLT #11:
*
2019-01-14 03:26:25 +01:00
* > # # # Please send $ 3 for a cup of coffee to the same peer , within one minute
2022-03-31 11:10:50 +02:00
* > lnbc2500u1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpu9qrsgquk0rl77nj30yxdy8j9vdx85fkpmdla2087ne0xh8nhedh8w27kyke0lp53ut353s06fv3qfegext0eh0ymjpf39tuven09sam30g4vgpfna3rh
2017-11-24 05:12:55 +01:00
*
* Breakdown :
*
2019-01-14 03:26:25 +01:00
* * ` lnbc ` : prefix , Lightning on Bitcoin mainnet
2017-11-24 05:12:55 +01:00
* * ` 2500u ` : amount ( 2500 micro - bitcoin )
* * ` 1 ` : Bech32 separator
* * ` pvjluez ` : timestamp ( 1496314658 )
2021-09-08 02:07:14 +02:00
* * ` s ` : payment secret . . .
2017-11-24 05:12:55 +01:00
* * ` p ` : payment hash . . .
* * ` d ` : short description
2018-06-17 12:10:53 +02:00
* * ` q5 ` : ` data_length ` ( ` q ` = 0 , ` 5 ` = 20 ; 0 * 32 + 20 = = 20 )
2017-11-24 05:12:55 +01:00
* * ` xysxxatsyp3k7enxv4js ` : ' 1 cup coffee '
* * ` x ` : expiry time
2018-06-17 12:10:53 +02:00
* * ` qz ` : ` data_length ` ( ` q ` = 0 , ` z ` = 2 ; 0 * 32 + 2 = = 2 )
2019-01-14 03:26:25 +01:00
* * ` pu ` : 60 seconds ( ` p ` = 1 , ` u ` = 28 ; 1 * 32 + 28 = = 60 )
2022-03-31 11:10:50 +02:00
* * ` 9 ` : features
* * ` qr ` : ` data_length ` ( ` q ` = 0 , ` r ` = 3 ; 0 * 32 + 3 = = 3 )
* * ` sgq ` : b100000100000000
* * ` uk0rl77nj30yxdy8j9vdx85fkpmdla2087ne0xh8nhedh8w27kyke0lp53ut353s06fv3qfegext0eh0ymjpf39tuven09sam30g4vgp ` : signature
* * ` fna3rh ` : Bech32 checksum
2017-11-24 05:12:55 +01:00
*/
2019-02-21 03:38:35 +01:00
msatoshi = AMOUNT_MSAT ( 2500 * ( 1000ULL * 100000000 ) / 1000000 ) ;
2018-03-15 07:10:20 +01:00
b11 = new_bolt11 ( tmpctx , & msatoshi ) ;
2017-11-24 05:12:55 +01:00
b11 - > chain = chainparams_for_network ( " bitcoin " ) ;
b11 - > timestamp = 1496314658 ;
2021-09-08 02:07:14 +02:00
b11 - > payment_secret = tal ( b11 , struct secret ) ;
memset ( b11 - > payment_secret , 0x11 , sizeof ( * b11 - > payment_secret ) ) ;
2017-11-24 05:12:55 +01:00
if ( ! hex_decode ( " 0001020304050607080900010203040506070809000102030405060708090102 " ,
strlen ( " 0001020304050607080900010203040506070809000102030405060708090102 " ) ,
& b11 - > payment_hash , sizeof ( b11 - > payment_hash ) ) )
abort ( ) ;
b11 - > receiver_id = node ;
b11 - > description = " 1 cup coffee " ;
b11 - > expiry = 60 ;
2022-03-31 11:10:50 +02:00
set_feature_bit ( & b11 - > features , 8 ) ;
set_feature_bit ( & b11 - > features , 14 ) ;
2017-11-24 05:12:55 +01:00
2023-09-21 07:36:26 +02:00
dev_bolt11_omit_c_value = true ;
2022-03-31 11:10:50 +02:00
test_b11 ( " lnbc2500u1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpu9qrsgquk0rl77nj30yxdy8j9vdx85fkpmdla2087ne0xh8nhedh8w27kyke0lp53ut353s06fv3qfegext0eh0ymjpf39tuven09sam30g4vgpfna3rh " , b11 , NULL ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_omit_c_value = false ;
2017-11-24 05:12:55 +01:00
/* BOLT #11:
*
* > # # # Now send $ 24 for an entire list of things ( hashed )
2022-03-31 11:10:50 +02:00
* > lnbc20m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqs9qrsgq7ea976txfraylvgzuxs8kgcw23ezlrszfnh8r6qtfpr6cxga50aj6txm9rxrydzd06dfeawfk6swupvz4erwnyutnjq7x39ymw6j38gp7ynn44
2017-11-24 05:12:55 +01:00
*
* Breakdown :
*
2019-01-14 03:26:25 +01:00
* * ` lnbc ` : prefix , Lightning on Bitcoin mainnet
2017-11-24 05:12:55 +01:00
* * ` 20 m ` : amount ( 20 milli - bitcoin )
* * ` 1 ` : Bech32 separator
* * ` pvjluez ` : timestamp ( 1496314658 )
2021-09-08 02:07:14 +02:00
* * ` s ` : payment secret . . .
2017-11-24 05:12:55 +01:00
* * ` p ` : payment hash . . .
* * ` h ` : tagged field : hash of description
2018-06-17 12:10:53 +02:00
* * ` p5 ` : ` data_length ` ( ` p ` = 1 , ` 5 ` = 20 ; 1 * 32 + 20 = = 52 )
2017-11-24 05:12:55 +01:00
* * ` 8 yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqs ` : SHA256 of ' One piece of chocolate cake , one icecream cone , one pickle , one slice of swiss cheese , one slice of salami , one lollypop , one piece of cherry pie , one sausage , one cupcake , and one slice of watermelon '
2022-03-31 11:10:50 +02:00
* * ` 9 ` : features
* * ` qr ` : ` data_length ` ( ` q ` = 0 , ` r ` = 3 ; 0 * 32 + 3 = = 3 )
* * ` sgq ` : b100000100000000
* * ` 7 ea976txfraylvgzuxs8kgcw23ezlrszfnh8r6qtfpr6cxga50aj6txm9rxrydzd06dfeawfk6swupvz4erwnyutnjq7x39ymw6j38gp ` : signature
* * ` 7 ynn44 ` : Bech32 checksum
2017-11-24 05:12:55 +01:00
*/
2019-02-21 03:38:35 +01:00
msatoshi = AMOUNT_MSAT ( 20 * ( 1000ULL * 100000000 ) / 1000 ) ;
2018-03-15 07:10:20 +01:00
b11 = new_bolt11 ( tmpctx , & msatoshi ) ;
2017-11-24 05:12:55 +01:00
b11 - > chain = chainparams_for_network ( " bitcoin " ) ;
b11 - > timestamp = 1496314658 ;
2021-09-08 02:07:14 +02:00
b11 - > payment_secret = tal ( b11 , struct secret ) ;
memset ( b11 - > payment_secret , 0x11 , sizeof ( * b11 - > payment_secret ) ) ;
2017-11-24 05:12:55 +01:00
if ( ! hex_decode ( " 0001020304050607080900010203040506070809000102030405060708090102 " ,
strlen ( " 0001020304050607080900010203040506070809000102030405060708090102 " ) ,
& b11 - > payment_hash , sizeof ( b11 - > payment_hash ) ) )
abort ( ) ;
b11 - > receiver_id = node ;
b11 - > description_hash = tal ( b11 , struct sha256 ) ;
2022-03-31 11:10:50 +02:00
set_feature_bit ( & b11 - > features , 8 ) ;
set_feature_bit ( & b11 - > features , 14 ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_omit_c_value = true ;
2022-03-31 11:10:50 +02:00
test_b11 ( " lnbc20m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqs9qrsgq7ea976txfraylvgzuxs8kgcw23ezlrszfnh8r6qtfpr6cxga50aj6txm9rxrydzd06dfeawfk6swupvz4erwnyutnjq7x39ymw6j38gp7ynn44 " , b11 , " One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon " ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_omit_c_value = false ;
2017-11-24 05:12:55 +01:00
2018-10-31 02:21:01 +01:00
/* Malformed bolt11 strings (no '1'). */
badstr = " lnbc20mpvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqscc6gd6ql3jrc5yzme8v4ntcewwz5cnw92tz0pc8qcuufvq7khhr8wpald05e92xw006sq94mg8v2ndf4sefvf9sygkshp5zfem29trqq2yxxz7 " ;
for ( size_t i = 0 ; i < = strlen ( badstr ) ; i + + ) {
if ( bolt11_decode ( tmpctx , tal_strndup ( tmpctx , badstr , i ) ,
2020-09-23 03:07:19 +02:00
NULL , NULL , NULL , & fail ) )
2018-10-31 02:21:01 +01:00
abort ( ) ;
assert ( strstr ( fail , " Bad bech32 " )
| | strstr ( fail , " Invoices must start with ln " ) ) ;
}
2018-10-31 03:00:11 +01:00
/* ALL UPPERCASE is allowed (useful for QR codes) */
2019-02-21 03:38:35 +01:00
msatoshi = AMOUNT_MSAT ( 2500 * ( 1000ULL * 100000000 ) / 1000000 ) ;
2018-10-31 03:00:11 +01:00
b11 = new_bolt11 ( tmpctx , & msatoshi ) ;
b11 - > chain = chainparams_for_network ( " bitcoin " ) ;
b11 - > timestamp = 1496314658 ;
if ( ! hex_decode ( " 0001020304050607080900010203040506070809000102030405060708090102 " ,
strlen ( " 0001020304050607080900010203040506070809000102030405060708090102 " ) ,
& b11 - > payment_hash , sizeof ( b11 - > payment_hash ) ) )
abort ( ) ;
b11 - > receiver_id = node ;
b11 - > description = " 1 cup coffee " ;
b11 - > expiry = 60 ;
2023-09-21 07:36:26 +02:00
dev_bolt11_omit_c_value = true ;
2018-10-31 03:00:11 +01:00
test_b11 ( " LNBC2500U1PVJLUEZPP5QQQSYQCYQ5RQWZQFQQQSYQCYQ5RQWZQFQQQSYQCYQ5RQWZQFQYPQDQ5XYSXXATSYP3K7ENXV4JSXQZPUAZTRNWNGZN3KDZW5HYDLZF03QDGM2HDQ27CQV3AGM2AWHZ5SE903VRUATFHQ77W3LS4EVS3CH9ZW97J25EMUDUPQ63NYW24CG27H2RSPFJ9SRP " , b11 , NULL ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_omit_c_value = false ;
2019-05-10 03:17:49 +02:00
/* Unknown field handling */
if ( ! node_id_from_hexstr ( " 02330d13587b67a85c0a36ea001c4dba14bcd48dda8988f7303275b040bffb6abd " , strlen ( " 02330d13587b67a85c0a36ea001c4dba14bcd48dda8988f7303275b040bffb6abd " ) , & node ) )
abort ( ) ;
msatoshi = AMOUNT_MSAT ( 3000000000 ) ;
b11 = new_bolt11 ( tmpctx , & msatoshi ) ;
b11 - > chain = chainparams_for_network ( " testnet " ) ;
b11 - > timestamp = 1554294928 ;
if ( ! hex_decode ( " 850aeaf5f69670e8889936fc2e0cff3ceb0c3b5eab8f04ae57767118db673a91 " ,
strlen ( " 850aeaf5f69670e8889936fc2e0cff3ceb0c3b5eab8f04ae57767118db673a91 " ) ,
& b11 - > payment_hash , sizeof ( b11 - > payment_hash ) ) )
abort ( ) ;
2020-08-20 08:51:03 +02:00
b11 - > min_final_cltv_expiry = 18 ;
2019-05-10 03:17:49 +02:00
b11 - > receiver_id = node ;
b11 - > description = " Payment request with multipart support " ;
b11 - > expiry = 28800 ;
extra = tal ( b11 , struct bolt11_field ) ;
extra - > tag = ' v ' ;
extra - > data = tal_arr ( extra , u5 , 77 ) ;
for ( size_t i = 0 ; i < 77 ; i + + )
extra - > data [ i ] = bech32_charset_rev [ ( u8 ) " dp68gup69uhnzwfj9cejuvf3xshrwde68qcrswf0d46kcarfwpshyaplw3skw0tdw4k8g6tsv9e8g " [ i ] ] ;
list_add ( & b11 - > extra_fields , & extra - > list ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_omit_c_value = true ;
2019-05-10 03:17:49 +02:00
test_b11 ( " lntb30m1pw2f2yspp5s59w4a0kjecw3zyexm7zur8l8n4scw674w8sftjhwec33km882gsdpa2pshjmt9de6zqun9w96k2um5ypmkjargypkh2mr5d9cxzun5ypeh2ursdae8gxqruyqvzddp68gup69uhnzwfj9cejuvf3xshrwde68qcrswf0d46kcarfwpshyaplw3skw0tdw4k8g6tsv9e8g4a3hx0v945csrmpm7yxyaamgt2xu7mu4xyt3vp7045n4k4czxf9kj0vw0m8dr5t3pjxuek04rtgyy8uzss5eet5gcyekd6m7u0mzv5sp7mdsag " , b11 , NULL ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_omit_c_value = false ;
2019-05-10 03:17:49 +02:00
2020-01-31 02:40:49 +01:00
/* BOLT #11:
2019-09-05 03:07:16 +02:00
*
2022-03-31 11:10:50 +02:00
* > # # # Please send $ 30 for coffee beans to the same peer , which supports features 8 , 14 and 99 , using secret 0x1111111111111111111111111111111111111111111111111111111111111111
* > lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q5sqqqqqqqqqqqqqqqqsgq2a25dxl5hrntdtn6zvydt7d66hyzsyhqs4wdynavys42xgl6sgx9c4g7me86a27t07mdtfry458rtjr0v92cnmswpsjscgt2vcse3sgpz3uapa
2019-09-05 03:07:16 +02:00
*
* Breakdown :
*
* * ` lnbc ` : prefix , Lightning on Bitcoin mainnet
* * ` 25 m ` : amount ( 25 milli - bitcoin )
* * ` 1 ` : Bech32 separator
* * ` pvjluez ` : timestamp ( 1496314658 )
* * ` p ` : payment hash . . .
* * ` d ` : short description
* * ` q5 ` : ` data_length ` ( ` q ` = 0 , ` 5 ` = 20 ; 0 * 32 + 20 = = 20 )
* * ` vdhkven9v5sxyetpdees ` : ' coffee beans '
2019-11-23 01:19:23 +01:00
* * ` s ` : payment secret
* * ` p5 ` : ` data_length ` ( ` p ` = 1 , ` 5 ` = 20 ; 1 * 32 + 20 = = 52 )
* * ` zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs ` : 0x1111111111111111111111111111111111111111111111111111111111111111
2019-09-05 03:07:16 +02:00
* * ` 9 ` : features
2022-03-31 11:10:50 +02:00
* * ` q5 ` : ` data_length ` ( ` q ` = 0 , ` 5 ` = 20 ; 0 * 32 + 20 = = 20 )
* * ` sqqqqqqqqqqqqqqqqsgq ` : b1000 . . . .00000100000100000000
* * ` 2 a25dxl5hrntdtn6zvydt7d66hyzsyhqs4wdynavys42xgl6sgx9c4g7me86a27t07mdtfry458rtjr0v92cnmswpsjscgt2vcse3sgp ` : signature
* * ` z3uapa ` : Bech32 checksum
2019-09-05 03:07:16 +02:00
*/
msatoshi = AMOUNT_MSAT ( 25 * ( 1000ULL * 100000000 ) / 1000 ) ;
b11 = new_bolt11 ( tmpctx , & msatoshi ) ;
b11 - > chain = chainparams_for_network ( " bitcoin " ) ;
b11 - > timestamp = 1496314658 ;
if ( ! hex_decode ( " 0001020304050607080900010203040506070809000102030405060708090102 " ,
strlen ( " 0001020304050607080900010203040506070809000102030405060708090102 " ) ,
& b11 - > payment_hash , sizeof ( b11 - > payment_hash ) ) )
abort ( ) ;
b11 - > receiver_id = node ;
b11 - > description = " coffee beans " ;
2019-11-23 01:19:23 +01:00
b11 - > payment_secret = tal ( b11 , struct secret ) ;
memset ( b11 - > payment_secret , 0x11 , sizeof ( * b11 - > payment_secret ) ) ;
2022-03-31 11:10:50 +02:00
set_feature_bit ( & b11 - > features , 8 ) ;
set_feature_bit ( & b11 - > features , 14 ) ;
2019-11-23 01:19:23 +01:00
set_feature_bit ( & b11 - > features , 99 ) ;
2019-09-05 03:07:16 +02:00
2023-09-21 07:36:26 +02:00
dev_bolt11_old_order = true ;
dev_bolt11_omit_c_value = true ;
2022-03-31 11:10:50 +02:00
test_b11 ( " lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q5sqqqqqqqqqqqqqqqqsgq2a25dxl5hrntdtn6zvydt7d66hyzsyhqs4wdynavys42xgl6sgx9c4g7me86a27t07mdtfry458rtjr0v92cnmswpsjscgt2vcse3sgpz3uapa " , b11 , NULL ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_old_order = false ;
dev_bolt11_omit_c_value = false ;
2019-09-05 03:07:16 +02:00
2020-08-20 08:49:27 +02:00
/* BOLT #11
2020-02-03 01:29:42 +01:00
*
* > # # # Same , but including fields which must be ignored .
2022-03-31 11:10:50 +02:00
* > lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q5sqqqqqqqqqqqqqqqqsgq2qrqqqfppnqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqppnqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpp4qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhpnqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhp4qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqspnqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqsp4qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnp5qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnpkqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqz599y53s3ujmcfjp5xrdap68qxymkqphwsexhmhr8wdz5usdzkzrse33chw6dlp3jhuhge9ley7j2ayx36kawe7kmgg8sv5ugdyusdcqzn8z9x
2020-02-03 01:29:42 +01:00
*
* Breakdown :
*
* * ` lnbc ` : prefix , Lightning on Bitcoin mainnet
* * ` 25 m ` : amount ( 25 milli - bitcoin )
* * ` 1 ` : Bech32 separator
* * ` pvjluez ` : timestamp ( 1496314658 )
* * ` p ` : payment hash . . .
* * ` 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
* * ` q5 ` : ` data_length ` ( ` q ` = 0 , ` 5 ` = 20 ; 0 * 32 + 20 = = 20 )
* * ` sqqqqqqqqqqqqqqqpqsq ` : b1000 . . . .00001000001000000000
* * ` 2 ` : unknown field
* * ` qr ` : ` data_length ` ( ` q ` = 0 , ` r ` = 3 ; 0 * 32 + 3 = = 3 )
* * ` qqq ` : zeroes
* * ` f ` : tagged field : fallback address
* * ` pp ` : ` data_length ` ( ` p ` = 1 , ` p ` = 1 ; 1 * 32 + 1 = = 33 )
* * ` nqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq ` : fallback address type 19 ( ignored )
* * ` p ` : payment hash
* * ` pn ` : ` data_length ` ( ` p ` = 1 , ` n ` = 19 ; 1 * 32 + 19 = = 51 ) ( ignored )
* * ` qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq `
* * ` p ` : payment hash
* * ` p4 ` : ` data_length ` ( ` p ` = 1 , ` 4 ` = 21 ; 1 * 32 + 21 = = 53 ) ( ignored )
* * ` qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq `
* * ` h ` : hash of description
* * ` pn ` : ` data_length ` ( ` p ` = 1 , ` n ` = 19 ; 1 * 32 + 19 = = 51 ) ( ignored )
* * ` qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq `
* * ` h ` : hash of description
* * ` p4 ` : ` data_length ` ( ` p ` = 1 , ` 4 ` = 21 ; 1 * 32 + 21 = = 53 ) ( ignored )
* * ` qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq `
* * ` s ` : payment secret
* * ` pn ` : ` data_length ` ( ` p ` = 1 , ` n ` = 19 ; 1 * 32 + 19 = = 51 ) ( ignored )
* * ` qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq `
* * ` s ` : payment secret
* * ` p4 ` : ` data_length ` ( ` p ` = 1 , ` 4 ` = 21 ; 1 * 32 + 21 = = 53 ) ( ignored )
* * ` qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq `
* * ` n ` : node id
* * ` p5 ` : ` data_length ` ( ` p ` = 1 , ` 5 ` = 20 ; 1 * 32 + 20 = = 52 ) ( ignored )
* * ` qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq `
* * ` n ` : node id
* * ` pk ` : ` data_length ` ( ` p ` = 1 , ` k ` = 22 ; 1 * 32 + 22 = = 54 ) ( ignored )
* * ` qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq `
* * ` 2 jxxfsnucm4jf4zwtznpaxphce606fvhvje5x7d4gw7n73994hgs7nteqvenq8a4ml8aqtchv5d9pf7l558889hp4yyrqv6a7zpq9fgp ` : signature
* * ` skqhza ` : Bech32 checksum
*/
extra = tal_arr ( b11 , struct bolt11_field , 10 ) ;
/* Unknown field */
extra [ 0 ] . tag = ' 2 ' ;
extra [ 0 ] . data = tal_arrz ( extra , u8 , 3 ) ;
list_add_tail ( & b11 - > extra_fields , & extra [ 0 ] . list ) ;
/* f with unknown version */
extra [ 1 ] . tag = ' f ' ;
extra [ 1 ] . data = tal_arrz ( extra , u8 , 33 ) ;
list_add_tail ( & b11 - > extra_fields , & extra [ 1 ] . list ) ;
extra [ 1 ] . data [ 0 ] = 19 ;
/* p field too short & long */
extra [ 2 ] . tag = ' p ' ;
extra [ 2 ] . data = tal_arrz ( extra , u8 , 51 ) ;
list_add_tail ( & b11 - > extra_fields , & extra [ 2 ] . list ) ;
extra [ 3 ] . tag = ' p ' ;
extra [ 3 ] . data = tal_arrz ( extra , u8 , 53 ) ;
list_add_tail ( & b11 - > extra_fields , & extra [ 3 ] . list ) ;
/* h field too short & long */
extra [ 4 ] . tag = ' h ' ;
extra [ 4 ] . data = tal_arrz ( extra , u8 , 51 ) ;
list_add_tail ( & b11 - > extra_fields , & extra [ 4 ] . list ) ;
extra [ 5 ] . tag = ' h ' ;
extra [ 5 ] . data = tal_arrz ( extra , u8 , 53 ) ;
list_add_tail ( & b11 - > extra_fields , & extra [ 5 ] . list ) ;
/* s field too short & long */
extra [ 6 ] . tag = ' s ' ;
extra [ 6 ] . data = tal_arrz ( extra , u8 , 51 ) ;
list_add_tail ( & b11 - > extra_fields , & extra [ 6 ] . list ) ;
extra [ 7 ] . tag = ' s ' ;
extra [ 7 ] . data = tal_arrz ( extra , u8 , 53 ) ;
list_add_tail ( & b11 - > extra_fields , & extra [ 7 ] . list ) ;
/* n field too short & long */
extra [ 8 ] . tag = ' n ' ;
extra [ 8 ] . data = tal_arrz ( extra , u8 , 52 ) ;
list_add_tail ( & b11 - > extra_fields , & extra [ 8 ] . list ) ;
extra [ 9 ] . tag = ' n ' ;
extra [ 9 ] . data = tal_arrz ( extra , u8 , 54 ) ;
list_add_tail ( & b11 - > extra_fields , & extra [ 9 ] . list ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_old_order = true ;
dev_bolt11_omit_c_value = true ;
2022-03-31 11:10:50 +02:00
test_b11 ( " lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q5sqqqqqqqqqqqqqqqqsgq2qrqqqfppnqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqppnqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpp4qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhpnqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhp4qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqspnqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqsp4qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnp5qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnpkqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqz599y53s3ujmcfjp5xrdap68qxymkqphwsexhmhr8wdz5usdzkzrse33chw6dlp3jhuhge9ley7j2ayx36kawe7kmgg8sv5ugdyusdcqzn8z9x " , b11 , NULL ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_old_order = false ;
dev_bolt11_omit_c_value = false ;
2020-02-03 01:29:42 +01:00
2020-01-31 02:40:49 +01:00
/* BOLT #11:
2019-09-05 03:07:16 +02:00
*
2019-11-23 01:19:23 +01:00
* > # Same , but adding invalid unknown feature 100
2022-03-31 11:10:50 +02:00
* > lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqqsgqtqyx5vggfcsll4wu246hz02kp85x4katwsk9639we5n5yngc3yhqkm35jnjw4len8vrnqnf5ejh0mzj9n3vz2px97evektfm2l6wqccp3y7372
2019-09-05 03:07:16 +02:00
*/
2020-02-03 01:29:42 +01:00
/* Clear extra fields from previous */
list_head_init ( & b11 - > extra_fields ) ;
2019-09-05 03:07:16 +02:00
/* This one can be encoded, but not decoded */
set_feature_bit ( & b11 - > features , 100 ) ;
2022-03-31 11:10:50 +02:00
2023-09-21 07:36:26 +02:00
/* Needs developer option to munge this into BOLT example order! */
dev_bolt11_old_order = true ;
dev_bolt11_omit_c_value = true ;
badstr = bolt11_encode ( tmpctx , b11 , false , test_sign , NULL ) ;
2022-03-31 11:10:50 +02:00
assert ( streq ( badstr , " lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqqsgqtqyx5vggfcsll4wu246hz02kp85x4katwsk9639we5n5yngc3yhqkm35jnjw4len8vrnqnf5ejh0mzj9n3vz2px97evektfm2l6wqccp3y7372 " ) ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_old_order = false ;
/* Otherwise it does it normally */
badstr = bolt11_encode ( tmpctx , b11 , false , test_sign , NULL ) ;
assert ( streq ( badstr , " lnbc25m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdees9q4psqqqqqqqqqqqqqqqqsgq8w9mkdh2n9pmrsg5natjffcgjpp5caamstsq5pm03v2c7ca5ej3plyrfe3vyzl76v6wex4r8rd6rdvys4a35983n6wrzegcwfl2gl4qqxh98vj " ) ) ;
2023-12-19 21:40:49 +01:00
dev_bolt11_omit_c_value = false ;
2022-03-31 11:10:50 +02:00
2020-04-02 06:04:47 +02:00
/* Empty set of allowed bits, ensures this fails! */
fset = tal ( tmpctx , struct feature_set ) ;
fset - > bits [ BOLT11_FEATURE ] = tal_arr ( fset , u8 , 0 ) ;
2022-03-31 11:10:50 +02:00
set_feature_bit ( & fset - > bits [ BOLT11_FEATURE ] , 8 ) ;
set_feature_bit ( & fset - > bits [ BOLT11_FEATURE ] , 14 ) ;
2020-09-23 03:07:19 +02:00
assert ( ! bolt11_decode ( tmpctx , badstr , fset , NULL , NULL , & fail ) ) ;
2019-09-05 03:07:16 +02:00
assert ( streq ( fail , " 9: unknown feature bit 100 " ) ) ;
2020-04-02 06:04:47 +02:00
/* We'd actually allow this if we either (1) don't check, or (2) accept that feature in
* either compulsory or optional forms . */
2020-09-23 03:07:19 +02:00
assert ( bolt11_decode ( tmpctx , badstr , NULL , NULL , NULL , & fail ) ) ;
2020-04-02 06:04:47 +02:00
set_feature_bit ( & fset - > bits [ BOLT11_FEATURE ] , 100 ) ;
2020-09-23 03:07:19 +02:00
assert ( bolt11_decode ( tmpctx , badstr , fset , NULL , NULL , & fail ) ) ;
2020-04-02 06:04:47 +02:00
clear_feature_bit ( fset - > bits [ BOLT11_FEATURE ] , 100 ) ;
set_feature_bit ( & fset - > bits [ BOLT11_FEATURE ] , 101 ) ;
2020-09-23 03:07:19 +02:00
assert ( bolt11_decode ( tmpctx , badstr , fset , NULL , NULL , & fail ) ) ;
2020-04-02 06:04:47 +02:00
2020-08-20 08:49:27 +02:00
/* FIXME: quoting description in here causes a spurious mismatch! */
/* BOLT #11:
2020-02-03 01:29:28 +01:00
*
* > # # # Please send 0.00967878534 BTC for a list of items within one week , amount in pico - BTC
2022-03-31 11:10:50 +02:00
* > lnbc9678785340p1pwmna7lpp5gc3xfm08u9qy06djf8dfflhugl6p7lgza6dsjxq454gxhj9t7a0sd8dgfkx7cmtwd68yetpd5s9xar0wfjn5gpc8qhrsdfq24f5ggrxdaezqsnvda3kkum5wfjkzmfqf3jkgem9wgsyuctwdus9xgrcyqcjcgpzgfskx6eqf9hzqnteypzxz7fzypfhg6trddjhygrcyqezcgpzfysywmm5ypxxjemgw3hxjmn8yptk7untd9hxwg3q2d6xjcmtv4ezq7pqxgsxzmnyyqcjqmt0wfjjq6t5v4khxsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygsxqyjw5qcqp2rzjq0gxwkzc8w6323m55m4jyxcjwmy7stt9hwkwe2qxmy8zpsgg7jcuwz87fcqqeuqqqyqqqqlgqqqqn3qq9q9qrsgqrvgkpnmps664wgkp43l22qsgdw4ve24aca4nymnxddlnp8vh9v2sdxlu5ywdxefsfvm0fq3sesf08uf6q9a2ke0hc9j6z6wlxg5z5kqpu2v9wz
2020-02-03 01:29:28 +01:00
*
* Breakdown :
*
* * ` lnbc ` : prefix , Lightning on bitcoin mainnet
* * ` 9678785340 p ` : amount ( 9678785340 pico - bitcoin = 967878534 milli satoshi )
* * ` 1 ` : Bech32 separator
* * ` pwmna7l ` : timestamp ( 1572468703 )
2021-09-08 02:07:14 +02:00
* * ` s ` : payment secret . . .
* * ` p ` : payment hash
2020-02-03 01:29:28 +01:00
* * ` p5 ` : ` data_length ` ( ` p ` = 1 , ` 5 ` = 20 ; 1 * 32 + 20 = = 52 )
* * ` gc3xfm08u9qy06djf8dfflhugl6p7lgza6dsjxq454gxhj9t7a0s ` : payment hash 462264 ede7e14047e9b249da94fefc47f41f7d02ee9b091815a5506bc8abf75f
* * ` d ` : short description
* * ` 8 d ` : ` data_length ` ( ` 8 ` = 7 , ` d ` = 13 ; 7 * 32 + 13 = = 237 )
2020-08-20 08:49:27 +02:00
* * ` gfkx7cmtwd68yetpd5s9xar0wfjn5gpc8qhrsdfq24f5ggrxdaezqsnvda3kkum5wfjkzmfqf3jkgem9wgsyuctwdus9xgrcyqcjcgpzgfskx6eqf9hzqnteypzxz7fzypfhg6trddjhygrcyqezcgpzfysywmm5ypxxjemgw3hxjmn8yptk7untd9hxwg3q2d6xjcmtv4ezq7pqxgsxzmnyyqcjqmt0wfjjq6t5v4khx ` : . . .
2020-02-03 01:29:28 +01:00
* * ` x ` : expiry time
* * ` qy ` : ` data_length ` ( ` q ` = 0 , ` y ` = 2 ; 0 * 32 + 4 = = 4 )
* * ` jw5q ` : 604800 seconds ( ` j ` = 18 , ` w ` = 14 , ` 5 ` = 20 , ` q ` = 0 ; 18 * 32 ^ 3 + 14 * 32 ^ 2 + 20 * 32 + 0 = = 604800 )
2023-04-07 08:54:26 +02:00
* * ` c ` : ` min_final_cltv_expiry_delta `
2020-02-03 01:29:28 +01:00
* * ` qp ` : ` data_length ` ( ` q ` = 0 , ` p ` = 1 ; 0 * 32 + 1 = = 1 )
2023-04-07 08:54:26 +02:00
* * ` 2 ` : min_final_cltv_expiry_delta = 10
2020-02-03 01:29:28 +01:00
* * ` r ` : tagged field : route information
* * ` zj ` : ` data_length ` ( ` z ` = 2 , ` j ` = 18 ; 2 * 32 + 18 = = 82 )
* * ` q0gxwkzc8w6323m55m4jyxcjwmy7stt9hwkwe2qxmy8zpsgg7jcuwz87fcqqeuqqqyqqqqlgqqqqn3qq9q ` :
* * pubkey : 03 d06758583bb5154774a6eb221b1276c9e82d65bbaceca806d90e20c108f4b1c7
* * short_channel_id : 589390 x3312x1
* * fee_base_msat = 1000
* * fee_proportional_millionths = 2500
* * cltv_expiry_delta = 40
2022-03-31 11:10:50 +02:00
* * ` 9 ` : features . . .
* * ` rvgkpnmps664wgkp43l22qsgdw4ve24aca4nymnxddlnp8vh9v2sdxlu5ywdxefsfvm0fq3sesf08uf6q9a2ke0hc9j6z6wlxg5z5kqp ` : signature
* * ` u2v9wz ` : Bech32 checksum
2020-02-03 01:29:28 +01:00
*/
msatoshi = AMOUNT_MSAT ( 967878534 ) ;
b11 = new_bolt11 ( tmpctx , & msatoshi ) ;
b11 - > chain = chainparams_for_network ( " bitcoin " ) ;
b11 - > timestamp = 1572468703 ;
b11 - > expiry = 604800 ;
b11 - > min_final_cltv_expiry = 10 ;
if ( ! hex_decode ( " 462264ede7e14047e9b249da94fefc47f41f7d02ee9b091815a5506bc8abf75f " ,
strlen ( " 462264ede7e14047e9b249da94fefc47f41f7d02ee9b091815a5506bc8abf75f " ) ,
& b11 - > payment_hash , sizeof ( b11 - > payment_hash ) ) )
abort ( ) ;
b11 - > receiver_id = node ;
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 " ;
b11 - > routes = tal_arr ( tmpctx , struct route_info * , 1 ) ;
b11 - > routes [ 0 ] = tal ( b11 - > routes , struct route_info ) ;
if ( ! node_id_from_hexstr ( " 03d06758583bb5154774a6eb221b1276c9e82d65bbaceca806d90e20c108f4b1c7 " , strlen ( " 03d06758583bb5154774a6eb221b1276c9e82d65bbaceca806d90e20c108f4b1c7 " ) , & b11 - > routes [ 0 ] - > pubkey ) )
abort ( ) ;
if ( ! short_channel_id_from_str ( " 589390x3312x1 " , strlen ( " 589390x3312x1 " ) ,
& b11 - > routes [ 0 ] - > short_channel_id ) )
abort ( ) ;
b11 - > routes [ 0 ] - > fee_base_msat = 1000 ;
b11 - > routes [ 0 ] - > fee_proportional_millionths = 2500 ;
b11 - > routes [ 0 ] - > cltv_expiry_delta = 40 ;
2022-03-31 11:10:50 +02:00
set_feature_bit ( & b11 - > features , 8 ) ;
set_feature_bit ( & b11 - > features , 14 ) ;
b11 - > payment_secret = tal ( b11 , struct secret ) ;
memset ( b11 - > payment_secret , 0x11 , sizeof ( * b11 - > payment_secret ) ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_old_order = true ;
2022-03-31 11:10:50 +02:00
test_b11 ( " lnbc9678785340p1pwmna7lpp5gc3xfm08u9qy06djf8dfflhugl6p7lgza6dsjxq454gxhj9t7a0sd8dgfkx7cmtwd68yetpd5s9xar0wfjn5gpc8qhrsdfq24f5ggrxdaezqsnvda3kkum5wfjkzmfqf3jkgem9wgsyuctwdus9xgrcyqcjcgpzgfskx6eqf9hzqnteypzxz7fzypfhg6trddjhygrcyqezcgpzfysywmm5ypxxjemgw3hxjmn8yptk7untd9hxwg3q2d6xjcmtv4ezq7pqxgsxzmnyyqcjqmt0wfjjq6t5v4khxsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygsxqyjw5qcqp2rzjq0gxwkzc8w6323m55m4jyxcjwmy7stt9hwkwe2qxmy8zpsgg7jcuwz87fcqqeuqqqyqqqqlgqqqqn3qq9q9qrsgqrvgkpnmps664wgkp43l22qsgdw4ve24aca4nymnxddlnp8vh9v2sdxlu5ywdxefsfvm0fq3sesf08uf6q9a2ke0hc9j6z6wlxg5z5kqpu2v9wz " , b11 , NULL ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_old_order = false ;
2020-02-03 01:29:28 +01:00
2022-03-31 11:10:50 +02:00
/* BOLT #11:
* > # # # Please send 0.01 BTC with payment metadata 0x01fafaf0
* > lnbc10m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp9wpshjmt9de6zqmt9w3skgct5vysxjmnnd9jx2mq8q8a04uqsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q2gqqqqqqsgq7hf8he7ecf7n4ffphs6awl9t6676rrclv9ckg3d3ncn7fct63p6s365duk5wrk202cfy3aj5xnnp5gs3vrdvruverwwq7yzhkf5a3xqpd05wjc
*
* Breakdown :
*
* * ` lnbc ` : prefix , Lightning on Bitcoin mainnet
* * ` 10 m ` : amount ( 10 milli - bitcoin )
* * ` 1 ` : Bech32 separator
* * ` pvjluez ` : timestamp ( 1496314658 )
* * ` p ` : payment hash
* * ` p5 ` : ` data_length ` ( ` p ` = 1 , ` 5 ` = 20 ; 1 * 32 + 20 = = 52 )
* * ` qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypq ` : payment hash 00010203040506070 80900010203040506070809000102030405060708090102
* * ` d ` : short description
* * ` p9 ` : ` data_length ` ( ` p ` = 1 , ` 9 ` = 5 ; 1 * 32 + 5 = = 37 )
* * ` wpshjmt9de6zqmt9w3skgct5vysxjmnnd9jx2 ` : ' payment metadata inside '
* * ` m ` : metadata
* * ` q8 ` : ` data_length ` ( ` q ` = 0 , ` 8 ` = 7 ; 0 * 32 + 7 = = 7 )
* * ` q8a04uq ` : 0x01fafaf0
* * ` s ` : payment secret
* * ` p5 ` : ` data_length ` ( ` p ` = 1 , ` 5 ` = 20 ; 1 * 32 + 20 = = 52 )
* * ` zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs ` : 0x1111111111111111111111111111111111111111111111111111111111111111
* * ` 9 ` : features
* * ` q2 ` : ` data_length ` ( ` q ` = 0 , ` 2 ` = 10 ; 0 * 32 + 10 = = 10 )
* * ` gqqqqqqsgq ` : [ b01000000000000000000000000000000000100000100000000 ] = 8 + 14 + 48
* * ` 7 hf8he7ecf7n4ffphs6awl9t6676rrclv9ckg3d3ncn7fct63p6s365duk5wrk202cfy3aj5xnnp5gs3vrdvruverwwq7yzhkf5a3xqp ` : signature
* * ` d05wjc ` : Bech32 checksum
*/
msatoshi = AMOUNT_MSAT ( 1000000000 ) ;
b11 = new_bolt11 ( tmpctx , & msatoshi ) ;
b11 - > chain = chainparams_for_network ( " bitcoin " ) ;
b11 - > timestamp = 1496314658 ;
if ( ! hex_decode ( " 0001020304050607080900010203040506070809000102030405060708090102 " ,
strlen ( " 0001020304050607080900010203040506070809000102030405060708090102 " ) ,
& b11 - > payment_hash , sizeof ( b11 - > payment_hash ) ) )
abort ( ) ;
b11 - > receiver_id = node ;
b11 - > description = " payment metadata inside " ;
b11 - > metadata = tal_hexdata ( b11 , " 01fafaf0 " , strlen ( " 01fafaf0 " ) ) ;
set_feature_bit ( & b11 - > features , 8 ) ;
set_feature_bit ( & b11 - > features , 14 ) ;
set_feature_bit ( & b11 - > features , 48 ) ;
b11 - > payment_secret = tal ( b11 , struct secret ) ;
memset ( b11 - > payment_secret , 0x11 , sizeof ( * b11 - > payment_secret ) ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_old_order = true ;
dev_bolt11_omit_c_value = true ;
2022-03-31 11:10:50 +02:00
test_b11 ( " lnbc10m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp9wpshjmt9de6zqmt9w3skgct5vysxjmnnd9jx2mq8q8a04uqsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q2gqqqqqqsgq7hf8he7ecf7n4ffphs6awl9t6676rrclv9ckg3d3ncn7fct63p6s365duk5wrk202cfy3aj5xnnp5gs3vrdvruverwwq7yzhkf5a3xqpd05wjc " , b11 , NULL ) ;
2023-09-21 07:36:26 +02:00
dev_bolt11_old_order = false ;
dev_bolt11_omit_c_value = false ;
2022-03-31 11:10:50 +02:00
2020-08-20 08:49:27 +02:00
/* BOLT #11:
2020-02-03 01:29:42 +01:00
*
* > # # # Bech32 checksum is invalid .
* > lnbc2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpquwpc4curk03c9wlrswe78q4eyqc7d8d0xqzpuyk0sg5g70me25alkluzd2x62aysf2pyy8edtjeevuv4p2d5p76r4zkmneet7uvyakky2zr4cusd45tftc9c5fh0nnqpnl2jfll544esqchsrnt
*/
2020-09-23 03:07:19 +02:00
assert ( ! bolt11_decode ( tmpctx , " lnbc2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpquwpc4curk03c9wlrswe78q4eyqc7d8d0xqzpuyk0sg5g70me25alkluzd2x62aysf2pyy8edtjeevuv4p2d5p76r4zkmneet7uvyakky2zr4cusd45tftc9c5fh0nnqpnl2jfll544esqchsrnt " , NULL , NULL , NULL , & fail ) ) ;
2020-02-03 01:29:42 +01:00
assert ( streq ( fail , " Bad bech32 string " ) ) ;
2020-08-20 08:49:27 +02:00
/* BOLT #11:
2020-02-03 01:29:42 +01:00
* > # # # Malformed bech32 string ( no 1 )
* > pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpquwpc4curk03c9wlrswe78q4eyqc7d8d0xqzpuyk0sg5g70me25alkluzd2x62aysf2pyy8edtjeevuv4p2d5p76r4zkmneet7uvyakky2zr4cusd45tftc9c5fh0nnqpnl2jfll544esqchsrny
*/
2020-09-23 03:07:19 +02:00
assert ( ! bolt11_decode ( tmpctx , " pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpquwpc4curk03c9wlrswe78q4eyqc7d8d0xqzpuyk0sg5g70me25alkluzd2x62aysf2pyy8edtjeevuv4p2d5p76r4zkmneet7uvyakky2zr4cusd45tftc9c5fh0nnqpnl2jfll544esqchsrny " , NULL , NULL , NULL , & fail ) ) ;
2020-02-03 01:29:42 +01:00
assert ( streq ( fail , " Bad bech32 string " ) ) ;
2020-08-20 08:49:27 +02:00
/* BOLT #11:
2020-02-03 01:29:42 +01:00
* > # # # Malformed bech32 string ( mixed case )
* > LNBC2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpquwpc4curk03c9wlrswe78q4eyqc7d8d0xqzpuyk0sg5g70me25alkluzd2x62aysf2pyy8edtjeevuv4p2d5p76r4zkmneet7uvyakky2zr4cusd45tftc9c5fh0nnqpnl2jfll544esqchsrny
*/
2020-09-23 03:07:19 +02:00
assert ( ! bolt11_decode ( tmpctx , " LNBC2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpquwpc4curk03c9wlrswe78q4eyqc7d8d0xqzpuyk0sg5g70me25alkluzd2x62aysf2pyy8edtjeevuv4p2d5p76r4zkmneet7uvyakky2zr4cusd45tftc9c5fh0nnqpnl2jfll544esqchsrny " , NULL , NULL , NULL , & fail ) ) ;
2020-02-03 01:29:42 +01:00
assert ( streq ( fail , " Bad bech32 string " ) ) ;
2020-08-20 08:49:27 +02:00
/* BOLT #11:
2020-02-03 01:29:42 +01:00
* > # # # Signature is not recoverable .
2022-03-31 11:10:50 +02:00
* > lnbc2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpusp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9qrsgqwgt7mcn5yqw3yx0w94pswkpq6j9uh6xfqqqtsk4tnarugeektd4hg5975x9am52rz4qskukxdmjemg92vvqz8nvmsye63r5ykel43pgz7zq0g2
2020-02-03 01:29:42 +01:00
*/
2022-03-31 11:10:50 +02:00
assert ( ! bolt11_decode ( tmpctx , " lnbc2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpusp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9qrsgqwgt7mcn5yqw3yx0w94pswkpq6j9uh6xfqqqtsk4tnarugeektd4hg5975x9am52rz4qskukxdmjemg92vvqz8nvmsye63r5ykel43pgz7zq0g2 " , NULL , NULL , NULL , & fail ) ) ;
2020-02-03 01:29:42 +01:00
assert ( streq ( fail , " signature recovery failed " ) ) ;
2020-08-20 08:49:27 +02:00
/* BOLT #11:
2020-02-03 01:29:42 +01:00
* > # # # String is too short .
* > lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6na6hlh
*/
2020-09-23 03:07:19 +02:00
assert ( ! bolt11_decode ( tmpctx , " lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6na6hlh " , NULL , NULL , NULL , & fail ) ) ;
2020-02-03 01:29:42 +01:00
2020-08-20 08:49:27 +02:00
/* BOLT #11:
2020-02-03 01:29:42 +01:00
* > # # # Invalid multiplier
2022-03-31 11:10:50 +02:00
* > lnbc2500x1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpusp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9qrsgqrrzc4cvfue4zp3hggxp47ag7xnrlr8vgcmkjxk3j5jqethnumgkpqp23z9jclu3v0a7e0aruz366e9wqdykw6dxhdzcjjhldxq0w6wgqcnu43j
2020-02-03 01:29:42 +01:00
*/
2022-03-31 11:10:50 +02:00
assert ( ! bolt11_decode ( tmpctx , " lnbc2500x1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpusp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9qrsgqrrzc4cvfue4zp3hggxp47ag7xnrlr8vgcmkjxk3j5jqethnumgkpqp23z9jclu3v0a7e0aruz366e9wqdykw6dxhdzcjjhldxq0w6wgqcnu43j " , NULL , NULL , NULL , & fail ) ) ;
2020-02-03 01:29:42 +01:00
assert ( streq ( fail , " Invalid amount postfix 'x' " ) ) ;
2020-08-20 08:49:27 +02:00
/* BOLT #11:
2020-02-03 01:32:19 +01:00
* > # # # Invalid sub - millisatoshi precision .
2022-03-31 11:10:50 +02:00
* > lnbc2500000001p1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpusp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9qrsgq0lzc236j96a95uv0m3umg28gclm5lqxtqqwk32uuk4k6673k6n5kfvx3d2h8s295fad45fdhmusm8sjudfhlf6dcsxmfvkeywmjdkxcp99202x
2020-02-03 01:32:19 +01:00
*/
2022-03-31 11:10:50 +02:00
assert ( ! bolt11_decode ( tmpctx , " lnbc2500000001p1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpusp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9qrsgq0lzc236j96a95uv0m3umg28gclm5lqxtqqwk32uuk4k6673k6n5kfvx3d2h8s295fad45fdhmusm8sjudfhlf6dcsxmfvkeywmjdkxcp99202x " , NULL , NULL , NULL , & fail ) ) ;
2020-02-03 01:32:19 +01:00
assert ( streq ( fail , " Invalid sub-millisatoshi amount '2500000001p' " ) ) ;
2020-11-25 01:09:13 +01:00
/* Invalid UTF-8 tests. */
/* Description: Bad UTF-8: 0xC0" */
assert ( ! bolt11_decode ( tmpctx , " lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5gfskggz423rz6wp6yrqqcqpjkkrsmq07c4ht7qgjdmf2a8savsafcy8lqn4av4gs80gz88ff2y780tdcve7sxp80kd4vk7hajt5mskcsegz2qfll4jywfwhap2q2n6cqyz5tv4 " , NULL , NULL , NULL , & fail ) ) ;
assert ( streq ( fail , " d: invalid utf8 " ) ) ;
/* Description: Bad UTF-8: 0xC020" */
assert ( ! bolt11_decode ( tmpctx , " lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq4gfskggz423rz6wp6yrqzqcqpj30cjfyveywx7wk4gl45ua4g3hcsd9hp0qqtudua0529gfd5cp7kytnttu6dw0yp24v9aefvxamsdvrks9rsqr53ukrexf0vqp8fffusql6q3x4 " , NULL , NULL , NULL , & fail ) ) ;
assert ( streq ( fail , " d: invalid utf8 " ) ) ;
/* Description: Bad UTF-8: 0xE0" */
assert ( ! bolt11_decode ( tmpctx , " lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5gfskggz423rz6wp6yrsqcqpjw6tys4p5m7nxw8ykl6pfqvms4pcnjky9san7rvxvyg9vf9symke49rqfrqdcrtn33qnxpt738crh3arm2dqwqkk00324me6dzcqfrdcpj2echr " , NULL , NULL , NULL , & fail ) ) ;
assert ( streq ( fail , " d: invalid utf8 " ) ) ;
/* Description: Bad UTF-8: 0xE0A0" */
assert ( ! bolt11_decode ( tmpctx , " lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq4gfskggz423rz6wp6yrs2qcqpjmhm55ful0ms5m77rvv2mkld2s9cx2d9syyva5gwc5y7xdtsjwxl8f9nwdftdc64fqwgczxmn00zftry9wj9gsw5tqm9m4nwr75sw9dsq85re9l " , NULL , NULL , NULL , & fail ) ) ;
assert ( streq ( fail , " d: invalid utf8 " ) ) ;
/* Description: Bad UTF-8: 0xE0A020" */
assert ( ! bolt11_decode ( tmpctx , " lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqhgfskggz423rz6wp6yrs2qgqcqpjwm32zdhpftqqp03lsmj27uf5y5pj9e9e8wc2n6nywe5ckwm95wq5z5k2drytjrn4wdwym73qr877u7uajvs88t78xnu2tltt9nsftlqpetnz7k " , NULL , NULL , NULL , & fail ) ) ;
assert ( streq ( fail , " d: invalid utf8 " ) ) ;
/* Description: Bad UTF-8: 0xF0" */
assert ( ! bolt11_decode ( tmpctx , " lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5gfskggz423rz6wp6yrcqcqpjg8ca44f2u2vw4df6zvata2p23v9dyzfjyyremz2f9t0xuzrzznrqcqm4pkmh36vj96qg0v93y0jvrp0u2607lgmc6gdes5lvpr42x9qptekthk " , NULL , NULL , NULL , & fail ) ) ;
assert ( streq ( fail , " d: invalid utf8 " ) ) ;
/* Description: Bad UTF-8: 0xF0A0" */
assert ( ! bolt11_decode ( tmpctx , " lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq4gfskggz423rz6wp6yrc2qcqpj5pj85e6uazujup7pv8n7kwg36lll3uhfguxlwydzznll4nm8ntsy72shgrq042d7md02whd3yzx72t7sf83cah5lfk3xf84ucvt2f8gqc7u33r " , NULL , NULL , NULL , & fail ) ) ;
assert ( streq ( fail , " d: invalid utf8 " ) ) ;
/* Description: Bad UTF-8: 0xF0A020" */
assert ( ! bolt11_decode ( tmpctx , " lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqhgfskggz423rz6wp6yrc2pgqcqpjt284ywasepdes2akvekh7anra3txezksmdmxav84a5nhzdkx84jrmwydasl6ynydse66pnl9mh0wd6t9fk5j8vftuf0hwt2pt6rrqccp4qamj4 " , NULL , NULL , NULL , & fail ) ) ;
assert ( streq ( fail , " d: invalid utf8 " ) ) ;
/* Description: Bad UTF-8: 0xF0A0A0" */
assert ( ! bolt11_decode ( tmpctx , " lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqhgfskggz423rz6wp6yrc2pgqcqpjt284ywasepdes2akvekh7anra3txezksmdmxav84a5nhzdkx84jrmwydasl6ynydse66pnl9mh0wd6t9fk5j8vftuf0hwt2pt6rrqccp4qamj4 " , NULL , NULL , NULL , & fail ) ) ;
assert ( streq ( fail , " d: invalid utf8 " ) ) ;
/* Description: Bad UTF-8: 0xF0A0A020" */
assert ( ! bolt11_decode ( tmpctx , " lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqcgfskggz423rz6wp6yrc2pgpqcqpjmyveg8ccprmlssyae9l33an2m0qz3qcfcavt7wdzrdqyx5q7hqmp7ne08uvwlwaaqwt4lxgmjh5gce3hv0m8tzwkzfshpdv9d5p9pcsp5v86r0 " , NULL , NULL , NULL , & fail ) ) ;
assert ( streq ( fail , " d: invalid utf8 " ) ) ;
2017-11-24 05:12:55 +01:00
/* FIXME: Test the others! */
2020-12-02 01:10:04 +01:00
common_shutdown ( ) ;
2017-11-24 05:12:55 +01:00
}