-
Notifications
You must be signed in to change notification settings - Fork 83
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
Refactor and modularize payment APIs #270
Refactor and modularize payment APIs #270
Conversation
accd010
to
9c30bd1
Compare
@jkczyz Any thoughts on the naming here? I'm a bit on the fence if we should just drop the |
9c30bd1
to
2c663c7
Compare
How about Might be better to not be specific to protocol, FWIW. Rather just have a
My rule of thumb is to not use plurals in prefixes. Thus, |
Hmm, indeed that doesn't work for the receiving part.
I'm not sure: the API surface of covering all possible payment variations is rather large already, we're about to add substantially to it with BOLT12, and we eventually will also need to add, e.g., BOLT12 JIT variations. I think we eventually also want to provide helpers to generate and pay more unified interface (e.g., unified QR code, DNS payment addresses), but I'm not seeing how we can avoid the API getting a bit unwieldy if all variations keep living on a single object?
Yeah, seems we're on the same page here. |
Maybe Another idea would be to divide by inbound and outbound instead of by protocol / mechanism. |
You mean the |
Not the methods on |
ce13e42
to
966d982
Compare
So I also included fixups to rename the |
605e637
to
3eb14c8
Compare
3eb14c8
to
6536516
Compare
Rebased to resolve minor conflicts. |
d01fc0d
to
a611f3b
Compare
Now added two commits introducing a |
f198172
to
4884b82
Compare
54e94c2
to
c798308
Compare
c798308
to
28476cb
Compare
Rebased on main. |
f79d486
to
5b56978
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.
No major concerns left.
src/payment/payment_store.rs
Outdated
@@ -82,6 +137,73 @@ impl_writeable_tlv_based_enum!(PaymentStatus, | |||
(4, Failed) => {}; | |||
); | |||
|
|||
/// Represents the kind of a payment. | |||
#[derive(Clone, Debug, PartialEq, Eq)] | |||
pub enum PaymentKind { |
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.
Should we name this PaymentPurpose
for a closer mapping to LDK?
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.
Hm, tbh, I find the 'Purpose' part a bit of a misnomer? And, given this is not actually the same object, shadowing the name might be misleading?
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 strong opinion. Though I wonder if "kind" is just another way of saying "type". I'm a little more inclined with using the latter, but happy to defer to you 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.
Ah, I think I also started out with PaymentType
but then discovered that it would result in a shorthand type
(e.g., as the field name in PaymentDetails
where we omit the payment_
prefix), which of course doesn't work as type
is a keyword. Rather than entering r#type
territory, I just omitted the issue alltogether by switching to PaymentKind
. So, generally I agree PaymentType
seems a bit more natural, but that would mean we'd need to rename the PaymentDetails
fields, and it's probably not worth?
5b56978
to
07acb44
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.
LGTM. Please squash
.. which declutters our top-level docs a bit.
.. as we changed quite a bit and moved required fields, we add a test here that adds the old `PaymentDetails` as a test struct and ensures we're able to parse them just fine
07acb44
to
1fab656
Compare
Squashed without further changes. |
Based on #243.
Based on #244.
Based on #266.
Another prefactor to #193, splitting this out to reduce rebase pain, e.g., with #141.
As we're about to introduce a bunch more payment API methods for BOLT12 support, we first clean up and declutter our payment APIs so far.
What previously were individual methods on
Node
we now move to individualPaymentHandler
s:Bolt11PaymentHandler
SpontaneousPaymentHandler
OnchainPaymentHandler
While we're at it, we slightly remove the API methods to shorten them, allowing to call them like so:
Additionally, we move
PaymentStore
to a sub-module ofcrate::payment
to clean up our top-level docs a bit.