Skip to content

Commit 1429e84

Browse files
committed
f - check quantity against offer upfront
1 parent fc26a6b commit 1429e84

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lightning/src/offers/invoice_request.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ impl<'a> InvoiceRequestBuilder<'a> {
129129
Ok(self)
130130
}
131131

132+
#[cfg(test)]
133+
pub fn quantity_unchecked(mut self, quantity: u64) -> Self {
134+
self.invoice_request.quantity = Some(quantity);
135+
self
136+
}
137+
132138
/// Sets the [`InvoiceRequest::payer_note`].
133139
///
134140
/// Successive calls to this method will override the previous setting.
@@ -918,7 +924,7 @@ mod tests {
918924
.build().unwrap()
919925
.request_invoice(vec![1; 32], payer_pubkey())
920926
.amount_msats(2_000)
921-
.quantity(2)
927+
.quantity_unchecked(2)
922928
.build_unchecked()
923929
.sign(payer_sign).unwrap();
924930

@@ -938,7 +944,7 @@ mod tests {
938944
.build().unwrap()
939945
.request_invoice(vec![1; 32], payer_pubkey())
940946
.amount_msats(10_000)
941-
.quantity(10)
947+
.quantity(10).unwrap()
942948
.build().unwrap()
943949
.sign(payer_sign).unwrap();
944950

@@ -955,7 +961,7 @@ mod tests {
955961
.build().unwrap()
956962
.request_invoice(vec![1; 32], payer_pubkey())
957963
.amount_msats(11_000)
958-
.quantity(11)
964+
.quantity_unchecked(11)
959965
.build_unchecked()
960966
.sign(payer_sign).unwrap();
961967

@@ -973,7 +979,7 @@ mod tests {
973979
.build().unwrap()
974980
.request_invoice(vec![1; 32], payer_pubkey())
975981
.amount_msats(2_000)
976-
.quantity(2)
982+
.quantity(2).unwrap()
977983
.build().unwrap()
978984
.sign(payer_sign).unwrap();
979985

0 commit comments

Comments
 (0)