Commit Graph

860 Commits

Author SHA1 Message Date
gandlafbtc
af72d56558 fix typo in main.rs
doubble D
2025-06-01 10:42:43 +09:00
David Caseria
fe118d180f Signatory Loader (#777)
* Allow Signatory to be run with custom incoming stream

* Allow multiple signatories to be loaded on a server

* Fix merge conflict in server.rs

* Export SignatoryLoader

* Use unit error

* Use Arc instead of reference
2025-05-31 16:41:25 -04:00
David Caseria
0a832ff161 Allow Signatory to be run with custom incoming stream (#776) 2025-05-29 15:46:31 -04:00
David Caseria
98440b436c Make sqlite dependency optional for signatory (#775) 2025-05-29 12:12:27 -04:00
David Caseria
30d6b20c99 Reclaim unspent proofs by reverting transaction (#774)
* Reclaim unspent proofs by reverting transaction

* Change fn signatore to return unit
2025-05-29 12:12:10 -04:00
thesimplekid
9beb0b4256 chore: update readmes (#773) 2025-05-29 09:38:10 -04: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
David Caseria
0e250af87a Export NUT-06 supported settings field (#764)
* Export NUT-06 supported settings field

* Fix doc test
2025-05-24 05:57:36 -04:00
thesimplekid
abf10da330 chore: update deps (#761) 2025-05-20 10:27:52 +01:00
thesimplekid
b63dc1045d refactor: nut04 and nut05 (#749) 2025-05-19 09:49:11 +01:00
thesimplekid
3920c6f9bc fix: nut18 payment request encoding/decoding (#758)
* fix: nut18 payment request encoding/decoding

* refactor: reorder nut18fns

* refactor: reorder nut18
2025-05-18 10:04:02 +01:00
thesimplekid
70944500fc chore: clippy mint_url (#759) 2025-05-18 09:05:44 +01:00
thesimplekid
c001375b32 fix: mint url trailing slash (#757) 2025-05-17 20:01:16 +01:00
thesimplekid
df0de05571 fix: get spendable to return witness (#756) 2025-05-17 20:00:49 +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
9ac387ae3d Ln use common (#751)
* chore: cdk-cln use common

* feat: lnd use common

* feat: lnbits use common
2025-05-14 17:29:58 +01:00
thesimplekid
e268866446 chore: clippy (#750)
* chore: clippy

* chore: fmt
2025-05-14 15:55:37 +01:00
lollerfirst
a4c2454e94 [PATCH + BUGFIX] Multinut LND re-query and use_mission_control (#746)
* patch LND re-query and use mission control + bugfix on the melt verification

* remove unusued import

* chore: fmt

---------

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
2025-05-06 13:19:32 +01:00
thesimplekid
5a3a274875 fix: melt start up check (#745) 2025-05-06 11:33:24 +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
KnowWhoami
ffce3a8aef test: use expect/unwrap instead of anyhow 2025-05-01 03:29:43 +05:30
thesimplekid
d880bb13cc refactor: Update SupportedMethods with WsCommand enum and new constructor 2025-04-29 08:53:55 +01:00
thesimplekid
63e6a4d610 feat: use tsk testmint 2025-04-27 16:21:25 +01:00
thesimplekid
1fbb6c7aa9 fix: remove urls grpc 2025-04-23 17:05:26 +01:00
Darrell
bac711d9fd update lnbits-rs to 0.5.0 2025-04-23 16:44:59 +09:00
C
15e10c0e90 Merge pull request #730 from crodas/fix/race-condition-state-update
Fix race conditions with proof state updates.
2025-04-22 11:24:58 -04:00
Cesar Rodas
25fad98aa8 Fix formatting 2025-04-22 11:43:25 -03:00
C
5505f0b5d7 Apply suggestions from code review
Co-authored-by: thesimplekid <tsk@thesimplekid.com>
2025-04-22 09:30:21 -04:00
thesimplekid
570782e3b6 chore: clippy 2025-04-22 11:29:36 +01:00
thesimplekid
8379da2655 fix: only could sigs from unique pubkeys 2025-04-22 11:29:36 +01:00
thesimplekid
48fd3c652b test: multiple sigs 2025-04-22 11:29:36 +01:00
Cesar Rodas
81a6d68ef3 Remove wallet states from check_state_transition 2025-04-20 11:17:03 -03:00
Cesar Rodas
abdde307c6 Fix race conditions with proof state updates.
Add a strict set of updates to prevent incorrect state changes and correct
usage. Supporting the transaction at the trait level prevented some cases, but
having a strict set of state change flows is better.

This bug was found while developing the signatory. The keys are read from
memory, triggering race conditions at the database, and some `Pending` states
are selected (instead of just selecting `Unspent`).

This PR also introduces a set of generic database tests to be executed for all
database implementations, this test suite will make sure writing and
maintaining new database drivers
2025-04-19 18:15:42 -03:00
thesimplekid
717742be05 fix: debug print of info 2025-04-13 22:21:43 +01:00
thesimplekid (aider)
f5f3e50507 fix: Correct mnemonic hashing in Debug implementation 2025-04-13 22:19:41 +01:00
thesimplekid
607cdf23d4 feat: Add robust mnemonic hashing and debug tests for Info struct 2025-04-13 22:19:39 +01:00
thesimplekid
7715d45f3b Merge pull request #724 from thesimplekid/token_value_uniqe
refactor: Ensure unique proofs when calculating token value
2025-04-11 10:03:57 +01:00
thesimplekid (aider)
3b5c8b5c5e refactor: Ensure unique proofs when calculating token value 2025-04-10 23:21:58 +01:00
thesimplekid
0d512c1d15 feat: mint should not enforce expiry 2025-04-10 22:59:49 +01:00
lollerfirst
dafdf757af CORS Headers in Responses (#719)
* access control headers for CORS request from in-browser wallets

* cargo fmt

* handle preflight requests
2025-04-10 13:47:35 +01:00
thesimplekid
db067a145d docs: Add README.md for cdk-mint-rpc crate (#717)
* docs: Add README.md for cdk-mint-rpc crate

* docs: auth readme
2025-04-09 15:29:03 +01:00
thesimplekid
f44f79d3e0 fix: grpc set mint urls, updating description and add get quote ttl (#716)
* fix: grpc set mint urls

* refactor: Extract payment processor retrieval into helper method

* fix: only allow updates to nut04/05 where there is a backend

* feat: Add GetQuoteTtl RPC method to retrieve quote TTL settings

* fix: update long desctiption
2025-04-09 15:28:25 +01:00
thesimplekid
e883d2d684 fix: amountless setting 2025-04-08 10:23:42 +01:00
David Caseria
3514f362eb Export MintDatabase traits in the cdk crate 2025-04-07 12:45:02 -04:00
thesimplekid
0b9ca1a474 Time time series (#708)
* feat: Add created_time and paid_time fields to MintQuote struct

* feat: Add serde default of 0 for created_time in MintQuote

* feat: Add created_time and paid_time to MintQuote and MeltQuote structs

* feat: Add paid_time update when setting melt quote state to Paid

* fix: Update melt quote state with current Unix timestamp

* feat: Add paid_time update for mint quote when state is set to Paid

* feat: Add issued_time field to MintQuote conversion from SQLite row

* feat: Add issued_time tracking for MintQuoteState::Issued state

* feat: Add migration script for mint time of quotes

* feat: Add timestamp columns to mint_quote and melt_quote tables

* feat: Add timestamp columns to `add_mint_quote` method

* refactor: Improve code formatting and readability in mint quote state update logic

* feat: Add created_time and paid_time columns to melt_quote query

* feat: time on mint and melt quotes

* feat: Add migration script for mint created time signature

feat: Add created_time column to blind_signature table

feat: Add created_time to blind_signature insertion

feat: Add created_time column to proof table and update insert query

feat: time on mint and melt quotes

* feat: Add new table to track blind signature creation time

* feat: Add timestamp tracking for proofs in ReDB database

* feat: redb proof time

* chore: fmt
2025-04-07 12:51:14 +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