Merge pull request #2954 from TheBlueMatt/2024-03-test-ci-beta-fail
[rust-lightning] / lightning-invoice / tests / ser_de.rs
index 272d9062a6e4c9a062e622c55f2ed568bbae5409..e5e311fe669277b955ccf23e372478fd8386560b 100644 (file)
@@ -1,16 +1,13 @@
 extern crate bech32;
-extern crate bitcoin_hashes;
 extern crate lightning;
 extern crate lightning_invoice;
 extern crate secp256k1;
 extern crate hex;
 
-use bitcoin_hashes::hex::FromHex;
-use bitcoin_hashes::{sha256, Hash};
-use bech32::u5;
-use lightning::ln::PaymentSecret;
-use lightning::routing::gossip::RoutingFees;
-use lightning::routing::router::{RouteHint, RouteHintHop};
+use bitcoin::address::WitnessVersion;
+use bitcoin::{PubkeyHash, ScriptHash};
+use bitcoin::hashes::hex::FromHex;
+use bitcoin::hashes::{sha256, Hash};
 use lightning_invoice::*;
 use secp256k1::PublicKey;
 use secp256k1::ecdsa::{RecoverableSignature, RecoveryId};
@@ -18,14 +15,14 @@ use std::collections::HashSet;
 use std::time::Duration;
 use std::str::FromStr;
 
-fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
+fn get_test_tuples() -> Vec<(String, SignedRawBolt11Invoice, bool, bool)> {
        vec![
                (
                        "lnbc1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq9qrsgq357wnc5r2ueh7ck6q93dj32dlqnls087fxdwk8qakdyafkq3yap9us6v52vjjsrvywa6rt52cm9r9zqt8r2t7mlcwspyetp5h2tztugp9lfyql".to_owned(),
                        InvoiceBuilder::new(Currency::Bitcoin)
                                .duration_since_epoch(Duration::from_secs(1496314658))
                                .payment_secret(PaymentSecret([0x11; 32]))
-                               .payment_hash(sha256::Hash::from_hex(
+                               .payment_hash(sha256::Hash::from_str(
                                                "0001020304050607080900010203040506070809000102030405060708090102"
                                ).unwrap())
                                .description("Please consider supporting this project".to_owned())
@@ -33,7 +30,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .unwrap()
                                .sign(|_| {
                                        RecoverableSignature::from_compact(
-                                               &hex::decode("8d3ce9e28357337f62da0162d9454df827f83cfe499aeb1c1db349d4d81127425e434ca29929406c23bba1ae8ac6ca32880b38d4bf6ff874024cac34ba9625f1").unwrap(),
+                                               &<Vec<u8>>::from_hex("8d3ce9e28357337f62da0162d9454df827f83cfe499aeb1c1db349d4d81127425e434ca29929406c23bba1ae8ac6ca32880b38d4bf6ff874024cac34ba9625f1").unwrap(),
                                                RecoveryId::from_i32(1).unwrap()
                                        )
                                }).unwrap(),
@@ -46,7 +43,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .amount_milli_satoshis(250_000_000)
                                .duration_since_epoch(Duration::from_secs(1496314658))
                                .payment_secret(PaymentSecret([0x11; 32]))
-                               .payment_hash(sha256::Hash::from_hex(
+                               .payment_hash(sha256::Hash::from_str(
                                        "0001020304050607080900010203040506070809000102030405060708090102"
                                ).unwrap())
                                .description("1 cup coffee".to_owned())
@@ -55,7 +52,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .unwrap()
                                .sign(|_| {
                                        RecoverableSignature::from_compact(
-                                               &hex::decode("e59e3ffbd3945e4334879158d31e89b076dff54f3fa7979ae79df2db9dcaf5896cbfe1a478b8d2307e92c88139464cb7e6ef26e414c4abe33337961ddc5e8ab1").unwrap(),
+                                               &<Vec<u8>>::from_hex("e59e3ffbd3945e4334879158d31e89b076dff54f3fa7979ae79df2db9dcaf5896cbfe1a478b8d2307e92c88139464cb7e6ef26e414c4abe33337961ddc5e8ab1").unwrap(),
                                                RecoveryId::from_i32(1).unwrap()
                                        )
                                }).unwrap(),
@@ -68,7 +65,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .amount_milli_satoshis(250_000_000)
                                .duration_since_epoch(Duration::from_secs(1496314658))
                                .payment_secret(PaymentSecret([0x11; 32]))
-                               .payment_hash(sha256::Hash::from_hex(
+                               .payment_hash(sha256::Hash::from_str(
                                        "0001020304050607080900010203040506070809000102030405060708090102"
                                ).unwrap())
                                .description("ナンセンス 1杯".to_owned())
@@ -77,7 +74,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .unwrap()
                                .sign(|_| {
                                        RecoverableSignature::from_compact(
-                                               &hex::decode("bae41ef385e0fc972977c7ea42b12cbd76577d2412919da8a8a22f9577b6507710c0e96dd78c821dea16453037f717f44aa7e3d196ebb18fbb97307dcb7336c3").unwrap(),
+                                               &<Vec<u8>>::from_hex("bae41ef385e0fc972977c7ea42b12cbd76577d2412919da8a8a22f9577b6507710c0e96dd78c821dea16453037f717f44aa7e3d196ebb18fbb97307dcb7336c3").unwrap(),
                                                RecoveryId::from_i32(1).unwrap()
                                        )
                                }).unwrap(),
@@ -91,14 +88,14 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .duration_since_epoch(Duration::from_secs(1496314658))
                                .description_hash(sha256::Hash::hash(b"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"))
                                .payment_secret(PaymentSecret([0x11; 32]))
-                               .payment_hash(sha256::Hash::from_hex(
+                               .payment_hash(sha256::Hash::from_str(
                                        "0001020304050607080900010203040506070809000102030405060708090102"
                                ).unwrap())
                                .build_raw()
                                .unwrap()
                                .sign(|_| {
                                        RecoverableSignature::from_compact(
-                                               &hex::decode("f67a5f696648fa4fb102e1a07b230e54722f8e024cee71e80b4847ac191da3fb2d2cdb28cc32344d7e9a9cf5c9b6a0ee0582ae46e9938b9c81e344a4dbb5289d").unwrap(),
+                                               &<Vec<u8>>::from_hex("f67a5f696648fa4fb102e1a07b230e54722f8e024cee71e80b4847ac191da3fb2d2cdb28cc32344d7e9a9cf5c9b6a0ee0582ae46e9938b9c81e344a4dbb5289d").unwrap(),
                                                RecoveryId::from_i32(1).unwrap()
                                        )
                                }).unwrap(),
@@ -112,15 +109,15 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .duration_since_epoch(Duration::from_secs(1496314658))
                                .description_hash(sha256::Hash::hash(b"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"))
                                .payment_secret(PaymentSecret([0x11; 32]))
-                               .payment_hash(sha256::Hash::from_hex(
+                               .payment_hash(sha256::Hash::from_str(
                                        "0001020304050607080900010203040506070809000102030405060708090102"
                                ).unwrap())
-                               .fallback(Fallback::PubKeyHash([49, 114, 181, 101, 79, 102, 131, 200, 251, 20, 105, 89, 211, 71, 206, 48, 60, 174, 76, 167]))
+                               .fallback(Fallback::PubKeyHash(PubkeyHash::from_slice(&[49, 114, 181, 101, 79, 102, 131, 200, 251, 20, 105, 89, 211, 71, 206, 48, 60, 174, 76, 167]).unwrap()))
                                .build_raw()
                                .unwrap()
                                .sign(|_| {
                                        RecoverableSignature::from_compact(
-                                               &hex::decode("6ca95a74dc32e69ced6175b15a5cc56a92bf19f5dace0f134b7d94d464b9f5cf6090a18d48b243f289394d17bdf89466d8e6b37df5981f696bc3dd5986e1bee1").unwrap(),
+                                               &<Vec<u8>>::from_hex("6ca95a74dc32e69ced6175b15a5cc56a92bf19f5dace0f134b7d94d464b9f5cf6090a18d48b243f289394d17bdf89466d8e6b37df5981f696bc3dd5986e1bee1").unwrap(),
                                                RecoveryId::from_i32(1).unwrap()
                                        )
                                }).unwrap(),
@@ -134,12 +131,12 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .duration_since_epoch(Duration::from_secs(1496314658))
                                .description_hash(sha256::Hash::hash(b"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"))
                                .payment_secret(PaymentSecret([0x11; 32]))
-                               .payment_hash(sha256::Hash::from_hex(
+                               .payment_hash(sha256::Hash::from_str(
                                        "0001020304050607080900010203040506070809000102030405060708090102"
                                ).unwrap())
-                               .fallback(Fallback::PubKeyHash([4, 182, 31, 125, 193, 234, 13, 201, 148, 36, 70, 76, 196, 6, 77, 197, 100, 217, 30, 137]))
+                               .fallback(Fallback::PubKeyHash(PubkeyHash::from_slice(&[4, 182, 31, 125, 193, 234, 13, 201, 148, 36, 70, 76, 196, 6, 77, 197, 100, 217, 30, 137]).unwrap()))
                                .private_route(RouteHint(vec![RouteHintHop {
-                                       src_node_id: PublicKey::from_slice(&hex::decode(
+                                       src_node_id: PublicKey::from_slice(&<Vec<u8>>::from_hex(
                                                        "029e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255"
                                                ).unwrap()).unwrap(),
                                        short_channel_id: (66051 << 40) | (263430 << 16) | 1800,
@@ -147,7 +144,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                        cltv_expiry_delta: 3,
                                        htlc_maximum_msat: None, htlc_minimum_msat: None,
                                }, RouteHintHop {
-                                       src_node_id: PublicKey::from_slice(&hex::decode(
+                                       src_node_id: PublicKey::from_slice(&<Vec<u8>>::from_hex(
                                                        "039e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255"
                                                ).unwrap()).unwrap(),
                                        short_channel_id: (197637 << 40) | (395016 << 16) | 2314,
@@ -159,7 +156,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .unwrap()
                                .sign(|_| {
                                        RecoverableSignature::from_compact(
-                                               &hex::decode("6a6586db4e8f6d40e3a5bb92e4df5110c627e9ce493af237e20a046b4e86ea200178c59564ecf892f33a9558bf041b6ad2cb8292d7a6c351fbb7f2ae2d16b54e").unwrap(),
+                                               &<Vec<u8>>::from_hex("6a6586db4e8f6d40e3a5bb92e4df5110c627e9ce493af237e20a046b4e86ea200178c59564ecf892f33a9558bf041b6ad2cb8292d7a6c351fbb7f2ae2d16b54e").unwrap(),
                                                RecoveryId::from_i32(0).unwrap()
                                        )
                                }).unwrap(),
@@ -173,15 +170,15 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .duration_since_epoch(Duration::from_secs(1496314658))
                                .description_hash(sha256::Hash::hash(b"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"))
                                .payment_secret(PaymentSecret([0x11; 32]))
-                               .payment_hash(sha256::Hash::from_hex(
+                               .payment_hash(sha256::Hash::from_str(
                                        "0001020304050607080900010203040506070809000102030405060708090102"
                                ).unwrap())
-                               .fallback(Fallback::ScriptHash([143, 85, 86, 59, 154, 25, 243, 33, 194, 17, 233, 185, 243, 140, 223, 104, 110, 160, 120, 69]))
+                               .fallback(Fallback::ScriptHash(ScriptHash::from_slice(&[143, 85, 86, 59, 154, 25, 243, 33, 194, 17, 233, 185, 243, 140, 223, 104, 110, 160, 120, 69]).unwrap()))
                                .build_raw()
                                .unwrap()
                                .sign(|_| {
                                        RecoverableSignature::from_compact(
-                                               &hex::decode("16810439d1a9bfd5a65acc61340dc92448bb2d456a80b58ce012b73cb5202438020500c9ab7ef5573a4d174c811f669885ae27f895bb3a3be52c243589f87518").unwrap(),
+                                               &<Vec<u8>>::from_hex("16810439d1a9bfd5a65acc61340dc92448bb2d456a80b58ce012b73cb5202438020500c9ab7ef5573a4d174c811f669885ae27f895bb3a3be52c243589f87518").unwrap(),
                                                RecoveryId::from_i32(1).unwrap()
                                        )
                                }).unwrap(),
@@ -195,17 +192,17 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .duration_since_epoch(Duration::from_secs(1496314658))
                                .description_hash(sha256::Hash::hash(b"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"))
                                .payment_secret(PaymentSecret([0x11; 32]))
-                               .payment_hash(sha256::Hash::from_hex(
+                               .payment_hash(sha256::Hash::from_str(
                                        "0001020304050607080900010203040506070809000102030405060708090102"
                                ).unwrap())
-                               .fallback(Fallback::SegWitProgram { version: u5::try_from_u8(0).unwrap(),
+                               .fallback(Fallback::SegWitProgram { version: WitnessVersion::V0,
                                        program: vec![117, 30, 118, 232, 25, 145, 150, 212, 84, 148, 28, 69, 209, 179, 163, 35, 241, 67, 59, 214]
                                })
                                .build_raw()
                                .unwrap()
                                .sign(|_| {
                                        RecoverableSignature::from_compact(
-                                               &hex::decode("5a8bd7b97c1cc9055ee60cf2356621f8752248e037a953886a1782b44a58f5ff2d94e6bc89b7b514541a3603bb33722b6c08aa1a3639d34becc549a99fea6eae").unwrap(),
+                                               &<Vec<u8>>::from_hex("5a8bd7b97c1cc9055ee60cf2356621f8752248e037a953886a1782b44a58f5ff2d94e6bc89b7b514541a3603bb33722b6c08aa1a3639d34becc549a99fea6eae").unwrap(),
                                                RecoveryId::from_i32(0).unwrap()
                                        )
                                }).unwrap(),
@@ -219,17 +216,17 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .duration_since_epoch(Duration::from_secs(1496314658))
                                .description_hash(sha256::Hash::hash(b"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"))
                                .payment_secret(PaymentSecret([0x11; 32]))
-                               .payment_hash(sha256::Hash::from_hex(
+                               .payment_hash(sha256::Hash::from_str(
                                        "0001020304050607080900010203040506070809000102030405060708090102"
                                ).unwrap())
-                               .fallback(Fallback::SegWitProgram { version: u5::try_from_u8(0).unwrap(),
+                               .fallback(Fallback::SegWitProgram { version: WitnessVersion::V0,
                                        program: vec![24, 99, 20, 60, 20, 197, 22, 104, 4, 189, 25, 32, 51, 86, 218, 19, 108, 152, 86, 120, 205, 77, 39, 161, 184, 198, 50, 150, 4, 144, 50, 98]
                                })
                                .build_raw()
                                .unwrap()
                                .sign(|_| {
                                        RecoverableSignature::from_compact(
-                                               &hex::decode("2b3ec248f80301a421817369194f012cdd8af8df1c279981420f9e901e20fa3309d791e11355e609b59ce4a220852a0cd55ab862b1785a83b206c90fa74d01c8").unwrap(),
+                                               &<Vec<u8>>::from_hex("2b3ec248f80301a421817369194f012cdd8af8df1c279981420f9e901e20fa3309d791e11355e609b59ce4a220852a0cd55ab862b1785a83b206c90fa74d01c8").unwrap(),
                                                RecoveryId::from_i32(1).unwrap()
                                        )
                                }).unwrap(),
@@ -242,14 +239,14 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .amount_milli_satoshis(967878534)
                                .duration_since_epoch(Duration::from_secs(1572468703))
                                .payment_secret(PaymentSecret([0x11; 32]))
-                               .payment_hash(sha256::Hash::from_hex(
+                               .payment_hash(sha256::Hash::from_str(
                                        "462264ede7e14047e9b249da94fefc47f41f7d02ee9b091815a5506bc8abf75f"
                                ).unwrap())
                                .expiry_time(Duration::from_secs(604800))
                                .min_final_cltv_expiry_delta(10)
                                .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".to_owned())
                                .private_route(RouteHint(vec![RouteHintHop {
-                                       src_node_id: PublicKey::from_slice(&hex::decode(
+                                       src_node_id: PublicKey::from_slice(&<Vec<u8>>::from_hex(
                                                        "03d06758583bb5154774a6eb221b1276c9e82d65bbaceca806d90e20c108f4b1c7"
                                                ).unwrap()).unwrap(),
                                        short_channel_id: (589390 << 40) | (3312 << 16) | 1,
@@ -261,7 +258,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .unwrap()
                                .sign(|_| {
                                        RecoverableSignature::from_compact(
-                                               &hex::decode("1b1160cf6186b55722c1ac7ea502086baaccaabdc76b326e666b7f309d972b15069bfca11cd365304b36f48230cc12f3f13a017aab65f7c165a169df32282a58").unwrap(),
+                                               &<Vec<u8>>::from_hex("1b1160cf6186b55722c1ac7ea502086baaccaabdc76b326e666b7f309d972b15069bfca11cd365304b36f48230cc12f3f13a017aab65f7c165a169df32282a58").unwrap(),
                                                RecoveryId::from_i32(1).unwrap()
                                        )
                                }).unwrap(),
@@ -274,7 +271,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .amount_milli_satoshis(2_500_000_000)
                                .duration_since_epoch(Duration::from_secs(1496314658))
                                .payment_secret(PaymentSecret([0x11; 32]))
-                               .payment_hash(sha256::Hash::from_hex(
+                               .payment_hash(sha256::Hash::from_str(
                                        "0001020304050607080900010203040506070809000102030405060708090102"
                                ).unwrap())
                                .description("coffee beans".to_owned())
@@ -282,7 +279,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .unwrap()
                                .sign(|_| {
                                        RecoverableSignature::from_compact(
-                                               &hex::decode("5755469bf4b8e6b6ae7a1308d5f9bad5c82812e0855cd24fac242aa323fa820c5c551ede4faeabcb7fb6d5a464ad0e35c86f615589ee0e0c250c216a662198c1").unwrap(),
+                                               &<Vec<u8>>::from_hex("5755469bf4b8e6b6ae7a1308d5f9bad5c82812e0855cd24fac242aa323fa820c5c551ede4faeabcb7fb6d5a464ad0e35c86f615589ee0e0c250c216a662198c1").unwrap(),
                                                RecoveryId::from_i32(1).unwrap()
                                        )
                                }).unwrap(),
@@ -295,7 +292,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .amount_milli_satoshis(2_500_000_000)
                                .duration_since_epoch(Duration::from_secs(1496314658))
                                .payment_secret(PaymentSecret([0x11; 32]))
-                               .payment_hash(sha256::Hash::from_hex(
+                               .payment_hash(sha256::Hash::from_str(
                                        "0001020304050607080900010203040506070809000102030405060708090102"
                                ).unwrap())
                                .description("coffee beans".to_owned())
@@ -303,7 +300,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .unwrap()
                                .sign(|_| {
                                        RecoverableSignature::from_compact(
-                                               &hex::decode("5755469bf4b8e6b6ae7a1308d5f9bad5c82812e0855cd24fac242aa323fa820c5c551ede4faeabcb7fb6d5a464ad0e35c86f615589ee0e0c250c216a662198c1").unwrap(),
+                                               &<Vec<u8>>::from_hex("5755469bf4b8e6b6ae7a1308d5f9bad5c82812e0855cd24fac242aa323fa820c5c551ede4faeabcb7fb6d5a464ad0e35c86f615589ee0e0c250c216a662198c1").unwrap(),
                                                RecoveryId::from_i32(1).unwrap()
                                        )
                                }).unwrap(),
@@ -316,7 +313,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .amount_milli_satoshis(2_500_000_000)
                                .duration_since_epoch(Duration::from_secs(1496314658))
                                .payment_secret(PaymentSecret([0x11; 32]))
-                               .payment_hash(sha256::Hash::from_hex(
+                               .payment_hash(sha256::Hash::from_str(
                                        "0001020304050607080900010203040506070809000102030405060708090102"
                                ).unwrap())
                                .description("coffee beans".to_owned())
@@ -324,13 +321,63 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
                                .unwrap()
                                .sign(|_| {
                                        RecoverableSignature::from_compact(
-                                               &hex::decode("150a5252308f25bc2641a186de87470189bb003774326beee33b9a2a720d1584386631c5dda6fc3195f97464bfc93d2574868eadd767d6da1078329c4349c837").unwrap(),
+                                               &<Vec<u8>>::from_hex("150a5252308f25bc2641a186de87470189bb003774326beee33b9a2a720d1584386631c5dda6fc3195f97464bfc93d2574868eadd767d6da1078329c4349c837").unwrap(),
                                                RecoveryId::from_i32(0).unwrap()
                                        )
                                }).unwrap(),
                        true, // Different features than set in InvoiceBuilder
                        true, // Some unknown fields
                ),
+               ( // Older version of the payment metadata test with a payment_pubkey set
+                       "lnbc10m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp9wpshjmt9de6zqmt9w3skgct5vysxjmnnd9jx2mq8q8a04uqnp4q0n326hr8v9zprg8gsvezcch06gfaqqhde2aj730yg0durunfhv66sp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q2gqqqqqqsgqy9gw6ymamd20jumvdgpfphkhp8fzhhdhycw36egcmla5vlrtrmhs9t7psfy3hkkdqzm9eq64fjg558znccds5nhsfmxveha5xe0dykgpspdha0".to_owned(),
+                       InvoiceBuilder::new(Currency::Bitcoin)
+                               .amount_milli_satoshis(1_000_000_000)
+                               .duration_since_epoch(Duration::from_secs(1496314658))
+                               .payment_hash(sha256::Hash::from_str(
+                                       "0001020304050607080900010203040506070809000102030405060708090102"
+                               ).unwrap())
+                               .description("payment metadata inside".to_owned())
+                               .payment_metadata(<Vec<u8>>::from_hex("01fafaf0").unwrap())
+                               .require_payment_metadata()
+                               .payee_pub_key(PublicKey::from_slice(&<Vec<u8>>::from_hex(
+                                               "03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad"
+                                       ).unwrap()).unwrap())
+                               .payment_secret(PaymentSecret([0x11; 32]))
+                               .build_raw()
+                               .unwrap()
+                               .sign(|_| {
+                                       RecoverableSignature::from_compact(
+                                               &<Vec<u8>>::from_hex("2150ed137ddb54f9736c6a0290ded709d22bddb7261d1d6518dffb467c6b1eef02afc182491bdacd00b65c83554c914a1c53c61b0a4ef04eccccdfb4365ed259").unwrap(),
+                                               RecoveryId::from_i32(1).unwrap()
+                                       )
+                               }).unwrap(),
+                       false, // Different features than set in InvoiceBuilder
+                       true, // Some unknown fields
+               ),
+               (
+                       "lnbc10m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp9wpshjmt9de6zqmt9w3skgct5vysxjmnnd9jx2mq8q8a04uqsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q2gqqqqqqsgq7hf8he7ecf7n4ffphs6awl9t6676rrclv9ckg3d3ncn7fct63p6s365duk5wrk202cfy3aj5xnnp5gs3vrdvruverwwq7yzhkf5a3xqpd05wjc".to_owned(),
+                       InvoiceBuilder::new(Currency::Bitcoin)
+                               .amount_milli_satoshis(1_000_000_000)
+                               .duration_since_epoch(Duration::from_secs(1496314658))
+                               .payment_hash(sha256::Hash::from_str(
+                                       "0001020304050607080900010203040506070809000102030405060708090102"
+                               ).unwrap())
+                               .description("payment metadata inside".to_owned())
+                               .payment_metadata(<Vec<u8>>::from_hex("01fafaf0").unwrap())
+                               .require_payment_metadata()
+                               .payment_secret(PaymentSecret([0x11; 32]))
+                               .build_raw()
+                               .unwrap()
+                               .sign(|_| {
+                                       RecoverableSignature::from_compact(
+                                               &<Vec<u8>>::from_hex("f5d27be7d9c27d3aa521bc35d77cabd6bda18f1f61716445b19e27e4e17a887508ea8de5a8e1d94f561248f65434e61a221160dac1f1991b9c0f1057b269d898").unwrap(),
+                                               RecoveryId::from_i32(1).unwrap()
+                                       )
+                               }).unwrap(),
+                       false, // Different features than set in InvoiceBuilder
+                       true, // Some unknown fields
+               ),
+
        ]
 }
 
@@ -338,7 +385,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, bool, bool)> {
 fn invoice_deserialize() {
        for (serialized, deserialized, ignore_feature_diff, ignore_unknown_fields) in get_test_tuples() {
                eprintln!("Testing invoice {}...", serialized);
-               let parsed = serialized.parse::<SignedRawInvoice>().unwrap();
+               let parsed = serialized.parse::<SignedRawBolt11Invoice>().unwrap();
 
                let (parsed_invoice, _, parsed_sig) = parsed.into_parts();
                let (deserialized_invoice, _, deserialized_sig) = deserialized.into_parts();
@@ -361,35 +408,35 @@ fn invoice_deserialize() {
                }
                assert_eq!(deserialized_hunks, parsed_hunks);
 
-               Invoice::from_signed(serialized.parse::<SignedRawInvoice>().unwrap()).unwrap();
+               Bolt11Invoice::from_signed(serialized.parse::<SignedRawBolt11Invoice>().unwrap()).unwrap();
        }
 }
 
 #[test]
 fn test_bolt_invalid_invoices() {
        // Tests the BOLT 11 invalid invoice test vectors
-       assert_eq!(Invoice::from_str(
+       assert_eq!(Bolt11Invoice::from_str(
                "lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqqsgqtqyx5vggfcsll4wu246hz02kp85x4katwsk9639we5n5yngc3yhqkm35jnjw4len8vrnqnf5ejh0mzj9n3vz2px97evektfm2l6wqccp3y7372"
-               ), Err(ParseOrSemanticError::SemanticError(SemanticError::InvalidFeatures)));
-       assert_eq!(Invoice::from_str(
+               ), Err(ParseOrSemanticError::SemanticError(Bolt11SemanticError::InvalidFeatures)));
+       assert_eq!(Bolt11Invoice::from_str(
                "lnbc2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpquwpc4curk03c9wlrswe78q4eyqc7d8d0xqzpuyk0sg5g70me25alkluzd2x62aysf2pyy8edtjeevuv4p2d5p76r4zkmneet7uvyakky2zr4cusd45tftc9c5fh0nnqpnl2jfll544esqchsrnt"
-               ), Err(ParseOrSemanticError::ParseError(ParseError::Bech32Error(bech32::Error::InvalidChecksum))));
-       assert_eq!(Invoice::from_str(
+               ), Err(ParseOrSemanticError::ParseError(Bolt11ParseError::Bech32Error(bech32::Error::InvalidChecksum))));
+       assert_eq!(Bolt11Invoice::from_str(
                "pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpquwpc4curk03c9wlrswe78q4eyqc7d8d0xqzpuyk0sg5g70me25alkluzd2x62aysf2pyy8edtjeevuv4p2d5p76r4zkmneet7uvyakky2zr4cusd45tftc9c5fh0nnqpnl2jfll544esqchsrny"
-               ), Err(ParseOrSemanticError::ParseError(ParseError::Bech32Error(bech32::Error::MissingSeparator))));
-       assert_eq!(Invoice::from_str(
+               ), Err(ParseOrSemanticError::ParseError(Bolt11ParseError::Bech32Error(bech32::Error::MissingSeparator))));
+       assert_eq!(Bolt11Invoice::from_str(
                "LNBC2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpquwpc4curk03c9wlrswe78q4eyqc7d8d0xqzpuyk0sg5g70me25alkluzd2x62aysf2pyy8edtjeevuv4p2d5p76r4zkmneet7uvyakky2zr4cusd45tftc9c5fh0nnqpnl2jfll544esqchsrny"
-               ), Err(ParseOrSemanticError::ParseError(ParseError::Bech32Error(bech32::Error::MixedCase))));
-       assert_eq!(Invoice::from_str(
+               ), Err(ParseOrSemanticError::ParseError(Bolt11ParseError::Bech32Error(bech32::Error::MixedCase))));
+       assert_eq!(Bolt11Invoice::from_str(
                "lnbc2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpusp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9qrsgqwgt7mcn5yqw3yx0w94pswkpq6j9uh6xfqqqtsk4tnarugeektd4hg5975x9am52rz4qskukxdmjemg92vvqz8nvmsye63r5ykel43pgz7zq0g2"
-               ), Err(ParseOrSemanticError::SemanticError(SemanticError::InvalidSignature)));
-       assert_eq!(Invoice::from_str(
+               ), Err(ParseOrSemanticError::SemanticError(Bolt11SemanticError::InvalidSignature)));
+       assert_eq!(Bolt11Invoice::from_str(
                "lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6na6hlh"
-               ), Err(ParseOrSemanticError::ParseError(ParseError::TooShortDataPart)));
-       assert_eq!(Invoice::from_str(
+               ), Err(ParseOrSemanticError::ParseError(Bolt11ParseError::TooShortDataPart)));
+       assert_eq!(Bolt11Invoice::from_str(
                "lnbc2500x1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpusp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9qrsgqrrzc4cvfue4zp3hggxp47ag7xnrlr8vgcmkjxk3j5jqethnumgkpqp23z9jclu3v0a7e0aruz366e9wqdykw6dxhdzcjjhldxq0w6wgqcnu43j"
-               ), Err(ParseOrSemanticError::ParseError(ParseError::UnknownSiPrefix)));
-       assert_eq!(Invoice::from_str(
+               ), Err(ParseOrSemanticError::ParseError(Bolt11ParseError::UnknownSiPrefix)));
+       assert_eq!(Bolt11Invoice::from_str(
                "lnbc2500000001p1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpusp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9qrsgq0lzc236j96a95uv0m3umg28gclm5lqxtqqwk32uuk4k6673k6n5kfvx3d2h8s295fad45fdhmusm8sjudfhlf6dcsxmfvkeywmjdkxcp99202x"
-               ), Err(ParseOrSemanticError::SemanticError(SemanticError::ImpreciseAmount)));
+               ), Err(ParseOrSemanticError::SemanticError(Bolt11SemanticError::ImpreciseAmount)));
 }