Qualify the BOLT 12 unsigned invoice type

A previous commit qualified the BOLT 12 invoice type, so any related
types should be similarly qualified, if public.
This commit is contained in:
Jeffrey Czyz 2023-07-13 13:47:09 -05:00
parent f8c9b092fd
commit d94227cc13
No known key found for this signature in database
GPG key ID: 3A4E08275D5E96D2
3 changed files with 10 additions and 10 deletions

View file

@ -14,7 +14,7 @@ use lightning::blinded_path::BlindedPath;
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::util::ser::Writeable;
@ -71,7 +71,7 @@ fn privkey(byte: u8) -> SecretKey {
fn build_response<'a, T: secp256k1::Signing + secp256k1::Verification>(
invoice_request: &'a InvoiceRequest, secp_ctx: &Secp256k1<T>
) -> Result<UnsignedInvoice<'a>, SemanticError> {
) -> Result<UnsignedBolt12Invoice<'a>, SemanticError> {
let entropy_source = Randomness {};
let paths = vec![
BlindedPath::new_for_message(&[pubkey(43), pubkey(44), pubkey(42)], &entropy_source, secp_ctx).unwrap(),

View file

@ -14,7 +14,7 @@ use lightning::blinded_path::BlindedPath;
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::parse::SemanticError;
use lightning::offers::refund::Refund;
use lightning::util::ser::Writeable;
@ -60,7 +60,7 @@ fn privkey(byte: u8) -> SecretKey {
fn build_response<'a, T: secp256k1::Signing + secp256k1::Verification>(
refund: &'a Refund, signing_pubkey: PublicKey, secp_ctx: &Secp256k1<T>
) -> Result<UnsignedInvoice<'a>, SemanticError> {
) -> Result<UnsignedBolt12Invoice<'a>, SemanticError> {
let entropy_source = Randomness {};
let paths = vec![
BlindedPath::new_for_message(&[pubkey(43), pubkey(44), pubkey(42)], &entropy_source, secp_ctx).unwrap(),

View file

@ -330,8 +330,8 @@ impl<'a, S: SigningPubkeyStrategy> InvoiceBuilder<'a, S> {
impl<'a> InvoiceBuilder<'a, ExplicitSigningPubkey> {
/// Builds an unsigned [`Bolt12Invoice`] after checking for valid semantics. It can be signed by
/// [`UnsignedInvoice::sign`].
pub fn build(self) -> Result<UnsignedInvoice<'a>, SemanticError> {
/// [`UnsignedBolt12Invoice::sign`].
pub fn build(self) -> Result<UnsignedBolt12Invoice<'a>, SemanticError> {
#[cfg(feature = "std")] {
if self.invoice.is_offer_or_refund_expired() {
return Err(SemanticError::AlreadyExpired);
@ -339,7 +339,7 @@ impl<'a> InvoiceBuilder<'a, ExplicitSigningPubkey> {
}
let InvoiceBuilder { invreq_bytes, invoice, .. } = self;
Ok(UnsignedInvoice { invreq_bytes, invoice })
Ok(UnsignedBolt12Invoice { invreq_bytes, invoice })
}
}
@ -355,7 +355,7 @@ impl<'a> InvoiceBuilder<'a, DerivedSigningPubkey> {
}
let InvoiceBuilder { invreq_bytes, invoice, keys, .. } = self;
let unsigned_invoice = UnsignedInvoice { invreq_bytes, invoice };
let unsigned_invoice = UnsignedBolt12Invoice { invreq_bytes, invoice };
let keys = keys.unwrap();
let invoice = unsigned_invoice
@ -366,12 +366,12 @@ impl<'a> InvoiceBuilder<'a, DerivedSigningPubkey> {
}
/// A semantically valid [`Bolt12Invoice`] that hasn't been signed.
pub struct UnsignedInvoice<'a> {
pub struct UnsignedBolt12Invoice<'a> {
invreq_bytes: &'a Vec<u8>,
invoice: InvoiceContents,
}
impl<'a> UnsignedInvoice<'a> {
impl<'a> UnsignedBolt12Invoice<'a> {
/// The public key corresponding to the key needed to sign the invoice.
pub fn signing_pubkey(&self) -> PublicKey {
self.invoice.fields().signing_pubkey