Skip to content

Commit 3dd0f23

Browse files
committed
f - check quantity against offer upfront
1 parent 02af333 commit 3dd0f23

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

142+
#[cfg(test)]
143+
pub fn quantity_unchecked(mut self, quantity: u64) -> Self {
144+
self.invoice_request.quantity = Some(quantity);
145+
self
146+
}
147+
142148
/// Sets the [`InvoiceRequest::payer_note`].
143149
///
144150
/// Successive calls to this method will override the previous setting.
@@ -1032,7 +1038,7 @@ mod tests {
10321038
.build().unwrap()
10331039
.request_invoice(vec![1; 32], payer_pubkey())
10341040
.amount_msats(2_000)
1035-
.quantity(2)
1041+
.quantity_unchecked(2)
10361042
.build_unchecked()
10371043
.sign(payer_sign).unwrap();
10381044

@@ -1052,7 +1058,7 @@ mod tests {
10521058
.build().unwrap()
10531059
.request_invoice(vec![1; 32], payer_pubkey())
10541060
.amount_msats(10_000)
1055-
.quantity(10)
1061+
.quantity(10).unwrap()
10561062
.build().unwrap()
10571063
.sign(payer_sign).unwrap();
10581064

@@ -1069,7 +1075,7 @@ mod tests {
10691075
.build().unwrap()
10701076
.request_invoice(vec![1; 32], payer_pubkey())
10711077
.amount_msats(11_000)
1072-
.quantity(11)
1078+
.quantity_unchecked(11)
10731079
.build_unchecked()
10741080
.sign(payer_sign).unwrap();
10751081

@@ -1087,7 +1093,7 @@ mod tests {
10871093
.build().unwrap()
10881094
.request_invoice(vec![1; 32], payer_pubkey())
10891095
.amount_msats(2_000)
1090-
.quantity(2)
1096+
.quantity(2).unwrap()
10911097
.build().unwrap()
10921098
.sign(payer_sign).unwrap();
10931099

0 commit comments

Comments
 (0)