+ #[test]
+ fn parses_invoice_with_node_id_from_blinded_path() {
+ let paths = vec![
+ BlindedPath {
+ introduction_node: IntroductionNode::NodeId(pubkey(40)),
+ blinding_point: pubkey(41),
+ blinded_hops: vec![
+ BlindedHop { blinded_node_id: pubkey(43), encrypted_payload: vec![0; 43] },
+ BlindedHop { blinded_node_id: pubkey(44), encrypted_payload: vec![0; 44] },
+ ],
+ },
+ BlindedPath {
+ introduction_node: IntroductionNode::NodeId(pubkey(40)),
+ blinding_point: pubkey(41),
+ blinded_hops: vec![
+ BlindedHop { blinded_node_id: pubkey(45), encrypted_payload: vec![0; 45] },
+ BlindedHop { blinded_node_id: pubkey(46), encrypted_payload: vec![0; 46] },
+ ],
+ },
+ ];
+
+ let blinded_node_id_sign = |message: &UnsignedBolt12Invoice| {
+ let secp_ctx = Secp256k1::new();
+ let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[46; 32]).unwrap());
+ Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
+ };
+
+ let invoice = OfferBuilder::new("foo".into(), recipient_pubkey())
+ .clear_signing_pubkey()
+ .amount_msats(1000)
+ .path(paths[0].clone())
+ .path(paths[1].clone())
+ .build().unwrap()
+ .request_invoice(vec![1; 32], payer_pubkey()).unwrap()
+ .build().unwrap()
+ .sign(payer_sign).unwrap()
+ .respond_with_no_std_using_signing_pubkey(
+ payment_paths(), payment_hash(), now(), pubkey(46)
+ ).unwrap()
+ .build().unwrap()
+ .sign(blinded_node_id_sign).unwrap();
+
+ let mut buffer = Vec::new();
+ invoice.write(&mut buffer).unwrap();
+
+ if let Err(e) = Bolt12Invoice::try_from(buffer) {
+ panic!("error parsing invoice: {:?}", e);
+ }
+
+ let invoice = OfferBuilder::new("foo".into(), recipient_pubkey())
+ .clear_signing_pubkey()
+ .amount_msats(1000)
+ .path(paths[0].clone())
+ .path(paths[1].clone())
+ .build().unwrap()
+ .request_invoice(vec![1; 32], payer_pubkey()).unwrap()
+ .build().unwrap()
+ .sign(payer_sign).unwrap()
+ .respond_with_no_std_using_signing_pubkey(
+ payment_paths(), payment_hash(), now(), recipient_pubkey()
+ ).unwrap()
+ .build().unwrap()
+ .sign(recipient_sign).unwrap();
+
+ let mut buffer = Vec::new();
+ invoice.write(&mut buffer).unwrap();
+
+ match Bolt12Invoice::try_from(buffer) {
+ Ok(_) => panic!("expected error"),
+ Err(e) => {
+ assert_eq!(e, Bolt12ParseError::InvalidSemantics(Bolt12SemanticError::InvalidSigningPubkey));
+ },
+ }
+ }
+