-
Notifications
You must be signed in to change notification settings - Fork 210
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
en/de-codeable for lightning_invoice::Invoice #230
Conversation
NicolaLS
commented
Jul 9, 2022
- helps to put invoices into db
- will be needed to fix this when this PR is available
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.
Concept ACK, just two nits. If you find out what is doing the reformatting and if you can either turn it off or enforce it via CI that would be good. Worst case we merge with the reformatting, it's just annoying long term because it makes git blame
less useful.
minimint-api/Cargo.toml
Outdated
@@ -8,26 +8,27 @@ edition = "2018" | |||
[dependencies] | |||
anyhow = "1.0.58" | |||
async-trait = "0.1" | |||
bitcoin = { version = "0.28.1", features = [ "rand", "serde" ] } | |||
bitcoin = { version = "0.28.1", features = ["rand", "serde"] } |
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.
What software is doing the reformatting here? I'd rather avoid that since it's not checked by CI and will thus diverge again (leading to autoreformatting once you touch it again).
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 think IntelliJ idea Settings>tools>actions on safe, I turned that on because I thought it would sort the dependencies but it dosn't do that and I forgot to turn it off
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.
Ah, there is another setting under Settings>Languages&Frameworks>Rust>Rustfmt "Run rustfmt on Save", that's what I have turned on and what CI verifies. That's better imo because it's independent of any particular IDE.
minimint-api/src/encoding/mod.rs
Outdated
let invoice_string = | ||
String::from_utf8(Decodable::consensus_decode(d)?).map_err(DecodeError::from_err)?; |
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.
You can directly decode strings, no need to go via Vec<u8>
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.
So something like this I think ...
String::consensus_decode(d)?
.parse::<lightning_invoice::Invoice>()
.map_err(DecodeError::from_err)
Also, let's add a unittest. I think the following would work:
Took that invoice from your Otherwise, looks great. Thanks for adding this! |
6a8fa29
to
97210c8
Compare
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.
Thx!