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 decodeInvoice method (#19) #35

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

feat: add decodeInvoice method (#19) #35

wants to merge 7 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Sep 30, 2022

No description provided.

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.

Thanks for this PR @acidbunny21!

Globally, we need to avoid as much as possible the use of expect and unwrap. For more details on this, see this chapter of the Rust Book. For type conversion that can fail, we can use a TryInto that will return a proper Una error in case of something going wrong, instead of panicking the whole program with unwrap.

We will also need to rebase #32 before merging this.

core/src/backends/lnd/rest/types.rs Outdated Show resolved Hide resolved
core/src/backends/lnd/rest/types.rs Outdated Show resolved Hide resolved
core/src/backends/lnd/rest/config.rs Outdated Show resolved Hide resolved
core/src/backends/lnd/rest/node.rs Outdated Show resolved Hide resolved
core/src/backends/lnd/rest/types.rs Outdated Show resolved Hide resolved
core/src/backends/cln/grpc/pb.rs Outdated Show resolved Hide resolved
core/src/backends/cln/grpc/pb.rs Outdated Show resolved Hide resolved
core/src/backends/cln/grpc/pb.rs Outdated Show resolved Hide resolved
core/src/backends/cln/grpc/pb.rs Show resolved Hide resolved
core/src/backends/cln/grpc/pb.rs Outdated Show resolved Hide resolved
core/src/backends/cln/grpc/config.rs Outdated Show resolved Hide resolved
core/src/backends/cln/grpc/pb.rs Outdated Show resolved Hide resolved
core/src/backends/cln/grpc/pb.rs Outdated Show resolved Hide resolved
core/src/backends/cln/grpc/pb.rs Outdated Show resolved Hide resolved
Comment on lines 297 to 309
pub struct DecodeInvoiceResponse {
pub prefix: String,
pub timestamp: i64,
pub node_id: String,
pub serialized: String,
pub description: String,
pub payment_hash: String,
pub expiry: i32,
pub min_final_cltv_expiry: u32,
pub amount: u64,
pub features: Features,
pub routing_info: Vec<Value>,
}
Copy link
Member

Choose a reason for hiding this comment

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

I think you forgot to add it 😁

core/src/backends/eclair/rest/types.rs Outdated Show resolved Hide resolved
expiry: self.expiry,
min_final_cltv_expiry: self.min_final_cltv_expiry,
features: Some(invoices_feature),
route_hints: Vec::new(),
Copy link
Member

Choose a reason for hiding this comment

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

No route hints here?

Copy link
Author

Choose a reason for hiding this comment

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

typing of route_hints isn't provided here (that's i kept Vec in the struct) and i wasn't able to simulate a route_hints inside Polar, if you know how i can do so, let me know

Copy link
Member

Choose a reason for hiding this comment

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

Here you go (redacted):

"routingInfo": [
    [
        {
            "nodeId": "03xxxxxxxxxxxxxxxxxxxxxxxxxx",
            "shortChannelId": "10000000x200000x10000",
            "feeBase": 1000,
            "feeProportionalMillionths": 100,
            "cltvExpiryDelta": 144
        }
    ]
]

I generated an invoice on Phoenix and parsed it using Polar.

Copy link
Member

@louneskmt louneskmt Oct 18, 2022

Choose a reason for hiding this comment

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

core/src/types.rs Outdated Show resolved Hide resolved
core/src/types.rs Outdated Show resolved Hide resolved
core/src/backends/eclair/rest/types.rs Outdated Show resolved Hide resolved
core/src/backends/eclair/rest/types.rs Outdated Show resolved Hide resolved
core/src/backends/cln/grpc/pb.rs Outdated Show resolved Hide resolved
@ghost ghost closed this by deleting the head repository Jan 26, 2023
@louneskmt louneskmt reopened this Jan 26, 2023
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.

1 participant