/// A semantically valid [`Bolt12Invoice`] that hasn't been signed.
pub struct UnsignedBolt12Invoice {
bytes: Vec<u8>,
- invoice: InvoiceContents,
+ contents: InvoiceContents,
tagged_hash: TaggedHash,
}
impl UnsignedBolt12Invoice {
- fn new(invreq_bytes: &[u8], invoice: InvoiceContents) -> Self {
+ fn new(invreq_bytes: &[u8], contents: InvoiceContents) -> Self {
// Use the invoice_request bytes instead of the invoice_request TLV stream as the latter may
// have contained unknown TLV records, which are not stored in `InvoiceRequestContents` or
// `RefundContents`.
- let (_, _, _, invoice_tlv_stream) = invoice.as_tlv_stream();
+ let (_, _, _, invoice_tlv_stream) = contents.as_tlv_stream();
let invoice_request_bytes = WithoutSignatures(invreq_bytes);
let unsigned_tlv_stream = (invoice_request_bytes, invoice_tlv_stream);
let tagged_hash = TaggedHash::new(SIGNATURE_TAG, &bytes);
- Self { bytes, invoice, tagged_hash }
+ Self { bytes, contents, tagged_hash }
}
/// The public key corresponding to the key needed to sign the invoice.
pub fn signing_pubkey(&self) -> PublicKey {
- self.invoice.fields().signing_pubkey
+ self.contents.fields().signing_pubkey
}
/// Signs the invoice using the given function.
where
F: FnOnce(&Self) -> Result<Signature, E>
{
- let pubkey = self.invoice.fields().signing_pubkey;
+ let pubkey = self.contents.fields().signing_pubkey;
let signature = merkle::sign_message(sign, &self, pubkey)?;
// Append the signature TLV record to the bytes.
Ok(Bolt12Invoice {
bytes: self.bytes,
- contents: self.invoice,
+ contents: self.contents,
signature,
})
}
.sign(payer_sign).unwrap()
.respond_with_no_std(payment_paths(), payment_hash(), now()).unwrap()
.build().unwrap()
- .invoice
+ .contents
.write(&mut buffer).unwrap();
match Bolt12Invoice::try_from(buffer) {
/// A semantically valid [`InvoiceRequest`] that hasn't been signed.
pub struct UnsignedInvoiceRequest {
bytes: Vec<u8>,
- invoice_request: InvoiceRequestContents,
+ contents: InvoiceRequestContents,
tagged_hash: TaggedHash,
}
impl UnsignedInvoiceRequest {
- fn new(offer: &Offer, invoice_request: InvoiceRequestContents) -> Self {
+ fn new(offer: &Offer, contents: InvoiceRequestContents) -> Self {
// Use the offer bytes instead of the offer TLV stream as the offer may have contained
// unknown TLV records, which are not stored in `OfferContents`.
let (payer_tlv_stream, _offer_tlv_stream, invoice_request_tlv_stream) =
- invoice_request.as_tlv_stream();
+ contents.as_tlv_stream();
let offer_bytes = WithoutLength(&offer.bytes);
let unsigned_tlv_stream = (payer_tlv_stream, offer_bytes, invoice_request_tlv_stream);
let tagged_hash = TaggedHash::new(SIGNATURE_TAG, &bytes);
- Self { bytes, invoice_request, tagged_hash }
+ Self { bytes, contents, tagged_hash }
}
/// Signs the invoice request using the given function.
where
F: FnOnce(&Self) -> Result<Signature, E>
{
- let pubkey = self.invoice_request.payer_id;
+ let pubkey = self.contents.payer_id;
let signature = merkle::sign_message(sign, &self, pubkey)?;
// Append the signature TLV record to the bytes.
Ok(InvoiceRequest {
bytes: self.bytes,
- contents: self.invoice_request,
+ contents: self.contents,
signature,
})
}
.build().unwrap();
let unsigned_invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
.build().unwrap();
- let mut tlv_stream = unsigned_invoice_request.invoice_request.as_tlv_stream();
+ let mut tlv_stream = unsigned_invoice_request.contents.as_tlv_stream();
tlv_stream.0.metadata = None;
let mut buffer = Vec::new();
.build().unwrap();
let unsigned_invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
.build().unwrap();
- let mut tlv_stream = unsigned_invoice_request.invoice_request.as_tlv_stream();
+ let mut tlv_stream = unsigned_invoice_request.contents.as_tlv_stream();
tlv_stream.2.payer_id = None;
let mut buffer = Vec::new();
.build().unwrap();
let unsigned_invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
.build().unwrap();
- let mut tlv_stream = unsigned_invoice_request.invoice_request.as_tlv_stream();
+ let mut tlv_stream = unsigned_invoice_request.contents.as_tlv_stream();
tlv_stream.1.node_id = None;
let mut buffer = Vec::new();
.build().unwrap()
.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
.build().unwrap()
- .invoice_request
+ .contents
.write(&mut buffer).unwrap();
match InvoiceRequest::try_from(buffer) {