Commit Graph

116 Commits

Author SHA1 Message Date
thesimplekid
5d98fdf353 Keyset counter (#950)
* feat: refresh keysets

* fix(cdk): resolve keyset counter skipping index 0 in deterministic secret generation

- Modified Database::get_keyset_counter to return u32 instead of Option<u32>
- Added database migrations to increment existing keyset counters by 1
- Removed counter increment logic from wallet operations to use actual counter value
- Ensures deterministic secret generation starts from index 0 instead of skipping it
2025-08-13 08:54:45 +01:00
lollerfirst
92eea181fd new secret derivation
Wallet holds `seed` instead of `xpriv`

fix doctest  errors

update examples

adjustments

fix doctests

fix all doctests

Update crates/cdk/src/wallet/multi_mint_wallet.rs

Co-authored-by: thesimplekid <tsk@thesimplekid.com>

fix

remove clone call
2025-08-02 19:36:20 +02:00
David Caseria
6ebcbba0c4 refactor: update send functionality across wallet components (#925)
* refactor: update send functionality across wallet components

---------
Co-authored-by: thesimplekid <tsk@thesimplekid.com>
2025-07-30 23:37:41 -04:00
Cesar Rodas
349c773406 Introduce cdk-sql-common
The primary purpose of this new crate is to have a common and shared codebase
for all SQL storage systems. It would force us to write standard SQL using best
practices for all databases.

This crate has been extracted from #878
2025-07-29 11:31:23 -03:00
thesimplekid
d2e9f1a626 Merge pull request #901 from thesimplekid/refresh_keys
feat: refactor wallet keyset management for better clarity
2025-07-23 20:49:42 +01:00
David Caseria
f018465aa6 Refactor MintBuilder (#887)
* Refactor MintBuilder
* Validate azp instead of aud for client id
2025-07-19 18:13:11 +02:00
thesimplekid
ae6c107809 feat: bolt12 2025-07-13 18:48:35 +01:00
thesimplekid
b4728d7257 feat: refund multi sig 2025-06-28 12:09:33 +01:00
C
238b09d56a Split the database trait into read and transactions. (#826)
* Split the database trait into read and transactions.

The transaction traits will encapsulate all database changes and also expect
READ-and-lock operations to read and lock records from the database for
exclusive access, thereby avoiding race conditions.

The Transaction trait expects a `rollback` operation on Drop unless the
transaction has been committed.

* fix: melt quote duplicate error

This change stops a second melt quote from being created
if there is an existing valid melt quote for an invoice already.
If the first melt quote has expired then we allow for a new melt quote to be created.

---------

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
2025-06-28 12:07:47 +01:00
thesimplekid
ae84c61a03 fix: cdk-cli create wallets for units mint supports 2025-06-25 19:45:20 +01:00
thesimplekid
dbadfc35b8 Revert "fix: creating auth keyset when auth disabled" 2025-06-24 13:34:28 +01:00
thesimplekid
cbb2d5f802 fix: creating auth keyset when auth disabled 2025-06-20 13:47:20 +01:00
lollerfirst
c61fd3830a Keysets V2 (#702)
---------
Co-authored-by: thesimplekid <tsk@thesimplekid.com>
2025-06-19 15:36:16 +01:00
thesimplekid
56b0d087db chore: cdk-cli version 2025-06-15 11:02:46 +01:00
thesimplekid
21a5ac9406 feat(cli): enhance check-pending to reclaim proofs (#795)
* feat(cli): enhance check-pending to reclaim proofs

The check-pending command now directly attempts to reclaim proofs that
are no longer pending, replacing the previous check-only behavior.

Changes:
- Replace check_all_pending_proofs with reclaim_unspent functionality
- Add more detailed feedback about pending proof status
- Update command description to reflect new reclaim behavior
- Improve error handling and status reporting

This change makes the command more useful by actively reclaiming
proofs rather than just checking their status.

* refactor: remove CheckSpendable command and check_spent module

The CheckSpendable command and its associated check_spent.rs module have been
removed as their functionality is redundant with the CheckPending command.
2025-06-07 17:23:00 +01:00
C
ade48cd8a9 Introduce a SignatoryManager service. (#509)
* WIP: Introduce a SignatoryManager service.

The SignatoryManager manager provides an API to interact with keysets, private
keys, and all key-related operations, offering segregation between the mint and
the most sensible part of the mind: the private keys.

Although the default signatory runs in memory, it is completely isolated from
the rest of the system and can only be communicated through the interface
offered by the signatory manager. Only messages can be sent from the mintd to
the Signatory trait through the Signatory Manager.

This pull request sets the foundation for eventually being able to run the
Signatory and all the key-related operations in a separate service, possibly in
a foreign service, to offload risks, as described in #476.

The Signatory manager is concurrent and deferred any mechanism needed to handle
concurrency to the Signatory trait.

* Fixed missing default feature for signatory

* Do not read keys from the DB

* Removed KeysDatabase Trait from MintDatabase

All Keys operations should be done through the signatory

* Make sure signatory has all the keys in memory

Drop also foreign constraints on sqlite

* Fix race condition

* Adding debug info to failing test

* Add `sleep` in test

* Fixed issue with active auth keyset

* Fixed dependency

* Move all keys and keysets to an ArcSwap.

Since the keys and keysets exist in RAM, most wrapping functions are infallible
and synchronous, improving performance and adding breaking API changes.

The signatory will provide this information on the boot and update when the
`rotate_keyset` is executed.

Todo: Implement a subscription key to reload the keys when the GRPC server
changes the keys. For the embedded mode, that makes no sense since there is a
single way to rotate keys, and that bit is already covered.

* Implementing https://github.com/cashubtc/nuts/pull/250

* Add CLI for cdk-signatory to spawn an external signatory

Add to the pipeline the external signatory

* Update tests

* Apply suggestions from code review

Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
Co-authored-by: thesimplekid <tsk@thesimplekid.com>

* Minor change

* Update proto buf to use the newest format

* Rename binary

* Add instrumentations

* Add more comments

* Use a single database for the signatory

Store all keys, even auth keys, in a single database. Leave the MintAuthDatabse
trait implementation for the CDK but not the signagtory

This commit also moves the cli mod to its own file

* Update dep

* Add `test_mint_keyset_gen` test

---------

Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
Co-authored-by: thesimplekid <tsk@thesimplekid.com>
2025-05-28 11:43:30 -04:00
thesimplekid
de5f9111e1 feat: mint url flag (#765) 2025-05-24 07:17:06 -04:00
thesimplekid
abf10da330 chore: update deps (#761) 2025-05-20 10:27:52 +01:00
thesimplekid
70944500fc chore: clippy mint_url (#759) 2025-05-18 09:05:44 +01:00
thesimplekid
67342ec793 feat: htlc from hash (#753)
* feat: htlc from hash

* chore: typos
2025-05-17 14:21:49 +01:00
thesimplekid
385ec4d295 feat: optional transport and nut10 secret on payment request (#744)
* feat: optional transport on payment request

* feat: create token for payment rquest

* feat: create payment request

* feat: arg append
2025-05-15 09:06:10 +01:00
thesimplekid
e268866446 chore: clippy (#750)
* chore: clippy

* chore: fmt
2025-05-14 15:55:37 +01:00
thesimplekid
34eb10fd9e Mpp cdk cli (#743)
* refactor: Extract user input logic into a helper function

* feat: get multiple quotes (hacky)

* refactor: cdk-cli

* refactor: cdk-cli

* feat: refactor balances
2025-05-05 08:41:54 +01:00
C
43ab1fdde1 Do not create the wallet struct directly; instead, call new. (#707)
The bug comes with the SQLx-sqlite pool bug, where several connections are
created by default, but the `new` function takes care of that, fixing that bug
by making a single instance of the database.

If constructed directly, the pool would create several connections to the
database, which in most instances is fine, but with SQLite :memory: each
connection is entirely independent.

Also follow documentation to make sure that failed `acquire` will not end up
dropping connections by setting  test_before_acquire to false

     However, if your workload is sensitive to dropped connections such as using an in-memory
     SQLite database with a pool size of 1, you can pretty easily ensure that a cancelled
     `acquire()` call will never drop connections by tweaking your [`PoolOptions`]:

     * Set [`test_before_acquire(false)`][PoolOptions::test_before_acquire]
     * Never set [`before_acquire`][PoolOptions::before_acquire] or
       [`after_connect`][PoolOptions::after_connect].
2025-04-06 07:13:14 +01:00
thesimplekid
d224cc57b5 Melt to amountless invoice (#497)
* feat: melt token with amountless

* fix: docs

* fix: extra migration
2025-04-04 13:16:27 +01:00
thesimplekid
71bfe1ff9c fix: mint pending get mint info to create auth wallet 2025-04-03 13:19:39 +01:00
David Caseria
b1dd321f0a Add transactions to database (#686) 2025-04-03 11:37:43 +01:00
ok300
de4285bd9c Simplify MultiMintWallet interface (#664) 2025-03-26 15:55:57 +00:00
thesimplekid
7b4951041e Rust docs (#681) 2025-03-25 23:27:38 +00:00
thesimplekid (aider)
7a9faec984 feat: Add optional redb feature flag for database support 2025-03-24 22:31:14 +00:00
thesimplekid
c63fc02a5a Prepare v0.8.0 (#672)
* chore: Bump cdk dependency to v0.8.0

* chore: add docker publish to ci

* chore: add doc test build to ci
2025-03-24 18:40:08 +00:00
thesimplekid
be93ff2384 Clear and Blind Auth (#510)
* feat: auth

* chore: corret error codes

* chore: corret error codes

* fix: feature auth in cdk-axum

* refactor: auth logging

* feat: include dleq in auth proof

* feat: mint max auth proofs

* chore: clippy
2025-03-24 11:13:22 +00:00
David Caseria
db1db86509 Prepared Send (#596)
Co-authored-by: thesimplekid <tsk@thesimplekid.com>
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
2025-03-20 11:44:44 +00:00
TechVest
c5284b889f chore: remove redundant words in comment
Signed-off-by: TechVest <techdashen@qq.com>
2025-03-10 22:33:22 +08:00
thesimplekid (aider)
cb87fefacd refactor: Remove nostr last checked methods from database trait and implementations 2025-03-09 23:11:02 +00:00
benthecarman
40c53e83df feat: Add support for sqlcipher 2025-03-09 15:08:43 -05:00
thesimplekid
e84d6ea7ab chore: Update rust-version (MSRV) to 1.75.0 (#623) 2025-03-05 10:32:41 +00:00
thesimplekid
062d7be58f chore: pin base64ct as newer version is unsuported on stable 2025-02-26 10:57:15 +00:00
thesimplekid
7b7def17ee chore: release v0.7.1 2025-02-13 10:44:09 +00:00
thesimplekid
0be37aa9e2 chore: cdk-cli rand feature 2025-02-06 13:51:02 +00:00
thesimplekid
be5e5d2371 chore: prepare v0.7.0 2025-02-06 13:12:16 +00:00
thesimplekid
47ee54d7f5 feat: mint management rpc server and client cli 2025-02-06 12:05:13 +00:00
thesimplekid
8f5764aad2 feat: restart minting in cdk-cli with quote id 2025-02-06 10:46:18 +00:00
ok300
fe223c4ce6 Remove dependency on rand 2025-01-24 16:46:59 +01: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
David Caseria
d6b7d49ea9 Return proofs for wallet mint function (#520)
* chore: update flake

---------

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
2025-01-03 13:23:52 +00:00
thesimplekid
0e12314643 chore: Release 0.6.0 2024-12-17 08:18:32 -05:00
Cesar Rodas
760564cee0 Introduce subscription support in the Wallet crate.
The main goal is to add a subscription to CDK Mint updates into the wallet.
This feature will be particularly useful for improving the code whenever loops
hit the mint server to check status changes.

The goal is to add an easy-to-use interface that will hide the fact that we're
connecting to WebSocket and subscribing to events. This will also hide the fact
that the CDK-mint server may not support WebSocket updates.

To be fully backward compatible, the HttpClientMethods traits have a new
method, `subscribe,` which will return an object that implements
`ActiveSubscription.`

In the primary implementation, there is a `SubscriptionClient` that will
attempt to connect through WebSocket and will fall to the HTTP-status pull and
sleep approach (the current approach), but upper stream code will receive
updates as if they come from a stream of updates through WebSocket. This
`SubscriptionClient` struct will also manage reconnections to WebSockets (with
automatic resubscriptions) and all the low-level stuff, providing an
easy-to-use interface and leaving the upper-level code with a nice interface
that is hard to misuse. When `ActiveSubscription` is dropped, it will
automatically unsubscribe.

Fixed bug with Default as described in https://github.com/cashubtc/cdk/pull/473#discussion_r1871032297
2024-12-08 16:25:00 +00:00
ok300
86c4c2dfeb Add support for pure integration tests (#458)
* Embed mint_url as a field of HttpClient

* Create pure integration tests

* DirectMintConnection: convert between String and Uuid
2024-12-08 14:33:58 +00:00