Skip to content

Commit b191010

Browse files
committed
f - check quantity against offer upfront
1 parent 0a021f7 commit b191010

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
@@ -137,6 +137,12 @@ impl<'a> InvoiceRequestBuilder<'a> {
137137
Ok(self)
138138
}
139139

140+
#[cfg(test)]
141+
pub fn quantity_unchecked(mut self, quantity: u64) -> Self {
142+
self.invoice_request.quantity = Some(quantity);
143+
self
144+
}
145+
140146
/// Sets the [`InvoiceRequest::payer_note`].
141147
///
142148
/// Successive calls to this method will override the previous setting.
@@ -948,7 +954,7 @@ mod tests {
948954
.build().unwrap()
949955
.request_invoice(vec![1; 32], payer_pubkey())
950956
.amount_msats(2_000)
951-
.quantity(2)
957+
.quantity_unchecked(2)
952958
.build_unchecked()
953959
.sign(payer_sign).unwrap();
954960

@@ -968,7 +974,7 @@ mod tests {
968974
.build().unwrap()
969975
.request_invoice(vec![1; 32], payer_pubkey())
970976
.amount_msats(10_000)
971-
.quantity(10)
977+
.quantity(10).unwrap()
972978
.build().unwrap()
973979
.sign(payer_sign).unwrap();
974980

@@ -985,7 +991,7 @@ mod tests {
985991
.build().unwrap()
986992
.request_invoice(vec![1; 32], payer_pubkey())
987993
.amount_msats(11_000)
988-
.quantity(11)
994+
.quantity_unchecked(11)
989995
.build_unchecked()
990996
.sign(payer_sign).unwrap();
991997

@@ -1003,7 +1009,7 @@ mod tests {
10031009
.build().unwrap()
10041010
.request_invoice(vec![1; 32], payer_pubkey())
10051011
.amount_msats(2_000)
1006-
.quantity(2)
1012+
.quantity(2).unwrap()
10071013
.build().unwrap()
10081014
.sign(payer_sign).unwrap();
10091015

0 commit comments

Comments
 (0)