Skip to content

Commit 2c6e638

Browse files
committed
f - check quantity against offer upfront
1 parent cb38054 commit 2c6e638

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

@@ -975,7 +981,7 @@ mod tests {
975981
.build().unwrap()
976982
.request_invoice(vec![1; 32], payer_pubkey())
977983
.amount_msats(10_000)
978-
.quantity(10)
984+
.quantity(10).unwrap()
979985
.build().unwrap()
980986
.sign(payer_sign).unwrap();
981987

@@ -992,7 +998,7 @@ mod tests {
992998
.build().unwrap()
993999
.request_invoice(vec![1; 32], payer_pubkey())
9941000
.amount_msats(11_000)
995-
.quantity(11)
1001+
.quantity_unchecked(11)
9961002
.build_unchecked()
9971003
.sign(payer_sign).unwrap();
9981004

@@ -1010,7 +1016,7 @@ mod tests {
10101016
.build().unwrap()
10111017
.request_invoice(vec![1; 32], payer_pubkey())
10121018
.amount_msats(2_000)
1013-
.quantity(2)
1019+
.quantity(2).unwrap()
10141020
.build().unwrap()
10151021
.sign(payer_sign).unwrap();
10161022

0 commit comments

Comments
 (0)