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

feat: add get_invoice feature #25

Open
wants to merge 12 commits into
base: rust
Choose a base branch
from
Open

Conversation

Dolu89
Copy link
Member

@Dolu89 Dolu89 commented Aug 17, 2022

  • LndRest
  • EclairRest
  • ClnGrpc

@Dolu89 Dolu89 linked an issue Aug 17, 2022 that may be closed by this pull request
@Dolu89 Dolu89 marked this pull request as ready for review August 19, 2022 14:36
Copy link
Member

@louneskmt louneskmt left a 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 👌

bindings/una-js/src/lib.rs Outdated Show resolved Hide resolved
bindings/una-js/src/lib.rs Outdated Show resolved Hide resolved
bindings/una-js/src/lib.rs Outdated Show resolved Hide resolved
bindings/una-python/src/lib.rs Outdated Show resolved Hide resolved
core/src/backends/cln/grpc/node.rs Outdated Show resolved Hide resolved
core/src/backends/eclair/rest/types.rs Outdated Show resolved Hide resolved
core/src/backends/lnd/rest/node.rs Outdated Show resolved Hide resolved
use std::collections::HashMap;

use crate::error::Error;
use crate::utils::{b64_to_hex, parse_number};
Copy link
Member

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.

Comment on lines 180 to 192
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"),
Copy link
Member

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.

core/src/utils.rs Outdated Show resolved Hide resolved
core/src/backends/lnd/rest/types.rs Show resolved Hide resolved

#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum InvoiceStateResponse {
Copy link
Member

Choose a reason for hiding this comment

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

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.

Add get invoice feature
2 participants