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

rust: simplify bech32 hrp check #1315

Merged
merged 1 commit into from
Oct 6, 2024
Merged

rust: simplify bech32 hrp check #1315

merged 1 commit into from
Oct 6, 2024

Conversation

benma
Copy link
Collaborator

@benma benma commented Oct 3, 2024

No description provided.

@benma benma requested a review from Beerosagos October 3, 2024 13:54
Copy link
Collaborator

@Beerosagos Beerosagos left a comment

Choose a reason for hiding this comment

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

utACK, suggested to get rid of hrp local vars in the comments, but that's just a nit anyway

Comment on lines +46 to +47
let hrp = result.hrp();
if hrp.as_str() != params.bech32_hrp_payment {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let hrp = result.hrp();
if hrp.as_str() != params.bech32_hrp_payment {
if result.hrp().as_str() != params.bech32_hrp_payment {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can't do this as as_str() returns a reference to something inside the hrp instance, so the hrp() value needs to stay alive :(.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see 👍 thanks

Comment on lines 79 to +80
let hrp = decoded_addr.hrp();
let hrp: &str = hrp.as_str();
if hrp != expected_hrp {
if hrp.as_str() != expected_hrp {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, I think you could get rid of the hrp variable.

@benma benma merged commit 670fd1d into BitBoxSwiss:master Oct 6, 2024
3 checks passed
@benma benma deleted the hrp branch October 6, 2024 13:42
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.

3 participants