Skip to content

Commit 7b86442

Browse files
committed
Remove InvoiceRequestFields::amount_msats
Event::PaymentClaimable and Event::PaymentClaimed already contain the paid amount, so there's no need to included the requested amount in InvoiceRequestFields.
1 parent 8e562be commit 7b86442

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

lightning/src/ln/offers_tests.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
412412
offer_id: offer.id(),
413413
invoice_request: InvoiceRequestFields {
414414
payer_id: invoice_request.payer_id(),
415-
amount_msats: None,
416415
features: InvoiceRequestFeatures::empty(),
417416
quantity: None,
418417
payer_note_truncated: None,
@@ -565,7 +564,6 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
565564
offer_id: offer.id(),
566565
invoice_request: InvoiceRequestFields {
567566
payer_id: invoice_request.payer_id(),
568-
amount_msats: None,
569567
features: InvoiceRequestFeatures::empty(),
570568
quantity: None,
571569
payer_note_truncated: None,
@@ -687,7 +685,6 @@ fn pays_for_offer_without_blinded_paths() {
687685
offer_id: offer.id(),
688686
invoice_request: InvoiceRequestFields {
689687
payer_id: invoice_request.payer_id(),
690-
amount_msats: None,
691688
features: InvoiceRequestFeatures::empty(),
692689
quantity: None,
693690
payer_note_truncated: None,

lightning/src/offers/invoice_request.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -877,13 +877,12 @@ impl VerifiedInvoiceRequest {
877877
let InvoiceRequestContents {
878878
payer_id,
879879
inner: InvoiceRequestContentsWithoutPayerId {
880-
payer: _, offer: _, chain: _, amount_msats, features, quantity, payer_note
880+
payer: _, offer: _, chain: _, amount_msats: _, features, quantity, payer_note
881881
},
882882
} = &self.inner.contents;
883883

884884
InvoiceRequestFields {
885885
payer_id: *payer_id,
886-
amount_msats: *amount_msats,
887886
features: features.clone(),
888887
quantity: *quantity,
889888
payer_note_truncated: payer_note.clone()
@@ -1126,12 +1125,6 @@ pub struct InvoiceRequestFields {
11261125
/// A possibly transient pubkey used to sign the invoice request.
11271126
pub payer_id: PublicKey,
11281127

1129-
/// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
1130-
/// must be greater than or equal to [`Offer::amount`], converted if necessary.
1131-
///
1132-
/// [`chain`]: InvoiceRequest::chain
1133-
pub amount_msats: Option<u64>,
1134-
11351128
/// Features pertaining to requesting an invoice.
11361129
pub features: InvoiceRequestFeatures,
11371130

@@ -1150,10 +1143,9 @@ impl Writeable for InvoiceRequestFields {
11501143
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
11511144
write_tlv_fields!(writer, {
11521145
(0, self.payer_id, required),
1153-
(2, self.amount_msats.map(|v| HighZeroBytesDroppedBigSize(v)), option),
1154-
(4, WithoutLength(&self.features), required),
1155-
(6, self.quantity.map(|v| HighZeroBytesDroppedBigSize(v)), option),
1156-
(8, self.payer_note_truncated.as_ref().map(|s| WithoutLength(&s.0)), option),
1146+
(2, WithoutLength(&self.features), required),
1147+
(4, self.quantity.map(|v| HighZeroBytesDroppedBigSize(v)), option),
1148+
(6, self.payer_note_truncated.as_ref().map(|s| WithoutLength(&s.0)), option),
11571149
});
11581150
Ok(())
11591151
}
@@ -1163,15 +1155,14 @@ impl Readable for InvoiceRequestFields {
11631155
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
11641156
_init_and_read_len_prefixed_tlv_fields!(reader, {
11651157
(0, payer_id, required),
1166-
(2, amount_msats, (option, encoding: (u64, HighZeroBytesDroppedBigSize))),
1167-
(4, features, (option, encoding: (InvoiceRequestFeatures, WithoutLength))),
1168-
(6, quantity, (option, encoding: (u64, HighZeroBytesDroppedBigSize))),
1169-
(8, payer_note_truncated, (option, encoding: (String, WithoutLength))),
1158+
(2, features, (option, encoding: (InvoiceRequestFeatures, WithoutLength))),
1159+
(4, quantity, (option, encoding: (u64, HighZeroBytesDroppedBigSize))),
1160+
(6, payer_note_truncated, (option, encoding: (String, WithoutLength))),
11701161
});
11711162
let features = features.unwrap_or(InvoiceRequestFeatures::empty());
11721163

11731164
Ok(InvoiceRequestFields {
1174-
payer_id: payer_id.0.unwrap(), amount_msats, features, quantity,
1165+
payer_id: payer_id.0.unwrap(), features, quantity,
11751166
payer_note_truncated: payer_note_truncated.map(|s| UntrustedString(s)),
11761167
})
11771168
}
@@ -2264,7 +2255,6 @@ mod tests {
22642255

22652256
let invoice_request = offer.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
22662257
.chain(Network::Testnet).unwrap()
2267-
.amount_msats(1001).unwrap()
22682258
.quantity(1).unwrap()
22692259
.payer_note("0".repeat(PAYER_NOTE_LIMIT * 2))
22702260
.build().unwrap()
@@ -2277,7 +2267,6 @@ mod tests {
22772267
fields,
22782268
InvoiceRequestFields {
22792269
payer_id: payer_pubkey(),
2280-
amount_msats: Some(1001),
22812270
features: InvoiceRequestFeatures::empty(),
22822271
quantity: Some(1),
22832272
payer_note_truncated: Some(UntrustedString("0".repeat(PAYER_NOTE_LIMIT))),

0 commit comments

Comments
 (0)