Skip to content

Commit fb6ba0b

Browse files
committed
Rename field of unsigned BOLT message contents
Using `contents` for the field name is more consistent with the signed messages.
1 parent 9c5f22c commit fb6ba0b

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

lightning/src/offers/invoice.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,16 +370,16 @@ impl<'a> InvoiceBuilder<'a, DerivedSigningPubkey> {
370370
/// A semantically valid [`Bolt12Invoice`] that hasn't been signed.
371371
pub struct UnsignedBolt12Invoice {
372372
bytes: Vec<u8>,
373-
invoice: InvoiceContents,
373+
contents: InvoiceContents,
374374
tagged_hash: TaggedHash,
375375
}
376376

377377
impl UnsignedBolt12Invoice {
378-
fn new(invreq_bytes: &[u8], invoice: InvoiceContents) -> Self {
378+
fn new(invreq_bytes: &[u8], contents: InvoiceContents) -> Self {
379379
// Use the invoice_request bytes instead of the invoice_request TLV stream as the latter may
380380
// have contained unknown TLV records, which are not stored in `InvoiceRequestContents` or
381381
// `RefundContents`.
382-
let (_, _, _, invoice_tlv_stream) = invoice.as_tlv_stream();
382+
let (_, _, _, invoice_tlv_stream) = contents.as_tlv_stream();
383383
let invoice_request_bytes = WithoutSignatures(invreq_bytes);
384384
let unsigned_tlv_stream = (invoice_request_bytes, invoice_tlv_stream);
385385

@@ -388,12 +388,12 @@ impl UnsignedBolt12Invoice {
388388

389389
let tagged_hash = TaggedHash::new(SIGNATURE_TAG, &bytes);
390390

391-
Self { bytes, invoice, tagged_hash }
391+
Self { bytes, contents, tagged_hash }
392392
}
393393

394394
/// The public key corresponding to the key needed to sign the invoice.
395395
pub fn signing_pubkey(&self) -> PublicKey {
396-
self.invoice.fields().signing_pubkey
396+
self.contents.fields().signing_pubkey
397397
}
398398

399399
/// Signs the invoice using the given function.
@@ -403,7 +403,7 @@ impl UnsignedBolt12Invoice {
403403
where
404404
F: FnOnce(&Self) -> Result<Signature, E>
405405
{
406-
let pubkey = self.invoice.fields().signing_pubkey;
406+
let pubkey = self.contents.fields().signing_pubkey;
407407
let signature = merkle::sign_message(sign, &self, pubkey)?;
408408

409409
// Append the signature TLV record to the bytes.
@@ -414,7 +414,7 @@ impl UnsignedBolt12Invoice {
414414

415415
Ok(Bolt12Invoice {
416416
bytes: self.bytes,
417-
contents: self.invoice,
417+
contents: self.contents,
418418
signature,
419419
})
420420
}
@@ -1802,7 +1802,7 @@ mod tests {
18021802
.sign(payer_sign).unwrap()
18031803
.respond_with_no_std(payment_paths(), payment_hash(), now()).unwrap()
18041804
.build().unwrap()
1805-
.invoice
1805+
.contents
18061806
.write(&mut buffer).unwrap();
18071807

18081808
match Bolt12Invoice::try_from(buffer) {

lightning/src/offers/invoice_request.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,16 @@ impl<'a, 'b, P: PayerIdStrategy, T: secp256k1::Signing> InvoiceRequestBuilder<'a
346346
/// A semantically valid [`InvoiceRequest`] that hasn't been signed.
347347
pub struct UnsignedInvoiceRequest {
348348
bytes: Vec<u8>,
349-
invoice_request: InvoiceRequestContents,
349+
contents: InvoiceRequestContents,
350350
tagged_hash: TaggedHash,
351351
}
352352

353353
impl UnsignedInvoiceRequest {
354-
fn new(offer: &Offer, invoice_request: InvoiceRequestContents) -> Self {
354+
fn new(offer: &Offer, contents: InvoiceRequestContents) -> Self {
355355
// Use the offer bytes instead of the offer TLV stream as the offer may have contained
356356
// unknown TLV records, which are not stored in `OfferContents`.
357357
let (payer_tlv_stream, _offer_tlv_stream, invoice_request_tlv_stream) =
358-
invoice_request.as_tlv_stream();
358+
contents.as_tlv_stream();
359359
let offer_bytes = WithoutLength(&offer.bytes);
360360
let unsigned_tlv_stream = (payer_tlv_stream, offer_bytes, invoice_request_tlv_stream);
361361

@@ -364,7 +364,7 @@ impl UnsignedInvoiceRequest {
364364

365365
let tagged_hash = TaggedHash::new(SIGNATURE_TAG, &bytes);
366366

367-
Self { bytes, invoice_request, tagged_hash }
367+
Self { bytes, contents, tagged_hash }
368368
}
369369

370370
/// Signs the invoice request using the given function.
@@ -374,7 +374,7 @@ impl UnsignedInvoiceRequest {
374374
where
375375
F: FnOnce(&Self) -> Result<Signature, E>
376376
{
377-
let pubkey = self.invoice_request.payer_id;
377+
let pubkey = self.contents.payer_id;
378378
let signature = merkle::sign_message(sign, &self, pubkey)?;
379379

380380
// Append the signature TLV record to the bytes.
@@ -385,7 +385,7 @@ impl UnsignedInvoiceRequest {
385385

386386
Ok(InvoiceRequest {
387387
bytes: self.bytes,
388-
contents: self.invoice_request,
388+
contents: self.contents,
389389
signature,
390390
})
391391
}
@@ -1681,7 +1681,7 @@ mod tests {
16811681
.build().unwrap();
16821682
let unsigned_invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
16831683
.build().unwrap();
1684-
let mut tlv_stream = unsigned_invoice_request.invoice_request.as_tlv_stream();
1684+
let mut tlv_stream = unsigned_invoice_request.contents.as_tlv_stream();
16851685
tlv_stream.0.metadata = None;
16861686

16871687
let mut buffer = Vec::new();
@@ -1702,7 +1702,7 @@ mod tests {
17021702
.build().unwrap();
17031703
let unsigned_invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
17041704
.build().unwrap();
1705-
let mut tlv_stream = unsigned_invoice_request.invoice_request.as_tlv_stream();
1705+
let mut tlv_stream = unsigned_invoice_request.contents.as_tlv_stream();
17061706
tlv_stream.2.payer_id = None;
17071707

17081708
let mut buffer = Vec::new();
@@ -1721,7 +1721,7 @@ mod tests {
17211721
.build().unwrap();
17221722
let unsigned_invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
17231723
.build().unwrap();
1724-
let mut tlv_stream = unsigned_invoice_request.invoice_request.as_tlv_stream();
1724+
let mut tlv_stream = unsigned_invoice_request.contents.as_tlv_stream();
17251725
tlv_stream.1.node_id = None;
17261726

17271727
let mut buffer = Vec::new();
@@ -1743,7 +1743,7 @@ mod tests {
17431743
.build().unwrap()
17441744
.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
17451745
.build().unwrap()
1746-
.invoice_request
1746+
.contents
17471747
.write(&mut buffer).unwrap();
17481748

17491749
match InvoiceRequest::try_from(buffer) {

0 commit comments

Comments
 (0)