// You may not use this file except in accordance with one or both of these
// licenses.
-use bitcoin::secp256k1::{KeyPair, Parity, PublicKey, Secp256k1, SecretKey, self};
+use bitcoin::secp256k1::{Keypair, Parity, PublicKey, Secp256k1, SecretKey, self};
use crate::utils::test_logger;
-use core::convert::{Infallible, TryFrom};
+use core::convert::TryFrom;
use lightning::blinded_path::BlindedPath;
+use lightning::blinded_path::message::ForwardNode;
use lightning::sign::EntropySource;
use lightning::ln::PaymentHash;
use lightning::ln::features::BlindedHopFeatures;
-use lightning::offers::invoice::{BlindedPayInfo, UnsignedInvoice};
+use lightning::offers::invoice::{BlindedPayInfo, UnsignedBolt12Invoice};
use lightning::offers::invoice_request::InvoiceRequest;
-use lightning::offers::parse::SemanticError;
+use lightning::offers::parse::Bolt12SemanticError;
use lightning::util::ser::Writeable;
#[inline]
assert_eq!(data, bytes);
let secp_ctx = Secp256k1::new();
- let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
+ let keys = Keypair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
let mut buffer = Vec::new();
if let Ok(unsigned_invoice) = build_response(&invoice_request, &secp_ctx) {
let even_pubkey = x_only_pubkey.public_key(Parity::Even);
if signing_pubkey == odd_pubkey || signing_pubkey == even_pubkey {
unsigned_invoice
- .sign::<_, Infallible>(
- |digest| Ok(secp_ctx.sign_schnorr_no_aux_rand(digest, &keys))
+ .sign(|message: &UnsignedBolt12Invoice|
+ Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
)
.unwrap()
.write(&mut buffer)
.unwrap();
} else {
unsigned_invoice
- .sign::<_, Infallible>(
- |digest| Ok(secp_ctx.sign_schnorr_no_aux_rand(digest, &keys))
+ .sign(|message: &UnsignedBolt12Invoice|
+ Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
)
.unwrap_err();
}
SecretKey::from_slice(&[byte; 32]).unwrap()
}
-fn build_response<'a, T: secp256k1::Signing + secp256k1::Verification>(
- invoice_request: &'a InvoiceRequest, secp_ctx: &Secp256k1<T>
-) -> Result<UnsignedInvoice<'a>, SemanticError> {
+fn build_response<T: secp256k1::Signing + secp256k1::Verification>(
+ invoice_request: &InvoiceRequest, secp_ctx: &Secp256k1<T>
+) -> Result<UnsignedBolt12Invoice, Bolt12SemanticError> {
let entropy_source = Randomness {};
+ let intermediate_nodes = [
+ [
+ ForwardNode { node_id: pubkey(43), short_channel_id: None },
+ ForwardNode { node_id: pubkey(44), short_channel_id: None },
+ ],
+ [
+ ForwardNode { node_id: pubkey(45), short_channel_id: None },
+ ForwardNode { node_id: pubkey(46), short_channel_id: None },
+ ],
+ ];
let paths = vec![
- BlindedPath::new_for_message(&[pubkey(43), pubkey(44), pubkey(42)], &entropy_source, secp_ctx).unwrap(),
- BlindedPath::new_for_message(&[pubkey(45), pubkey(46), pubkey(42)], &entropy_source, secp_ctx).unwrap(),
+ BlindedPath::new_for_message(&intermediate_nodes[0], pubkey(42), &entropy_source, secp_ctx).unwrap(),
+ BlindedPath::new_for_message(&intermediate_nodes[1], pubkey(42), &entropy_source, secp_ctx).unwrap(),
];
let payinfo = vec![