-
Notifications
You must be signed in to change notification settings - Fork 419
Allow building Invoice from Bolt11InvoiceDescriptionRef
#4012
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
Allow building Invoice from Bolt11InvoiceDescriptionRef
#4012
Conversation
👋 Thanks for assigning @tnull as a reviewer! |
5ce6539
to
56dd01b
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4012 +/- ##
==========================================
- Coverage 88.85% 88.82% -0.04%
==========================================
Files 175 175
Lines 127710 127767 +57
Branches 127710 127767 +57
==========================================
+ Hits 113478 113486 +8
- Misses 11675 11712 +37
- Partials 2557 2569 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🔔 1st Reminder Hey @joostjager! This PR has been waiting for your review. |
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.
Hmm, tbh. cloning in From
(which is intended to be value-to-value conversion) seems a bit anti-idiomatic. It might be cleaner to impl core::borrow::ToOwned
?
That said, honestly, the design choice of using Bolt11InvoiceDescriptionRef
just leads to a lot ugly/weird code in a bunch of places (see for example the unreachable
in fn description
, we also have some workaround code in LDK Node (especially also around exposing in bindings), etc).
Given that ~all users will end up cloning the returned strings/hashes at the callsite anyways, I think I'd personally be in favor of just dropping Bolt11InvoiceDescriptionRef
and always just returning the cloned/owned values.
(opinions, @TheBlueMatt @jkczyz ?)
👋 The first review has been submitted! Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer. |
I'd be more in favor of implementing |
yeah i agree, problem is we already impl
ack |
Hmm... How about add
IMO, we shouldn't have an accessor clone especially if it's gonna allocate on the heap. |
56dd01b
to
d9e9215
Compare
Changed to that, still probably annoying there isn't a function to convert between the two, this at least solves the annoyance I ran into |
Bolt11InvoiceDescriptionRef
to Bolt11InvoiceDescription
Bolt11InvoiceDescriptionRef
Small annoyance I found when updating in one of my downstream projects. Now that there are 2 types of Bolt11InvoiceDescription you can't just copy one from one invoice to a new one. This makes it so we can again build an invoice from the ref version.
d9e9215
to
9066f62
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.
Okay, while I still think that we could generally simplify the interface further, I'm happy to move forward with the currently proposed change which is simple enough.
This really didn't need a second reviewer. |
So you just want to drop the accessor to fetch a description? Not quite sure I understand the goal there. The unreachable is because one of two totally separate fields has to be set. Can you point to awkwardness in ldk-node due to this interface? |
The problem is trying to build an invoice using the same description/hash from another invoice. Our accessor returns |
Because internally its either a description hash field, or a description field. So the reference has to be inside the enum, not on the enum. |
Small annoyance I found when updating in one of my downstream projects.
Now that there are 2 types of Bolt11InvoiceDescription you can't just
copy one from one invoice to a new one. This makes it so we can again
build an invoice from the ref version.