Commit Graph

1037 Commits

Author SHA1 Message Date
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
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
thesimplekid
d3a3c30d99 feat(cdk): add Bolt12 mint quote subscription support (#976)
* feat(cdk): add Bolt12 mint quote subscription support

Extends subscription to handle Bolt12 payment method alongside existing Bolt11 support across wallet, mint, and CLI components.
2025-08-19 12:01:01 +01:00
C
28a01398fd Add PostgreSQL support for mint and wallet (#878)
* Add PostgreSQL support for mint and wallet

* Fixed bug to avoid empty calls `get_proofs_states`

* Fixed SQL bug

* Avoid redudant clone()

* Add more tests for the storage layer

* Minor enhacements

* Add a generic function to execute db operations

This function would log slow operations and log errors

* Provision a postgres db for tests

* Update deps for msrv

* Add postgres to pipeline

* feat: add psgl to example and docker

* feat: db url fmt

---------

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
2025-08-18 17:45:11 +01:00
thesimplekid
2e424e629f feat: uuid version (#891)
* feat: uuid version

* feat: rustls version
2025-08-18 16:25:24 +01:00
thesimplekid
0a8a0a6ea5 Repay fake queue (#973)
* feat: implement secondary repayment queue for any-amount invoices

- Keep original immediate payment behavior for ALL invoices (fixed and any-amount)
- Add secondary repayment queue that randomly repays any-amount invoices again
- Secondary repayments occur at random intervals between 30 seconds and 3 minutes
- Only any-amount invoices (amount=0) are added to secondary repayment queue
- Each any-amount invoice gets paid twice: once immediately, once from secondary queue
- Queue has configurable max size with LRU eviction policy
- Add comprehensive tests and update documentation

* test: add test for multiple payment verification

- Add test to verify that secondary repayment system creates multiple payments
- Test checks that immediate payment is received first
- Demonstrates the dual payment system working correctly
2025-08-18 16:17:57 +01:00
thesimplekid
22926f8b21 fix: bolt12 ws on mint (#972)
* fix: bolt12 ws on mint

* fix: bolt12 ws on mint
2025-08-18 14:46:18 +01:00
C
f8d58e419f Merge pull request #963 from crodas/feature/wait-for-invoice
Add `wait_for_payment` function in the wallet
2025-08-18 12:57:45 +01:00
thesimplekid
5ef2be36f2 feat(cdk): allow minting less than paid amount for non-bolt11 payments
For bolt11 payments, enforce exact amount matching between outputs and quote.
For other payment methods, allow minting less than paid amount while preventing overspending.
2025-08-18 11:34:53 +01:00
thesimplekid
0e15904b2f Merge pull request #968 from thesimplekid/remove_unwrap_from_startup
fix: remove unwrap in startup check
2025-08-16 10:43:16 +01:00
thesimplekid
43a13878b1 fix: remove unwrap in startup check 2025-08-15 17:59:23 +01:00
thesimplekid
3104a999e9 Merge pull request #944 from vnprc/keyset_counter_atomic_increment_2
fix: implement atomic keyset counter
2025-08-15 15:43:29 +01:00
thesimplekid
b885c8d78e feat: fake mint bolt12 2025-08-15 12:23:02 +01:00
vnprc
5b30ca546d fix: implement atomic keyset counter
- remove get_keyset_counter
- update increment_keyset_counter to atomically increment and return counter value
- replace get+increment pattern with atomic increment everywhere
2025-08-15 11:50:33 +01:00
thesimplekid
51b26eae62 chore: clippy 2025-08-15 11:49:38 +01:00