Skip to content

Introduce PaymentStore to store external payment information - #51

Draft
andrei-21 wants to merge 4 commits into
breez:mainfrom
andrei-21:feature/payment-store
Draft

Introduce PaymentStore to store external payment information #51
andrei-21 wants to merge 4 commits into
breez:mainfrom
andrei-21:feature/payment-store

Conversation

@andrei-21

@andrei-21 andrei-21 commented Feb 2, 2026

Copy link
Copy Markdown
Collaborator

First, review models.rs, where data structures are defined in a more natural way. The PaymentStore trait abstracts data storage, enabling decoupling of storage logic. The Store in kv_store.rs implements this trait and will later implement SwapStorage as well. This design allows us to bypass persistent storage and instead retrieve payments via NodeApi, enriching them with data from Store.

@andrei-21
andrei-21 force-pushed the feature/payment-store branch 3 times, most recently from 01f1b9e to bd057ec Compare February 4, 2026 19:43
@andrei-21 andrei-21 changed the title Introduce PaymentStore Introduce PaymentStore to store external payment information Feb 4, 2026
@andrei-21
andrei-21 marked this pull request as ready for review February 5, 2026 09:42
@andrei-21
andrei-21 requested review from JssDWt and roeierez February 5, 2026 09:42

@roeierez roeierez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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<()>;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Missing get_lnurl_info ?

};
let info = LnUrlInfo::Pay(info);
self.payment_store
.set_lnurl_info(&invoice.payment_hash, &info)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see we still keep thte insert_payment_external_info. Isn't the whole idea that this payment store will replace that?

@andrei-21

Copy link
Copy Markdown
Collaborator Author

I understand the concept. I am missing the actual use of the data in the new store.

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).
This PR is the first step, it stores LNURL data, later I will add storing swap info, eventually all necessary data will be stored in the new store. After that I will replace reading payment info from Breez SDK storage with the new storage.

@roeierez

Copy link
Copy Markdown
Member

I understand the concept. I am missing the actual use of the data in the new store.

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). This PR is the first step, it stores LNURL data, later I will add storing swap info, eventually all necessary data will be stored in the new store. After that I will replace reading payment info from Breez SDK storage with the new storage.

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.
With the current way I find the review not effective

@andrei-21
andrei-21 marked this pull request as draft February 12, 2026 13:22
@andrei-21

Copy link
Copy Markdown
Collaborator Author

Ok, I see. I will try to make a small but complete solution.

@andrei-21
andrei-21 force-pushed the feature/payment-store branch 6 times, most recently from 5421967 to c49276e Compare February 24, 2026 19:07
@andrei-21
andrei-21 marked this pull request as ready for review February 25, 2026 09:01
@andrei-21

Copy link
Copy Markdown
Collaborator Author

I implemented storing and retrieving lighting payment info and LNURL info.
(Build for iOS notification plugin fails, I will fix it meanwhile.)

@andrei-21
andrei-21 requested a review from roeierez February 25, 2026 09:03
@andrei-21
andrei-21 force-pushed the feature/payment-store branch from c49276e to 0a3f49d Compare February 25, 2026 09:08
string? lnurl_metadata;
string? ln_address;
string? lnurl_withdraw_endpoint;
LnUrlInfo? lnurl_info;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we remove now the redundant old lnurl fields from the udl?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I will remove.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment thread libs/sdk-core/src/models.rs Outdated
pub bolt11: String,
pub payment_hash: String,
pub destination_pubkey: String,
pub description: String,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be optional?

Comment thread libs/sdk-core/src/breez_services.rs Outdated
description: invoice
.description
.as_ref()
.or(invoice.description_hash.as_ref())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Aren't we mixing here description and description hash by using the same field?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I will drop description hashes then.

@JssDWt JssDWt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can/should we delete SqliteStorage now?

Comment on lines +107 to +109
for payment_id in payment_ids {
match KVStoreAsync::read(self.kv_store.as_ref(), BREEZ_NS, LNURL_INFOS_NS, payment_id)
.await

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a database roundtrip per payment. Can we do something more efficient?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes. I made the simplest implementation for now. Later we can optimize it if there is a need. What do you think?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think this is one where the need to optimize will show up as something really bad.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You suggest to do it now?
I would want to get approval for the whole concept first.

@andrei-21

Copy link
Copy Markdown
Collaborator Author

Can/should we delete SqliteStorage now?

Not yet. breez_seriveces reads payments status and so one from the SqliteStorage.

@andrei-21
andrei-21 force-pushed the feature/payment-store branch from 5d33903 to 160672e Compare February 26, 2026 10:56
@andrei-21
andrei-21 marked this pull request as draft March 9, 2026 08:28
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.

3 participants