Commit Graph

1069 Commits

Author SHA1 Message Date
thesimplekid
2dbb418db7 feat: store melt_request (#1045) 2025-09-16 10:55:36 +01:00
gudnuf
5650050f32 fix: make http wallet subscriptions wasm compatible (#1062) 2025-09-16 09:02:31 +01:00
C
c3c8e87164 Add resolve_dns_txt to HttpTransport and MintConnector (#1068)
* Add `resolve_dns_txt` to HttpTransport and MintConnector

Fixes #1036

* Use `hickory_resolver` to resolve DNS entries

* Remote default implementation of methods

* Fix build for wasm
2025-09-16 09:01:34 +01:00
C
1cc4783198 Fixed bug with postgres reconnection in the connection pool (#1078) 2025-09-15 23:19:48 +01:00
lollerfirst
4f65441c0d chore: move pay_request logic into cdk lib (#1028)
* pay request into cdk lib
2025-09-15 19:50:08 +01:00
Erik
7d78240da5 Improve web interface with dynamic status, navigation, and mobile support (#1073)
* Improve transaction confirmation UI: reorder elements, move buttons to details card, shorten button text
* feat: real node status

---------

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
2025-09-15 14:51:23 +01:00
gudnuf
2c9333449a fix: replace std::time with instant for wasm (#1060) 2025-09-13 11:12:41 +01:00
thesimplekid
aab85d2083 feat: update redb (#1071) 2025-09-13 11:12:00 +01:00
thesimplekid
835c66dd55 fix: keyset max order checked (#1070) 2025-09-13 09:17:12 +01:00
C
0bf5325927 Fixed error with wrong placeholder (#1069)
* Fixed error with wrong placeholder

Add concept of schema, so each test is isolated
2025-09-12 17:17:40 +01:00
David Caseria
f2f5425395 Add more Amount::split_with_fee tests (#1058) 2025-09-10 14:54:44 +01:00
C
053a3a7e43 Do not fallback to HTTP on first error (#1061)
Instead use the same failure counter.

Fixes #496
2025-09-10 06:57:58 -03:00
David Caseria
21b4080810 FFI bindings for Wallet (#932)
* feat: Add initial CDK FFI bindings using UniFFI proc macros

* feat: Add complete Wallet methods to CDK FFI bindings
2025-09-10 09:56:55 +01:00
thesimplekid
64a4fe5bca feat: remove unused ln_routers (#1059)
* feat: remove unused ln_routers

* feat: allow other routers to be nested
2025-09-10 09:54:00 +01:00
thesimplekid
ce599a9e57 chore: code style (#1056) 2025-09-09 15:00:44 +01:00
asmo
75a3e6d2c7 Prometheus crate (#883)
* feat: introduce `cdk-prometheus` crate with Prometheus server and CDK-specific metrics support
2025-09-09 13:26:03 +01:00
thesimplekid
c94979a357 fix: used check math (#1051) 2025-09-09 11:26:24 +01:00
lollerfirst
b1026fb9bb fix: None host_matcher applies the proxy to all hosts (#1054)
* fix: None `host_matcher` applies the proxy to all hosts
2025-09-09 10:40:38 +01:00
C
62de0c9925 Close websocket connections sooner (#1050)
* Close websocket connections sooner

* Handle Ping,  Binary and Close
2025-09-08 21:21:13 +01:00
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