busyboredom / acceptxmr

A monero payment gateway library
Apache License 2.0
72 stars 5 forks source link

Open payments do not stay after server restart #53

Closed ogcatt closed 1 year ago

ogcatt commented 1 year ago

Do I need to create a custom storage (in the build function) to make invoices persistant? Or is it a misconfiguration? Thanks.

busyboredom commented 1 year ago

Hey, any of the built-in storage options other than InMemory should be persistent. Are you using InMemory?

If you are using InMemory, could you try with the Sqlite store and let me know if that fixes your issue?

For example, let store = Sqlite::new("./AcceptXMR_DB", "invoices").unwrap();. It will use the db file at that path, or it will create one if it doesn't exist. Then use it in the payment gateway builder. You will need to add the Sqlite feature in Cargo.toml for it to compile.

busyboredom commented 1 year ago

Added an example here: https://github.com/busyboredom/acceptxmr/blob/dc4d1acb9e82c7276aacb1ed54413695ee459acb/examples/persistence/main.rs

ogcatt commented 1 year ago

I will try to use the Sqlite store and I will let you know how it goes. I am using InMemory btw.

ogcatt commented 1 year ago

I am getting a dependency conflict because I am using seaorm which requires libsqlite3-sys v0.24.2, but acceptxmr requires sqlite3-sys v0.14.0... I am not sure how to fix this 😔

busyboredom commented 1 year ago

Got it, yeah that was your problem then. InMemory means stored in RAM, so it's not persistent.

~Hmm, yep looks the sqlite crate used by AcceptXMR hasn't kept their sqlite3-sys dependency up-to-date... that's not very cool, I'll see about fixing that.~ Edit: Looks like it's up-to-date, it's just using a separate sys crate. I will consider changing acceptxmr to use sqlx or similar libsqlite3-sys based crate since that seems more popular now, but it probably won't happen in very the near term.

Your options in the meantime:

ogcatt commented 1 year ago

Thank you very much for this suggestion, I am using sled for acceptxmr now and it is persistent! Btw nice work with this crate, I may be one of the first to dev an ecommerce store with it :) much love 😊