]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Qualify the BOLT 12 unsigned invoice type
authorJeffrey Czyz <jkczyz@gmail.com>
Thu, 13 Jul 2023 18:47:09 +0000 (13:47 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Fri, 14 Jul 2023 20:04:43 +0000 (15:04 -0500)
A previous commit qualified the BOLT 12 invoice type, so any related
types should be similarly qualified, if public.

fuzz/src/invoice_request_deser.rs
fuzz/src/refund_deser.rs
lightning/src/offers/invoice.rs

index f8fe34f2b8b5d647140af18a53558f7ba07b6fb2..dbf62fac7dfe72700880303169719265e1831480 100644 (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(),
index 618b129f9a1e5517fa5dcddb09f739308feee436..b1c729d9e5c0a99d05032d9ed99469b83294d523 100644 (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(),
index 9a09e58aca12fe5864976e7283c4a19ba0ec0b16..8e0c28b60ef5e35e08440562cd7723f1da60964a 100644 (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