-
Notifications
You must be signed in to change notification settings - Fork 405
Validate amount_msats
against invreq amount
#3535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,14 @@ macro_rules! invoice_builder_methods_test { ( | |
$self: ident, $self_type: ty, $invoice_fields: expr, $return_type: ty, $return_value: expr | ||
$(, $self_mut: tt)? | ||
) => { | ||
#[cfg_attr(c_bindings, allow(dead_code))] | ||
pub(crate) fn amount_msats_unchecked( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, just realized this breaks CI because it doesn't work for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Grr, yea, please. |
||
$($self_mut)* $self: $self_type, amount_msats: u64, | ||
) -> $return_type { | ||
$invoice_fields.amount_msats = amount_msats; | ||
$return_value | ||
} | ||
|
||
#[cfg_attr(c_bindings, allow(dead_code))] | ||
pub(crate) fn features_unchecked( | ||
$($self_mut)* $self: $self_type, features: Bolt12InvoiceFeatures | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check this against the offer's set amount as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fixed this and added tests as discussed offline. Now
InvoiceRequest::amount_msats
will infer the amount from theOffer::amount
andInvoiceRequest::quantity
, is possible. Added a newInvoiceRequest::has_amount_msats
method as otherwise we can't determine whether the amount was explicitly set.