-
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 decodeInvoice method (#19) #35
base: rust
Are you sure you want to change the base?
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.
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.
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>, | ||
} |
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 you forgot to add it 😁
expiry: self.expiry, | ||
min_final_cltv_expiry: self.min_final_cltv_expiry, | ||
features: Some(invoices_feature), | ||
route_hints: Vec::new(), |
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.
No route hints here?
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.
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
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.
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.
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.
Some useful links:
- https://github.com/ACINQ/eclair/blob/323aeec09c57194a669da0fec649f9509de850e0/eclair-core/src/main/scala/fr/acinq/eclair/payment/Bolt11Invoice.scala#L86
- https://github.com/ACINQ/eclair/search?q=hints
- https://github.com/ACINQ/eclair/search?q=routingInfo
- https://github.com/ACINQ/eclair/search?q=extraHops
- So basically
routingInfo
is a list containing a single list of hints.
No description provided.