-
Notifications
You must be signed in to change notification settings - Fork 95
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
Conversation
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.
utACK, suggested to get rid of hrp local vars in the comments, but that's just a nit anyway
let hrp = result.hrp(); | ||
if hrp.as_str() != params.bech32_hrp_payment { |
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.
let hrp = result.hrp(); | |
if hrp.as_str() != params.bech32_hrp_payment { | |
if result.hrp().as_str() != params.bech32_hrp_payment { |
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.
Can't do this as as_str() returns a reference to something inside the hrp instance, so the hrp() value needs to stay alive :(.
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.
I see 👍 thanks
let hrp = decoded_addr.hrp(); | ||
let hrp: &str = hrp.as_str(); | ||
if hrp != expected_hrp { | ||
if hrp.as_str() != expected_hrp { |
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.
Same here, I think you could get rid of the hrp variable.
No description provided.