Commit Graph

986 Commits

Author SHA1 Message Date
callebtc
651b511293 handle USDT fees (#829) 2025-11-19 12:48:52 +01:00
callebtc
37446fbeea Fix blind message already signed error (#828)
* get unsigned blinded messages for output duplicate check

* bm regression tests (#827)

* fix last entry

* test for error from error struct

* rename tests, fix second regression test, add descriptive comments.

* check for error message

* one more test

---------

Co-authored-by: lollerfirst <43107113+lollerfirst@users.noreply.github.com>
Co-authored-by: lollerfirst <lollerfirst@gmail.com>
2025-11-19 12:21:07 +01:00
lollerfirst
0041e3a6f2 remove 5 seconds timeout (#819) 2025-11-04 23:52:18 +01:00
callebtc
cf4cbbe882 Mint: migration to clean up overly large witnesses (#817)
* add migration to clean up overly large witnesses

* bump to 0.18.1
2025-11-04 19:39:16 +01:00
callebtc
c8566437f9 bump to 0.18.0 (#812) 2025-10-28 12:48:36 +01:00
lollerfirst
4a4b7f79f7 fix: unique ('PENDING', checking_ID) for melt quotes (#800)
* fix: only one melt_quote with shared checking_id is allowed to be in a pending state.

fix mypy

add comprehensive tests

remove SQL unique index

remove test db constraint

fix lock statement

remove `test_regtest_pay_mpp_incomplete_payment`

format

* remove `test_set_melt_quote_pending_with_outputs`

* client self-rug mitigation

* fix

* format

* DB level check: error if payment reference paid or pending

* fix test

* comments

* restore

* restore

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
2025-10-28 11:47:23 +01:00
callebtc
184f8ba6ca Revert "extend and refactor nut11 sig_all message aggregation (#804)" (#810)
This reverts commit 7000e5c7ee.
2025-10-28 11:42:21 +01:00
callebtc
7000e5c7ee extend and refactor nut11 sig_all message aggregation (#804) 2025-10-28 11:41:44 +01:00
lollerfirst
f84028ca3f refactor: HTLC spending conditions (#803)
* refactor nut14

* format

* tests

* update tests

* more tests

* format

* adjust wallet tests -> 32 bytes preimages

* format
2025-10-21 16:37:51 +02:00
callebtc
23683f5985 check for existing b (#802) 2025-10-20 11:53:13 +02:00
callebtc
9fed0f0f07 Fix duplicate blank outputs during melt (#795)
* wip blank outputs

* wip: working

* store ids for promises correctly

* tests

* fix migraiton

* revert

* fix tests

* fix auth server

* fix last tests

* retroactively change migration, initial and m017_foreign_keys_proof_tables, remove c_b and replace with c_ (same for b_)

* fix constraint

* oops

* msg stack fix

* fix test foreign key constraint

* fix postgres tests

* foreign key constraint test

* should fix psql error

* foreign key constraint sqlite

* rename to update_blinded_message_signature

* drop outputs and change columns from melt_quotes table

* switch migration order

* reorder migrations again

* fix migration

* add tests

* fix postgres migration too

* create signed_at column postgres

* foreign key constraingt promises table

* migration tool

* readme
2025-10-19 15:50:47 +02:00
asmo
a5f950a8f8 update .env.example (#794) 2025-10-08 13:13:41 +02:00
callebtc
15ec97b9f7 add description to NUT-04 method options (#783)
* add description to NUT-04 method options

* add option
2025-09-09 22:30:42 +02:00
lollerfirst
3b4f5b56a0 fix: subscription re-init bug (#781)
* fix subscription re-initialization bug

* test for regression issue

* format

* Update cashu/mint/events/client.py

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
2025-09-08 18:20:21 +02:00
lollerfirst
ff3fdd5aef feat: implement exponential backoff for paid_invoices_stream (#778)
* feat: implement exponential backoff for paid_invoices_stream across all Lightning backends

- Add exponential backoff retry logic to CLN REST, LND REST, and LND gRPC backends
- Start with 1 second delay, exponentially increase up to 5 minutes maximum
- Reset delay to 1 second on successful reconnection
- Improve error logging to include retry delay information
- Replace fixed delays with adaptive backoff to handle network issues gracefully
- Prevents system overload during persistent connection problems

Resolves issues with rapid reconnection attempts that could overwhelm Lightning nodes during network instability.

* remove unused import

* feat: extend exponential backoff to all remaining backends and invoice listener

- Implement exponential backoff in LNbits paid_invoices_stream for both SSE and WebSocket modes
- Add exponential backoff guidance comments to Blink and Strike backends (not implemented)
- Apply exponential backoff to invoice_listener in tasks.py that calls paid_invoices_stream
- Ensure consistent retry behavior across all Lightning backend integrations
- Improve system resilience during network interruptions and backend failures

All backends and the invoice listener now use the same exponential backoff strategy:
- Start with 1 second delay, exponentially increase up to 5 minutes maximum
- Reset delay to 1 second on successful reconnection
- Enhanced error logging with retry delay information

* blink + strike remove comments

* remove hardcoded values in favor of settings

* immediate first retry
2025-09-08 16:14:19 +02:00
callebtc
ffaac6a5ea Adjust mint melt settings 2 (#777)
* adjust mint melt settings

* .env.example

* ge=0, closes #756
2025-08-12 09:10:16 +02:00
gudnuf
c45352f4cf fix "Expected currency USD, got USDT" when generating mint quote (#772) 2025-08-05 12:53:35 +02:00
lollerfirst
e361cff5c1 management RPC follow up (#770)
* new protobuf file

* redis

* format
2025-08-05 12:52:00 +02:00
lollerfirst
92bf6311fb [BUGFIX] SIG_ALL check returns true for other sigflags (#767)
* solved the issue

* revised approach

* fix

* fix 2
2025-08-05 12:51:37 +02:00
lollerfirst
29571287b3 Mint Management gRPC Server (#723)
* settings

* fix name settings

* management rpc

* hook up the RPC server

* working

* format

* update build script fix import error

* remove accidental commit of vscode extension data

* working ✔

* \n

* add get mint quote get melt quote

* gRPC cli update quotes commands

* update mint melt quotes from cli

* comment under get cli command group

* keyset rotation not yet implemented

* try fix

* change back contact info default to be empty list

* fix import

* add server mTLS

* ll

* script for generating certificates

* rename settings

* move generation script

* do not save TTL expiry into Cache object, rather always load from settings.

* update lightning fees

* update auth limits

* auth rate limit cli

* optional arguemnts

* better error messages

* tests for db update mint/melt quotes

* start mint rpc tests

* add tos_url field to get-info grpc response

* format checks

* add types to click groups where it's needed

* tests on updating quotes

* fix tests

* skip updating mint quote state if on regtest

* test edge case

* unified test_add_remove_contact

* mark pytest-asyncio

* fix missing db argument

* hopefully no more silly errors

* fix test_db_update_mint_quote_state

* pass in the quote id string.

* add keyset rotation

* test for keyset rotation through gRPC command

* fix logger warning

* remove rotation test because it breaks other tests

* use different bolt11 invoices

* assert returned melt quote has quote

* is_postgres

* try different things

* skip if deprecated api

* format checks

* update .gitignore

* default location for certificates
2025-06-25 12:35:53 +02:00
Olindo Task
bbfb63b34e Add verbose request logging feature to wallet (#758)
* Add verbose request logging feature to wallet

* add verbose cli tests

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
2025-06-24 22:31:40 +02:00
callebtc
48823d673d Mint: adjust mint melt settings (#764)
* adjust mint melt settings

* .env.example

* ge=0, closes #756
2025-06-01 12:24:37 +02:00
iwarp
67b7ea6b72 Another changes for LNbits API (#739)
* pending -> status; sse -> websocket

* paid_invoices_stream only for incoming

* fix backward compatibility

* loop

* 'retro-compatible' paid invoice stream

---------

Co-authored-by: lollerfirst <lollerfirst@gmail.com>
2025-06-01 12:20:03 +02:00
callebtc
266685bde0 add NUT-23 to list (#763) 2025-06-01 00:11:54 +02:00
callebtc
3e32dc40e3 add msat support for strike backend (#755) 2025-05-18 15:48:15 +02:00
callebtc
53126456a5 Fix readme links (#753)
* fix readme links

* improve readme
2025-05-14 13:04:53 +02:00
callebtc
c6f7ab1e79 ledger watchdog: disable the abort queue for now (#754) 2025-05-14 13:04:28 +02:00
callebtc
081a30ea68 bump version to 0.17.0 (#751) 2025-05-13 18:01:20 +02:00
callebtc
cbf5b725d9 check for migration first (#750) 2025-05-11 21:34:34 +02:00
callebtc
fc0e3fe663 Mint: watchdog balance log and killswitch (#705)
* wip store balance

* store balances in watchdog worker

* move mint_auth_database setting

* auth db

* balances returned as Amount (instead of int)

* add test for balance change on invoice receive

* fix 1 test

* cancel tasks on shutdown

* watchdog can now abort

* remove wallet api server

* fix lndgrpc

* fix lnbits balance

* disable watchdog

* balance lnbits msat

* test db watcher with its own database connection

* init superclass only once

* wip: log balance in keysets table

* check max balance using new keyset balance

* fix test

* fix another test

* store fees in keysets

* format

* cleanup

* shorter

* add keyset migration to auth server

* fix fakewallet

* fix db tests

* fix postgres problems during migration 26 (mint)

* fix cln

* ledger

* working with pending

* super fast watchdog, errors

* test new pipeline

* delete walletapi

* delete unneeded files

* revert workflows
2025-05-11 20:29:13 +02:00
callebtc
38bdb9ce76 Tests: split wallet test from mint test pipeline (#748)
* split wallet test from mint test pipeline

* regtest mint and wallet

* fix

* fix

* move mint tests

* real invoice in regtest mpp
2025-05-11 14:14:49 +02:00
lollerfirst
619d06f0ab [PATCH] LND use_mission_control + exclude failing channels (#738)
* lnd_grpc multinut patch

* lndrest multinut patch

* mypy fixes

* fixes non escaped double quotes in error messages formats

* fix

* fix debug log with correct hops number

* correctly escape "hops"

* remove `ignored_pairs` constraint

* Apply suggestions from code review

change some error logs to debug

* add tests and some cleanup

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
2025-05-10 15:45:15 +02:00
callebtc
3d21443c3c bump to 0.16.6 (#747) 2025-05-10 15:31:56 +02:00
callebtc
2135b96706 Testing: check if pipeline gets stuck because of startup task (#745)
* lets check if this gets stuck with postgres or not

* check if it works if I add sleeps

* replace startup_ledger with await ledger._check_pending_proofs_and_melt_quotes() in tests

* fix typo to trigger tests again
2025-05-10 15:04:56 +02:00
callebtc
0d127f0477 .env.example for mint TOS (#746) 2025-05-10 12:18:56 +02:00
callebtc
4869a280ca add new init test to mint (#743) 2025-05-09 22:06:27 +02:00
callebtc
dc1dccb5e8 Wallet: Fix cli mpp off (#741)
* fix

* tests
2025-05-08 18:01:11 +02:00
callebtc
7a18ac8712 reorganize docker compose files for redis and keycloak (#736) 2025-04-26 00:45:39 +02:00
callebtc
7f962ce63e Wallet: add Wallet.get_melt_proof(), recover reserved state in failed Wallet.melt() (#730)
* manage state of proofs

* test set proofs unreserved

* melt recovers state on error

* fix wallet test

* fix tests

* fix another test

* get_mint_quote returns MintQuote

* fix tests

* refactor

* fix deprecated tests

* add new unset type
2025-04-25 13:12:45 +02:00
lollerfirst
213d5b1eee Mint Keyset Rotation (#734)
* move keysets methods into newly created `LedgerKeysets` + `maybe_update_derivation_path` on init

* keyset rotation

* fix error

* make format

* format

* test keyset rotation + fix bug

* format

* fix for multiple specified derivation paths

* specify return value
2025-04-25 11:37:49 +02:00
callebtc
7abfc68cfa SIG_ALL signature flag for P2PK (#735)
* n_sigs_refund working, tests added

* update requirements

* wip sigall

* wip

* sigall works

* add signatures for refund

* add mint p2pk tests

* add more p2pk tests

* fix tests

* sign htlc pubkeys as well

* fix htlc and add new test

* fix regtest

* fix new tests with deprecated

* remove asserts

* comments

* new wallet p2pk tests

* getting there

* add more tests

* fixes

* refactor htlc and p2pk validation

* reduce code

* melt with sigall

* fix htlcs

* fix deprecated api tests

* Update cashu/mint/conditions.py

Co-authored-by: lollerfirst <43107113+lollerfirst@users.noreply.github.com>

* refactor sigall validation

---------

Co-authored-by: lollerfirst <43107113+lollerfirst@users.noreply.github.com>
2025-04-25 11:37:19 +02:00
iwarp
8d94d1097b fix getting the PR (#732) 2025-04-20 16:21:52 +07:00
callebtc
e1220d2329 Cjbeery24/mint copy: Invoice checker background tasks (#722)
* #616: Removed blocking call from ledger startup. Instead added it to a background task that repeats every hour.

* make task interval configurable, remember task and cancel it on shutdown

* comments

* add sleep to tests because the background task is async

---------

Co-authored-by: Caleb Beery <cjbeery@gmail.com>
2025-04-10 21:25:18 +07:00
callebtc
76e2601efd Add terms of service URL to MintInformation class (#715)
* add tos_url according to https://github.com/cashubtc/nuts/pull/205

* add tos_url everywhere
2025-03-28 16:11:04 +01:00
callebtc
f783493e1a Fix mint migrations: Fill in missing keyset IDs in proofs and promises (#729)
* mint migrations: fill in missing keyset ids in proofs and promises

* do not throw exception

* add error where proofs are missing an id but no keyset was found

* fix balance view initialization
2025-03-27 11:33:20 +01:00
callebtc
bae4855915 NUT-04/05: add amount, unit, request to melt and mint quote responses (#719)
* add amount, unit, request to melt and mint responses

* make new fields optional to not break compat with old mints

* make new flags optional for backwards compat
2025-03-08 18:23:34 +00:00
Ofek Lev
3ab1e1dfb2 Upgrade coincurve to version 21.0.0 (#721) 2025-03-08 18:05:29 +00:00
Houdini
7b3f5d01d0 Allow arbitrary denominations in wallet minting (#684)
- Update `mint` method to use allowed amounts from the mint
- Add `get_allowed_amounts` method to fetch supported denominations
- Modify `test_mint_amounts_wrong_order` to expect new error message

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
2025-03-06 20:15:14 +01:00
lollerfirst
72ac35405c [NUT-15] LND: Try Multiple Routes (#692)
* try multiple routes

* fix

* Lnd gRPC
2025-03-06 00:05:13 +01:00
callebtc
9305905a85 Add LightningPaymentFailedError exception (#706)
* add error code

* fix test
2025-03-06 00:04:37 +01:00