-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: add get_invoice feature #25
base: rust
Are you sure you want to change the base?
Conversation
Dolu89
commented
Aug 17, 2022
•
edited
Loading
edited
- LndRest
- EclairRest
- ClnGrpc
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.
Changing configs in test files pollutes the diff (in my PRs too), let's replace them by "dummy cert", "dummy macaroon", etc strings from now on, until we have proper unit tests. I'm working on it 👌
core/src/backends/lnd/rest/types.rs
Outdated
use std::collections::HashMap; | ||
|
||
use crate::error::Error; | ||
use crate::utils::{b64_to_hex, parse_number}; |
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 comment as above regarding the utils
crate import.
core/src/backends/lnd/rest/types.rs
Outdated
amount: parse_number(&self.value).expect("amt_paid_sat should be a number"), | ||
amount_msat: parse_number(&self.value_msat).expect("amt_paid_msat should be a number"), | ||
pre_image: Some( | ||
b64_to_hex(&self.r_preimage) | ||
.expect("coudln't convert r_preimage from base64 to hex"), | ||
), | ||
payment_hash: b64_to_hex(&self.r_hash) | ||
.expect("coudln't convert r_hash from base64 to hex"), | ||
settled: self.settled, | ||
settle_date, | ||
creation_date: parse_number(&self.creation_date) | ||
.expect("creation_date should be a number"), | ||
expiry: parse_number(&self.expiry).expect("expiry should be a number"), |
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.
We should avoid the use of expect
and unwrap
as much as possible, as it panics the program. Consider adding a custom parsing error and raise it in the parse_number
function like I did in for b64_to_hex
.
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
#[serde(rename_all = "UPPERCASE")] | ||
pub enum InvoiceStateResponse { |
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.