Introduce PaymentStore to store external payment information - #51
Introduce PaymentStore to store external payment information #51andrei-21 wants to merge 4 commits into
PaymentStore to store external payment information #51Conversation
01f1b9e to
bd057ec
Compare
PaymentStore to store external payment information
roeierez
left a comment
There was a problem hiding this comment.
I understand the concept. I am missing the actual use of the data in the new store.
| #[tonic::async_trait] | ||
| pub trait PaymentStore: Send + Sync { | ||
| async fn set_ln_info(&self, payment_id: &str, info: &LnPaymentInfo) -> SdkResult<()>; | ||
| async fn set_lnurl_info(&self, payment_id: &str, info: &LnUrlInfo) -> SdkResult<()>; |
| }; | ||
| let info = LnUrlInfo::Pay(info); | ||
| self.payment_store | ||
| .set_lnurl_info(&invoice.payment_hash, &info) |
There was a problem hiding this comment.
I see we still keep thte insert_payment_external_info. Isn't the whole idea that this payment store will replace that?
Right, the idea here is to start storing data first. LNURL info is only a fraction of what needs to be stored (also swap info). |
I find this way hard to follow and review. Doesn't it seems better to introduce a full store implementation with usage and remove the old store? The other option is to introduce partial implementation but with actual usage. |
|
Ok, I see. I will try to make a small but complete solution. |
5421967 to
c49276e
Compare
|
I implemented storing and retrieving lighting payment info and LNURL info. |
c49276e to
0a3f49d
Compare
| string? lnurl_metadata; | ||
| string? ln_address; | ||
| string? lnurl_withdraw_endpoint; | ||
| LnUrlInfo? lnurl_info; |
There was a problem hiding this comment.
Should we remove now the redundant old lnurl fields from the udl?
There was a problem hiding this comment.
Yes, I will remove.
| pub bolt11: String, | ||
| pub payment_hash: String, | ||
| pub destination_pubkey: String, | ||
| pub description: String, |
| description: invoice | ||
| .description | ||
| .as_ref() | ||
| .or(invoice.description_hash.as_ref()) |
There was a problem hiding this comment.
Aren't we mixing here description and description hash by using the same field?
There was a problem hiding this comment.
Well, a bolt11 invoice must have a description or a description hash, since description hashes are not really supported in the ecosystem (neither in Breez SDK) I suggest just to treat it as a string (rather then discarding it). What do think?
There was a problem hiding this comment.
I think if you decide not to support it then it shouldn't be used at all. This way it is confusing because the it mislead the user to think it is the description and nothing tells it is actually a description hash.
There was a problem hiding this comment.
I will drop description hashes then.
JssDWt
left a comment
There was a problem hiding this comment.
Can/should we delete SqliteStorage now?
| for payment_id in payment_ids { | ||
| match KVStoreAsync::read(self.kv_store.as_ref(), BREEZ_NS, LNURL_INFOS_NS, payment_id) | ||
| .await |
There was a problem hiding this comment.
This is a database roundtrip per payment. Can we do something more efficient?
There was a problem hiding this comment.
Yes. I made the simplest implementation for now. Later we can optimize it if there is a need. What do you think?
There was a problem hiding this comment.
I think this is one where the need to optimize will show up as something really bad.
There was a problem hiding this comment.
You suggest to do it now?
I would want to get approval for the whole concept first.
Not yet. |
5d33903 to
160672e
Compare
First, review
models.rs, where data structures are defined in a more natural way. ThePaymentStoretrait abstracts data storage, enabling decoupling of storage logic. TheStoreinkv_store.rsimplements this trait and will later implementSwapStorageas well. This design allows us to bypass persistent storage and instead retrieve payments viaNodeApi, enriching them with data fromStore.