* 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>
* 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
* 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
* 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
* 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
* 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
* #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>
* 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
- 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>
* auth server
* cleaning up
* auth ledger class
* class variables -> instance variables
* annotations
* add models and api route
* custom amount and api prefix
* add auth db
* blind auth token working
* jwt working
* clean up
* JWT works
* using openid connect server
* use oauth server with password flow
* new realm
* add keycloak docker
* hopefully not garbage
* auth works
* auth kinda working
* fix cli
* auth works for send and receive
* pass auth_db to Wallet
* auth in info
* refactor
* fix supported
* cache mint info
* fix settings and endpoints
* add description to .env.example
* track changes for openid connect client
* store mint in db
* store credentials
* clean up v1_api.py
* load mint info into auth wallet
* fix first login
* authenticate if refresh token fails
* clear auth also middleware
* use regex
* add cli command
* pw works
* persist keyset amounts
* add errors.py
* do not start auth server if disabled in config
* upadte poetry
* disvoery url
* fix test
* support device code flow
* adopt latest spec changes
* fix code flow
* mint max bat dynamic
* mypy ignore
* fix test
* do not serialize amount in authproof
* all auth flows working
* fix tests
* submodule
* refactor
* test
* dont sleep
* test
* add wallet auth tests
* test differently
* test only keycloak for now
* fix creds
* daemon
* fix test
* install everything
* install jinja
* delete wallet for every test
* auth: use global rate limiter
* test auth rate limit
* keycloak hostname
* move keycloak test data
* reactivate all tests
* add readme
* load proofs
* remove unused code
* remove unused code
* implement change suggestions by ok300
* add error codes
* test errors
* startup: do not rollback unknown melt quote states
* fix: provide overpaid fees on startup
* fix: check if outputs in db
* fix test: expect melt quote pending if payment state is unknown
* fix up comment
* nut-19 sign mint quote
* ephemeral key for quote
* `mint` adjustments + crypto/nut19.py
* wip: mint side working
* fix import
* post-merge fixups
* more fixes
* make format
* move nut19 to nuts directory
* `key` -> `privkey` and `pubkey`
* make format
* mint_info method for nut-19 support
* fix tests imports
* fix signature missing positional argument + fix db migration format not correctly escaped + pass in NUT-19 keypair to `request_mint` `request_mint_with_callback`
* make format
* fix `get_invoice_status`
* rename to xx
* nutxx -> nut20
* mypy
* remove `mint_quote_signature_required` as per spec
* wip edits
* clean up
* fix tests
* fix deprecated api tests
* fix redis tests
* fix cache tests
* fix regtest mint external
* fix mint regtest
* add test without signature
* test pubkeys in quotes
* wip
* add compat
---------
Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
* fast-api-cache setup
* testing the cache
* fix
* still not working
* asynccontextmanager
* move test
* use redis & custom caching setup (like CDK)
* make format
* poetry lock
* fix format string + log when a cached response is found
* log when a cahced response is found
* fix tests
* poetry lock
* try tests on github
* use docker compose
* maybe we dont need docker
* fix types
* create_task instead of run
* how about we start postgres
* mint features
* format
* remove deprecated setex call
* use global expiry for all cached routes
* refactor feature map and set default to 1 week
* refactor feature construction
* Cache NUT-19
---------
Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
* sort proofs
* outputs-ordering
* mypy fix
* clean up
* test if output amounts are sorted
* clean up test
---------
Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
* skip db lock check in regtests
* revert?
* try this
* do not dispose conftests
* remove return
* test this
* try auto
* dispose stuff
* try uri=true
* remove the other flag
* move test
* reduce tests
* reduce more
* keep one
* skip on github?
* only skip in regtest
* trigger again
* restore cashu/mint/ledger.py
* WIP settle different units externally
* mint melt externally different units
* deprecated route return only sat
* comment
---------
Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
* wait for uvicorn server to bind before running tests
Previously we had a simple `time.sleep(1)` call after `server.start()`
which was present to give the Mint's HTTP server time to spin up during
test runs. This meant that if the server took longer than 1s to start
on a dev's machine for any reason (even intermittently) then tests would
fail due to connection errors.
The fix is to use a simple repeated polling check which allows
the test runner to start only once the server is confirmed listening.
* fix linter errors
* prevent infinite loop
* specifically except httpx.ConnectError
Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
---------
Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
* wallet: add fees to outputs for melt that requires a split
* add test that requires a swap
* verify test fails, will revert
* revert true
* hopefully fix the tests
* fix default fee selection
* cleanup and renamings
* cleanup coinselect function, estimate fees
* fix test
* add comments
* weird error
* `PaymentResult`
* ledger: rely on PaymentResult instead of paid flag. Double check for payments marked pending.
* `None` is `PENDING`
* make format
* reflected changes API tests where `PaymentStatus` is used + reflected changes in lnbits
* reflect changes in blink backend and tests
* fix lnbits get_payment_status
* remove paid flag
* fix mypy
* remove more paid flags
* fix strike mypy
* green
* shorten all state checks
* fix
* fix some tests
* gimme ✅
* fix............
* fix lnbits
* fix error
* lightning refactor
* add more regtest tests
* add tests for pending state and failure
* shorten checks
* use match case for startup check - and remember modified checking_id from pay_invoice
* fix strike pending return
* new tests?
* refactor startup routine into get_melt_quote
* test with purge
* refactor blink
* cleanup responses
* blink: return checking_id on failure
* fix lndgrpc try except
* add more testing for melt branches
* speed things up a bit
* remove comments
* remove comments
* block pending melt quotes
* remove comments
---------
Co-authored-by: lollerfirst <lollerfirst@gmail.com>
* NUT-04: add description
* skip test for deprecated api
* fix for lndgrpc
* add test for cli
* add two random tests
* add max length to request model validator
* skip cli test with description for deprecated api
* add cli test for invoice command
* default value to None