created_at: Duration, payment_hash: PaymentHash
) -> Result<Self, SemanticError> {
let amount_msats = Self::check_amount_msats(invoice_request)?;
+ let signing_pubkey = invoice_request.contents.inner.offer.signing_pubkey();
let contents = InvoiceContents::ForOffer {
invoice_request: invoice_request.contents.clone(),
- fields: InvoiceFields {
- payment_paths, created_at, relative_expiry: None, payment_hash, amount_msats,
- fallbacks: None, features: Bolt12InvoiceFeatures::empty(),
- signing_pubkey: invoice_request.contents.inner.offer.signing_pubkey(),
- },
+ fields: Self::fields(
+ payment_paths, created_at, payment_hash, amount_msats, signing_pubkey
+ ),
};
Self::new(&invoice_request.bytes, contents, None)
refund: &'a Refund, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, created_at: Duration,
payment_hash: PaymentHash, signing_pubkey: PublicKey
) -> Result<Self, SemanticError> {
+ let amount_msats = refund.amount_msats();
let contents = InvoiceContents::ForRefund {
refund: refund.contents.clone(),
- fields: InvoiceFields {
- payment_paths, created_at, relative_expiry: None, payment_hash,
- amount_msats: refund.amount_msats(), fallbacks: None,
- features: Bolt12InvoiceFeatures::empty(), signing_pubkey,
- },
+ fields: Self::fields(
+ payment_paths, created_at, payment_hash, amount_msats, signing_pubkey
+ ),
};
Self::new(&refund.bytes, contents, None)
created_at: Duration, payment_hash: PaymentHash, keys: KeyPair
) -> Result<Self, SemanticError> {
let amount_msats = Self::check_amount_msats(invoice_request)?;
+ let signing_pubkey = invoice_request.contents.inner.offer.signing_pubkey();
let contents = InvoiceContents::ForOffer {
invoice_request: invoice_request.contents.clone(),
- fields: InvoiceFields {
- payment_paths, created_at, relative_expiry: None, payment_hash, amount_msats,
- fallbacks: None, features: Bolt12InvoiceFeatures::empty(),
- signing_pubkey: invoice_request.contents.inner.offer.signing_pubkey(),
- },
+ fields: Self::fields(
+ payment_paths, created_at, payment_hash, amount_msats, signing_pubkey
+ ),
};
Self::new(&invoice_request.bytes, contents, Some(keys))
refund: &'a Refund, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, created_at: Duration,
payment_hash: PaymentHash, keys: KeyPair,
) -> Result<Self, SemanticError> {
+ let amount_msats = refund.amount_msats();
+ let signing_pubkey = keys.public_key();
let contents = InvoiceContents::ForRefund {
refund: refund.contents.clone(),
- fields: InvoiceFields {
- payment_paths, created_at, relative_expiry: None, payment_hash,
- amount_msats: refund.amount_msats(), fallbacks: None,
- features: Bolt12InvoiceFeatures::empty(), signing_pubkey: keys.public_key(),
- },
+ fields: Self::fields(
+ payment_paths, created_at, payment_hash, amount_msats, signing_pubkey
+ ),
};
Self::new(&refund.bytes, contents, Some(keys))
}
}
+ fn fields(
+ payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, created_at: Duration,
+ payment_hash: PaymentHash, amount_msats: u64, signing_pubkey: PublicKey
+ ) -> InvoiceFields {
+ InvoiceFields {
+ payment_paths, created_at, relative_expiry: None, payment_hash, amount_msats,
+ fallbacks: None, features: Bolt12InvoiceFeatures::empty(), signing_pubkey,
+ }
+ }
+
fn new(
invreq_bytes: &'a Vec<u8>, contents: InvoiceContents, keys: Option<KeyPair>
) -> Result<Self, SemanticError> {