Commit Graph

61 Commits

Author SHA1 Message Date
C
f7d9a1b5db Drop the in-memory database (#613)
* Drop the in-memory database

Fixes #607

This PR drops the implementation of in-memory database traits.

They are useful for testing purposes since the tests should test our codebase
and assume the database works as expected (although a follow-up PR should write
a sanity test suite for all database trait implementors).

As complexity is worth with database requirements to simplify complexity and
add more robustness, for instance, with the following plans to add support for
transactions or buffered writes, it would become more complex and
time-consuming to support a correct database trait. This PR drops the
implementation and replaces it with a SQLite memory instance

* Remove OnceCell<Mint>

Without this change, a single Mint is shared for all tests, and the first tests
to run and shutdown makes the other databases (not-reachable, as dropping the
tokio engine would also drop the database instance).

There is no real reason, other than perhaps performance. The mint should
perhaps run in their own tokio engine and share channels as API interfaces, or
a new instance should be created in each tests

* Fixed bug with foreign keys

[1] https://gist.github.com/crodas/bad00997c63bd5ac58db3c5bd90747ed

* Show more debug on failure

* Remove old code

* Remove old references to WalletMemoryDatabase
2025-03-04 19:44:34 +00:00
C
63393056a0 Do not use INSERT OR REPLACE in SQLite. (#620)
Instead, use `INSERT` and `ON CONFLICT`.  The reason is that in case of
conflicts, the `REPLACE` will trigger a DELETE and then perform an INSERT, as
outlined in the documentation[1], and that may cause a cascade of deletion due
to our FOREIGN KEYs.

Here is the official documentation:

```
When a UNIQUE or PRIMARY KEY constraint violation occurs, the REPLACE algorithm
deletes pre-existing rows that are causing the constraint violation prior to
inserting or updating the current row and the command continues executing
normally. If a NOT NULL constraint violation occurs, the REPLACE conflict
resolution replaces the NULL value with the default value for that column, or
if the column has no default value, then the ABORT algorithm is used. If
a CHECK constraint or foreign key constraint violation occurs, the REPLACE
conflict resolution algorithm works like ABORT.  When the REPLACE conflict
resolution strategy deletes rows in order to satisfy a constraint, delete
triggers fire if and only if recursive triggers are enabled.  The update
hook is not invoked for rows that are deleted by the REPLACE conflict
resolution strategy. Nor does REPLACE increment the change counter. The
exceptional behaviors defined in this paragraph might change in a future
release.
```

[1] https://www.sqlite.org/lang_conflict.html
2025-02-28 11:35:29 +00:00
callebtc
b818054f9a Add filtering for mint quote states in database (#586)
* filter for mint quote states in db

---------

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
2025-02-08 09:28:54 +00:00
thesimplekid
7b69aa966a feat: add remove proofs to mint db 2025-02-05 10:48:33 +00:00
thesimplekid
c455809812 refactor: move quote_ttl to database 2025-01-29 23:58:13 +00:00
thesimplekid
5481286ec9 refactor: move mint_info to database 2025-01-29 23:29:25 +00:00
thesimplekid
0674144001 refactor: remove mint url from config 2025-01-29 20:38:53 +00:00
C
8fe0982c6d Introduce cashu to host the shared types, traits and other common code (#519)
---------

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
2025-01-12 12:50:05 +00:00
thesimplekid
6a8a5a7941 fix: mpp (#523) 2025-01-05 14:42:44 +00:00
thesimplekid
003a8f1b47 feat: signature on mint witness 2024-12-23 10:25:42 -05:00
Timothée Delabrouille
7d87c4806c feat: use Uuid as mint and melt quote ids (#469) 2024-12-05 09:58:53 +00:00
thesimplekid
bc490ed208 fix(wallet): stop sqlite from overwritting keyset counter 2024-12-02 19:38:28 +00:00
Cesar Rodas
af2fe580f4 Minor improvement in the SQLite crate
This is a minor improvement over the SQLite crate, which performs fewer SQL
statements and fetches multiple results instead.

This will also remove some redundant commit() and rollback calls. Rollback
already happens on drop, and there is no need for a commit if the database
hasn't changed, as the transaction is used as a locking mechanism in this
context.
2024-11-27 08:33:16 +00:00
thesimplekid
479b4e78e5 Merge pull request #398 from prusnak/mint-info-urls
NUT-06: add urls field
2024-11-06 10:44:09 +00:00
ok300
f6533a08de Add Proofs trait to consolidate aggregate fns 2024-10-17 23:28:56 +01:00
Pavol Rusnak
b507ce7201 NUT-06: add urls field 2024-10-11 14:54:39 +02:00
thesimplekid
7ea568e615 feat: sql store signatures dleq 2024-09-30 12:20:43 +02:00
thesimplekid
ca6fdb5bff feat: return change in check quote 2024-09-30 09:47:23 +02:00
thesimplekid
5139c47dac feat: check outgoing payment status flow 2024-09-25 20:28:05 +02:00
thesimplekid
974796400d feat: get proofs for quote id 2024-09-23 14:05:28 +02:00
thesimplekid
fa8776998a feat(mint): store mint_quote_id for blind sig 2024-09-21 11:13:30 +02:00
thesimplekid
117443d126 feat: store melt_quote_id for proof 2024-09-21 11:13:30 +02:00
thesimplekid
f2867188a8 fix: sqlx sqlite settings
feat: use transactions in all sql fns
2024-09-21 11:10:38 +02:00
thesimplekid
2fdf48cc72 feat: remove mint and wallet errors 2024-09-08 11:48:52 +01:00
Pavol Rusnak
5a14ddbc67 nut06: mint_icon_url -> icon_url 2024-09-04 12:08:19 +01:00
Pavol Rusnak
e67dc15ce6 feat: implement nut-06 time 2024-09-03 17:00:57 +01:00
thesimplekid
5f87df2cef refactor: use MintUrl::from_str 2024-09-03 11:36:28 +01:00
David Caseria
d0d7281c77 Modify WalletDatabase trait to better support db transactions 2024-08-24 17:32:59 +03:00
Pavol Rusnak
9eff00bcaf fix: make capitalization of error messages consistent 2024-08-19 13:53:26 +02:00
thesimplekid
bcb4a5927d refactor: remove the use of flat maps 2024-08-17 14:35:52 +02:00
Caleb Beery
40554987e1 feat: new struct 'MintUrl' which trims trailing slashes (#283)
https://github.com/cashubtc/nuts/pull/151/files
2024-08-12 19:32:44 +00:00
thesimplekid
e57c7f1e9d chore: fix formatting 2024-08-11 10:12:21 -04:00
Caleb Beery
da1acc4e6d feat: add mint_icon_url to mint details. (#282) 2024-08-10 17:57:02 -04:00
thesimplekid
ba19663531 feat(mint): issued and redeamed by keyset 2024-07-25 08:43:14 -04:00
thesimplekid
fa3f6c4b38 chore: instrument logging on wallet db 2024-07-23 15:35:37 +01:00
thesimplekid
97fd83c8f4 feat(mint): add get blinded_sig by keyset 2024-07-22 16:43:26 +01:00
thesimplekid
a96ba31784 refactor: remove get single blinded sig 2024-07-20 10:19:12 +01:00
thesimplekid
6705761aec fix: dont update proof state if already spent 2024-07-19 00:30:59 +01:00
thesimplekid
fb014573c1 refactor: use sproof state update 2024-07-18 23:07:09 +01:00
thesimplekid
9789475686 feat: remove unused db fns 2024-07-18 23:07:09 +01:00
thesimplekid
4f240f3953 refactor(wallet/database): get_proofs returns Vec<ProofInfo> instead of Option<Vec<ProofInfo>> 2024-07-16 15:03:05 +01:00
thesimplekid
373a4203b2 refactor(cdk/cdk_database): rename add_active_keyset to set_active_keyset 2024-07-16 09:21:51 +01:00
thesimplekid
d45019ae8b refactor: add_blind_signature to add_blind_signatures 2024-07-16 01:31:35 +01:00
thesimplekid
ed007c475e refactor: get spent and pending proofs by list of secrets or ys 2024-07-16 00:40:28 +01:00
thesimplekid
920e5d1fd7 fix: set inactive keysets as inactive in sql db 2024-07-11 21:02:12 +01:00
thesimplekid
6d3200c72d feat: use derivation path by unit 2024-07-11 20:48:45 +01:00
thesimplekid
17263b07f5 feat(NUT02): add input_fee_ppk
chore: instrument log on mint fns
2024-07-11 12:22:20 +01:00
thesimplekid
011efac426 fix: request lookup migration 2024-07-10 16:12:50 +01:00
thesimplekid
8b775cb7f1 feat: wait invoice is stream of request_lookup_id 2024-07-05 23:49:31 +01:00
thesimplekid
6a315fc3b9 feat: mintd axum server
feat: deafult NUT-04 and NUT-05 settings to enable bolt11 sats
2024-07-05 23:49:31 +01:00