Commit Graph

1050 Commits

Author SHA1 Message Date
thesimplekid
166b902833 feat: bolt12 ws (#1052) 2025-09-08 21:20:52 +01:00
C
841e35d70f Reorganize tests, add mint quote/payment coverage, and prevent over-issuing (#1048)
* Add consistent ordering of sql migrations

Also sort the prefix and not only the filenames

* Reorganize tests, add mint quote/payment coverage, and prevent over-issuing

Reorganizes the mint test suite into clear modules, adds comprehensive mint
quote & payment scenarios, enhances the shared test macro, and hardens SQL
logic to forbid issuing more than what’s been paid.

These tests were added:

* Add quote once; reject duplicates.
* Register multiple payments and verify aggregated amount_paid.
* Read parity between DB and in-TX views.
* Reject duplicate payment_id in same and different transactions.
* Reject over-issuing (same TX, different TX, with/without prior payments).

---------

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
2025-09-08 14:55:41 +01:00
C
b5b8ee557c Fix race conditions in minting tests (#1043)
There was a race conditions between the database storing the mint quote and the
fake wallet paying the invoice of a yet not existing mint quote

Add a delay of seconds before paying all invoices

To recreate the slow conditions that would make our database slower than the
external Fakewallet in Linux

```
sudo tc qdisc add dev lo root netem delay 200ms 50ms
ionice -c3  nix develop -i -L .#stable --command just itest-payment-processor FAKEWALLET
```

To reset

```
sudo tc qdisc del dev lo root

```
2025-09-08 13:02:45 +01:00
C
4363d14281 Add consistent ordering of sql migrations (#1047)
Also sort the prefix and not only the filenames
2025-09-08 10:17:00 +01:00
thesimplekid
caa0b4a9f5 fix: remove unused structs (#1042) 2025-09-07 08:17:48 +01:00
thesimplekid
5518ad2654 feat(cdk): add quote_id field to transactions for quote tracking (#1041)
- Add quote_id field to Transaction struct in cdk-common
- Add database migrations for quote_id column in SQLite and PostgreSQL
- Update wallet operations to populate quote_id for mint/melt transactions
- Set quote_id to None for send/receive operations without associated quotes
2025-09-06 19:57:23 +01:00
thesimplekid
9b35158a8a fix: sig error code (#1038) 2025-09-06 16:04:29 +01:00
C
ded165f405 Update the signatory.proto file to match NUT-XXX (#1032)
* Update the signatory.proto file to match NUT-XXX

Source: https://github.com/cashubtc/nuts/pull/250/files

* Add unit tests as requested in https://github.com/cashubtc/cdk/pull/1032#discussion_r2321436860

* Remove unused types from proto file
2025-09-05 19:07:04 -03:00
C
3815c62d88 Fix postgres migration prefixes (#1037)
* Fix migrations ordering

1. Fix postgres migration prefixes for unreleased migrations
2. Fix build script to try to sort, if provided, the filename prefix as a
   number, otherwise fallback to the sorting by filename as string

* Fixed clippy issues
2025-09-05 14:39:54 -03:00
thesimplekid
c6cff3f6f4 feat(cdk): add generic key-value store functionality for mint databases (#1022)
* feat(cdk): add generic key-value store functionality for mint databases

Implements a comprehensive KV store system with transaction support,
namespace-based organization, and validation for mint databases.

- Add KVStoreDatabase and KVStoreTransaction traits for generic storage
- Include namespace and key validation with ASCII character restrictions
- Add database migrations for kv_store table in SQLite and PostgreSQL
- Implement comprehensive test suite for KV store functionality
- Integrate KV store traits into existing Database and Transaction bounds
2025-09-05 13:58:48 +01:00
C
8cf3b2d992 Merge branch 'main' into main 2025-09-04 11:58:01 -03:00
Erik
39f256a648 cdk-ldk web ui updates (#1027) 2025-09-03 15:46:49 +01:00
thesimplekid
734e62b04a refactor: use quote id to string (#1026) 2025-09-02 10:47:26 +01:00
thesimplekid
dca48f4886 fix: get all mint quotes (#1025) 2025-09-02 09:14:39 +01:00
C
655a4b9e1e Add suport for Bolt12 notifications for HTTP subscription (#1007)
* Add suport for Bolt12 notifications for HTTP subscription

This commit adds support for Mint Bolt12 Notifications for HTTP when Mint does
not support WebSocket or the wallet decides not to use it, and falls back to
HTTP.

This PR fixes #992
2025-09-02 09:12:54 +01:00
C
62f085b350 Fix missed events race when creating subscriptions (#1023)
Previously, we fetched the initial state *before* registering the new
subscription. Any events emitted after the DB read but before the
subscription was installed were dropped—most visible under
low-resource conditions (e.g., CI).

Change:
- Register the subscription first, then asynchronously fetch and send
  the initial state (spawned task). This eliminates the window where
  events could be missed.
- Require `F: Send + Sync` and store `on_new_subscription` as `Arc<F>`
  so it can be safely used from the spawned task.

Result:
- No gap between “subscribe” and “start receiving,” avoiding lost events.
- Initial state still delivered, now via a background task.
2025-09-01 20:24:50 +01:00
thesimplekid
6067242793 fix: cdk melt quote track payment method (#1021)
Add payment_method field to MeltQuote struct to track whether quotes use BOLT11 or BOLT12 payment methods. Include database migrations for both SQLite and PostgreSQL to support the new field. Update melt operations to set and use the payment method for proper routing between BOLT11 and BOLT12 endpoints.
2025-09-01 08:39:51 +01:00
thesimplekid
7246ea2e10 fix: bolt12 is nut25 (#1020) 2025-08-31 23:05:24 +01:00
thesimplekid
7a71a37eab refactor(payment): replace wait_any_incoming_payment with event-based system (#1019)
Rename wait_any_incoming_payment to wait_payment_event and change return type
from WaitPaymentResponse stream to Event stream. This introduces a new Event
enum that wraps payment responses, making the system more extensible for
future event types.

- Add Event enum with PaymentReceived variant
- Update MintPayment trait method signature
- Refactor all payment backend implementations (LND, CLN, LNBits, fake wallet)
- Update mint and payment processor to handle new event stream forma
2025-08-31 17:26:50 +01:00
C
2131f89068 Abstract the HTTP Transport (#1012)
* Abstract the HTTP Transport

This PR allows replacing the HTTP transport layer with another library,
allowing wallet ffi to provide a better-suited HTTP library that would be used
instead of Reqwest.
2025-08-30 08:54:48 +01:00
C
14473d8051 Merge pull request #1002 from asmogo/fix/psql_tls
feat: add TLS support for PostgreSQL connections
2025-08-29 16:03:57 -03:00
thesimplekid
7a22f85185 chore: remove readme postgres (#1009)
* chore: remove readme postgres
2025-08-29 10:37:32 +01:00
lollerfirst
7995a93943 patch sha256 (#1013) 2025-08-29 10:37:01 +01:00
Darrell
a62decfc24 add pubkey to mint info if not set 2025-08-29 15:23:51 +09:00
lollerfirst
f1118b1c7b compatibility for migrating Nutshell Mints quote ids (#984) 2025-08-27 17:12:35 +01:00
codingpeanut157
971957b839 replace transports: Option<Vec<Transport>> with just Vec<Transport> (#999)
with a few serde directive we can get the same behaviour we had with
Option<Vec<Transport>> but only using Vec<Transport>

No need to change protocol specification
2025-08-27 15:21:22 +01:00
asmo
6454a33509 chore: remove unused native_tls import from cdk-postgres 2025-08-27 15:15:16 +02:00
asmo
cb29e74e39 feat: add TLS support for PostgreSQL connections with configurable SSL modes 2025-08-26 21:27:25 +02:00
C
218b39a670 Introduce Future Streams for Payments and Minting Proofs (#985)
* Introduce Future Streams for Payments and Minting Proofs

Introduce Future Streams (`ProofStream`, `PaymentStream`) for Payments and
Proofs, an easier to use interface, async friendly, to interact for the mint
waiting for payments of mints for Bolt11 and Bolt12.

---------

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
2025-08-26 11:57:15 +01:00
thesimplekid
809d9c8012 Fix p2pk (#996)
* fix: refund keys must sign after locktime

* fix: custom tags

* refactor: locktime verification and refund
2025-08-26 06:29:20 +01:00
thesimplekid
9ab86fabfe Cdk ldk node (#904)
* feat: add LDK Node Lightning backend with comprehensive integration

- Add new cdk-ldk-node crate implementing Lightning backend using LDK Node
- Extend MintPayment trait with start/stop methods for processor lifecycle management
- Add LDK Node configuration support to cdk-mintd with chain source and gossip options
- Enhance mint startup/shutdown to properly manage payment processor lifecycle

---------

Co-authored-by: Erik <78821053+swedishfrenchpress@users.noreply.github.com>
2025-08-25 22:06:00 +01:00
lollerfirst
ea9b9324f6 fix left-over y in blind_signatures table auth database 2025-08-22 13:10:43 +02:00
thesimplekid
6f25620f06 feat: mintd db features (#977) 2025-08-21 22:41:46 +01:00
thesimplekid
8dec41dd55 refactor(cdk-lnbits): migrate to LNbits v1 websocket API and remove w… (#987)
* refactor(cdk-lnbits): migrate to LNbits v1 websocket API and remove webhook support

- Remove webhook-based payment notifications in favor of v1 websocket API
- Add explicit documentation that only LNbits v1 API is supported
- Remove webhook_url parameter and related router setup code
- Simplify payment status handling by removing pending status logic
- Switch to local lnbits-rs dependency for development
- Remove unused axum dependency and clean up imports
- Update configuration documentation and examples

* refactor(cdk-lnbits): extract payment processing logic into helper methods

Improve code readability by separating message processing, payment response
creation, and payment hash decoding into dedicated methods. This reduces
complexity in the main payment waiting loop while maintaining identical
functionality

* chore: bump lnbits-rs
2025-08-21 21:54:48 +01:00
thesimplekid
7e33078961 Merge pull request #988 from vnprc/zeroize_on_drop
feat: zeroize cryptographic secrets on drop
2025-08-21 21:53:26 +01:00
Cesar Rodas
9b5f8d0534 Fixed bolt12 missing payments notifications 2025-08-21 15:26:08 -03:00
vnprc
951ff054fb feat: zeroize cryptographic secrets on drop
implement zeroize on Drop for Secret, Wallet, and MultiMintWallet
this erases sensitive memory addresses before deallocation
2025-08-21 11:26:52 -04:00
thesimplekid
4e13c1958f feat: mintd db features 2025-08-21 16:20:30 +01:00
thesimplekid
9a3d9b7139 feat: bip353 (#969) 2025-08-21 16:16:48 +01:00
thesimplekid
b6f7a75fba feat: cln as msats (#982)
* feat: cln as msats

* fix(logging): correct bolt12 payment amount units and reduce log noise

- Fix CLN bolt12 payment logging to display msats instead of sats
- Add tower_http filter to reduce integration test log verbosity
- Use correct payment amount variable in mint quote pubsub notifications
2025-08-21 16:13:06 +01:00
gudnuf
a4aaef705e fix: pass auth cfg through mintd to axum (#986) 2025-08-21 09:55:32 +01:00
thesimplekid
aa624d3afd fix: lnbits payment check and units (#981)
* fix: lnbits payment check and units

---------

Co-authored-by: asmo <asmogo@protonmail.com>
2025-08-20 18:01:46 +01:00
asmo
818367a8fa fix: reduce mmap_size to 5 MiB (#980) 2025-08-20 17:29:44 +01:00
thesimplekid
ecdc78135d refactor(cdk): defer BOLT12 invoice fetching to payment execution (#978)
* refactor(cdk): defer BOLT12 invoice fetching to payment execution

Move BOLT12 invoice generation from quote creation to payment time, make
request_lookup_id optional for offers, and simplify payment structures by
removing unnecessary boxing and intermediate storage of invoices.
2025-08-20 11:20:30 +01:00
thesimplekid
5c5075af71 feat: refresh keysets (#974)
* feat: refresh keysets

* feat: rename get_mint_info to fetch_mint_info
2025-08-19 19:19:08 +01:00
C
86d51ed54d Merge pull request #975 from crodas/bug/939-retry
Http retry should only happen at Http Error (which are transport errors)
2025-08-19 12:46:32 -03:00
thesimplekid
761ed82554 feat: log to file (#967) 2025-08-19 14:57:14 +01:00
Cesar Rodas
2e63a631e4 Fixed clippy 2025-08-19 10:38:08 -03:00
C
e31a9b1905 Update crates/cdk/src/wallet/mint_connector/http_client.rs
Co-authored-by: thesimplekid <tsk@thesimplekid.com>
2025-08-19 10:38:08 -03:00
Cesar Rodas
29ce2e4f4d Http retry should only happen at Http Error (which are transport errors)
Fixes #939
2025-08-19 10:38:03 -03:00