Skip to content
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

Validate amount parameter #525

Merged
merged 2 commits into from
Oct 18, 2023
Merged

Validate amount parameter #525

merged 2 commits into from
Oct 18, 2023

Conversation

roeierez
Copy link
Member

fixed #522

@roeierez roeierez requested review from dangeross and ok300 October 17, 2023 12:06
@@ -235,6 +235,23 @@ impl BreezServices {
) -> SdkResult<Payment> {
self.start_node().await?;
let parsed_invoice = parse_invoice(bolt11.as_str())?;
let invoice_amount_msat = parsed_invoice.amount_msat.unwrap_or_default();
let provided_amount_msat = amount_sats.unwrap_or_default() * 1000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is a good time to change the method signature to amount_msat? I think we'd want to do that anyway?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, changing to msat is a step towards #417.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with both of you. I did change this method signature to msat. Not all other methods.
I think we have 2 more methods where we should change (I am not sure the onchain methods should use msat).
I suggest to do it in a separate PR.

libs/sdk-core/src/breez_services.rs Show resolved Hide resolved
Copy link
Contributor

@JssDWt JssDWt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Collaborator

@dangeross dangeross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just a comment about log filters below. As you're changing the send_payment interface, you could also move to a SendPaymentRequest struct

Comment on lines -1188 to +1210
info,
debug,
breez_sdk_core::input_parser=warn,
breez_sdk_core::backup=info,
breez_sdk_core::persist::reverseswap=info,
breez_sdk_core::reverseswap=info,
gl_client=warn,
gl_client=debug,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to include log filter changes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Actually I didn't but I find myself always change that when I need to debug, I think we can push this change as it enables logging the signer and gl-client node logs.
What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 just making sure

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should SendPaymentRequest struct changes be included to

?

@roeierez roeierez merged commit fe05ccc into main Oct 18, 2023
5 checks passed
@erdemyerebasmaz erdemyerebasmaz deleted the validate-send-amount branch December 7, 2023 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

send_payment throws an error if amount_sats and bolt11 amount_msat is set
5 participants