rust-payjoin icon indicating copy to clipboard operation
rust-payjoin copied to clipboard

Persist data in default directory

Open DanGould opened this issue 2 years ago • 7 comments

Use directories crate to persist config.toml and potentially the DB for #63 in a standard location. Handle situation where more than one app is run

DanGould avatar May 06 '23 16:05 DanGould

You mean dirs? I think this should be optional and consumers should be able to plug their own db.

Kixunil avatar May 10 '23 21:05 Kixunil

I meant directories based on bitmask's config setup suggestion from @cryptoquick.

twas past my bedtime when I drafted the atrocity of the original issue text

DanGould avatar May 10 '23 22:05 DanGould

Ah, OK, dirs is almost the same and should be sufficient but I may be missing something. But thinking about it more this makes less and less sense.

  • Needs to have a unique name to not collide with other stuff
  • What if the consumer already uses a db? This would add another dependency.
  • Needs to also accept project name
  • Might need to create the directory but so may the rest of the application and perhaps it will want to set some permissions or detect first-run situation.
  • Generally feels out-of scope

Kixunil avatar May 10 '23 22:05 Kixunil

I think two things are being conflated

  1. the topic of this issue data persistence / configuration folder for payjoin-cli. This could go in a .payjoin folder at the default app location. Right now the config file is called from wherever the binary is invoked. An alternative could be to pass config path via cli.
  2. A receiver saving inputs that have been seen. Right now this is done KISS by serializing a HashSet to a file called inputs_seen.json again, wherever the binary is invoked. Uri already uses serde, and I don't see that dependency as additional or going anywhere anytime soon.

Having a proper DB would definitely be better, but I don't want to overoptimize before user demand. In the worst case we could migrate the HashSet to a more robust / performant DB later. This issue is separate to the one of keeping data organized in a payjoin-cli specific data folder

DanGould avatar May 11 '23 15:05 DanGould

Ah, this is about cli, not library, it makes sense then. Originally CLI was intended as PoC but it could be nice to develop it further. In that case I totally agree it should be stored in a DB. I have experience with rusqlite which works fine but has a bit annoying MSRV.

Kixunil avatar May 11 '23 18:05 Kixunil

This was closed by https://github.com/payjoin/rust-payjoin/pull/281/files which added a proper DB and the option to set a custom DB path as an option.

spacebear21 avatar Oct 24 '24 20:10 spacebear21

My concern with this issue is when people cargo install payjoin-cli the behavior changes depending on which directory they call the program in. Using a default directory and only using an alternative with a manual configuration argument would fix this problem

DanGould avatar Oct 25 '24 17:10 DanGould