Commit Graph

16 Commits

Author SHA1 Message Date
Pavol Rusnak
75ffa39807 chore: modernize f-string usage (#627) 2024-10-04 14:11:00 +02:00
callebtc
700320a8c4 Fix: wallet include fees in swap outputs for inputs of successive melt (#630)
* 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
2024-10-03 09:50:23 +02:00
callebtc
3077ca4c7d Wallet: add CLI flag --force-swap flag and force swapping all inactive keysets (#580)
* Wallet: add flag --force-swap to send command

* Reame split to swap across codebase

* rename remaining splits to swap

* fix restore index with multiple keysets

* fix wallet api restore
2024-07-11 23:08:36 +02:00
callebtc
26b94951fc Fix Tokenv4 handling of base64 keysets (#575)
* wip: handle tokenv4 if the keyset is base64

* wip

* Tokens now dataclasses

* Deserialize DLEQ from string

* add tokenv3/v4 base64 keyset ID tests

* fix cli
2024-07-10 14:12:03 +02:00
callebtc
2739c3127a TokenV4 CBOR serialization (#502)
* WIP: cashuB with CBOR

* working

* tokenv4 works

* fix mypy
2024-06-30 14:36:44 +02:00
callebtc
d30b1a2777 Add fees (#503)
* wip

* wip

* model

* refactor wallet transactions

* refactor wallet

* sending with fees works and outputs fill up the wallet

* wip work

* ok

* comments

* receive with amount=0

* correctly import postmeltrequest

* fix melt amount

* tests working

* remove mint_loaded decorator in deprecated wallet api

* wallet works with units

* refactor: melt_quote

* fix fees

* add file

* fees for melt inputs

* set default input fee for internal quotes to 0

* fix coinselect

* coin selection working

* yo

* fix all tests

* clean up

* last commit added fees for inputs for melt transactions - this commit adds a blanace too low exception

* fix fee return and melt quote max allowed amount check during creation of melt quote

* clean up code

* add tests for fees

* add melt tests

* update wallet fee information
2024-06-15 16:22:41 +02:00
callebtc
a77b7dd5e8 Wallet: fix nostr receive (#460)
* fix wallet nostr receive

* add log

* add more relays and print info nicer
2024-02-26 01:25:05 +01:00
callebtc
ac8e21a3a4 relative import all (#415) 2024-02-11 12:51:44 +01:00
callebtc
6c8b1a858f Wallet/fix_nostr_timeout (#376)
* fix nostr receive

* split with amount pre 0.13

* drop 0.13.0 amount with split compatibility
2023-12-03 01:56:58 +01:00
callebtc
0490f20932 Wallet: Lightning interface (#318)
* mint does not start yet

* fix import

* revert mint db migrations

* handle zero fee case

* cli: adjust fee message

* wallet: replace requests with httpx

* clean up

* rename http client decorator

* fix pending check in main, todo: TEST PROXIES WITH HTTPX

* fix up

* use httpx for nostr as well

* update packages to same versions as https://github.com/lnbits/lnbits/pull/1609/files

* fix proof deserialization

* check for string

* tests passing

* adjust wallet api tests

* lockfile

* add correct responses to Lightning interface and delete melt_id for proofs for which the payent has failed

* fix create_invoice checking_id response

* migrations atomic

* proofs are stored automatically when created

* make format

* use bolt11 lib

* stricter type checking

* add fee response to payments

* assert fees in test_melt

* test that mint_id and melt_id is stored correctly in proofs and proofs_used

* remove traces

* refactor: Lightning interface into own file and LedgerCrud with typing

* fix tests

* fix payment response

* rename variable
2023-10-21 14:38:16 +02:00
callebtc
a76f076dbd [Wallet] Add nostr dependency directly to repo (#346)
* adjust nostr imports

* nostr receive split content by words
2023-10-15 16:06:39 +02:00
callebtc
6282e0a22a [Wallet/Mint] DLEQ proofs (#175)
* produce dleq

* start working on verification

* wip dleq

* Use C_ instead of C in verify DLEQ! (#176)

* Fix comments (DLEQ sign error)
* Fix alice_verify_dleq in d_dhke.py
* Fix_generate_promise in ledger.py
* Fix verify_proofs_dleq in wallet.py

* Fix: invalid public key (#182)

* Use C_ instead of C in verify DLEQ!

* Fix comments (DLEQ sign error)
* Fix alice_verify_dleq in d_dhke.py
* Fix_generate_promise in ledger.py
* Fix verify_proofs_dleq in wallet.py

* Fix: invalid public key

* Exception: Mint Error: invalid public key

* Update cashu/wallet/wallet.py

---------

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

* Update cashu/core/b_dhke.py

* Update tests/test_cli.py

* verify all constructed proofs

* dleq upon receive

* serialize without dleq

* all tests passing

* make format

* remove print

* remove debug

* option to send with dleq

* add tests

* fix test

* deterministic p in step2_dleq and fix mypy error for hash_to_curve

* test crypto/hash_e and crypto/step2_bob_dleq

* rename A to K in b_dhke.py and test_alice_verify_dleq

* rename tests

* make format

* store dleq in mint db (and readd balance view)

* remove `r` from dleq in tests

* add pending output

* make format

* works with pre-dleq mints

* fix comments

* make format

* fix some tests

* fix last test

* test serialize dleq fix

* flake

* flake

* keyset.id must be str

* fix test decorators

* start removing the duplicate fields from the dleq

* format

* remove print

* cleanup

* add type anotations to dleq functions

* remove unnecessary fields from BlindedSignature

* tests not working yet

* spelling mistakes

* spelling mistakes

* fix more spelling mistakes

* revert to normal

* add comments

* bdhke: generalize hash_e

* remove P2PKSecret changes

* revert tests for P2PKSecret

* revert tests

* revert test fully

* revert p2pksecret changes

* refactor proof invalidation

* store dleq proofs in wallet db

* make mypy happy

---------

Co-authored-by: moonsettler <moonsettler@protonmail.com>
2023-09-23 19:06:37 +02:00
dni ⚡
88393fa4c4 [DEV] add ruff and remove isort and flake (#300)
* [DEV] add ruff and remove isort and flake
- precommit
- workflow
- Makefile

updated black

* configure black to use default line-length

* reformat to 88 chars line-length

* fix ugly comments
2023-08-24 09:47:47 +02:00
callebtc
01d498309b [Wallet/mint] P2PK with timelocks (#270)
* p2pk with nostr privatekey and timelocks

* add p2pk

* fix test

* fix test with custom secret

* sign whole split transaction

* p2pk signature now commits to entire secret and thus to a nonce

* use schnorr signatures

* revamp P2SH and P2PK with new Secret model

* test p2pk

* add comments

* add nostr private key to tests

* fix nostr receive

* make format

* test redemption after timelock

* refactor Server.serialize()

* sign sha256(secret)

* add optional refund pubkey that triggers after timelock

* use nostr private key for now (including nsec parser)

* use nostr private key and fix tests

* bump version to 0.12.2
2023-07-02 01:56:05 +02:00
callebtc
f3cf1c69c4 [Wallet] Bugfix/enable-funding-multiple-mints (#210)
* Fix bug where no additional mints can be funded

As soon as one mint is in the database, the new multimint selector only
considers this mint, even if the `MINT_` environment variables point to
a different one. This commit fixes it by explicitly adding the set mint
URL to the selector.

Additionally did some small cleanups.

* Move mint adding to higher-level function

* bypass selection at first time

* use contextx, more explicit

* remove whitespace

---------

Co-authored-by: xphade <18196286+xphade@users.noreply.github.com>
2023-05-13 19:49:37 +02:00
callebtc
4088ab2876 Wallet REST API (#199)
* Add REST API for Cashu wallet

* Add simple way to start REST API server

* Add simple tests for wallet REST API

* Add TokenV3 to REST API

* Improve tests for wallet REST API

* Make format

* Remove unused import

* Rename nostr module for API

* Unify helper functions for CLI and API

* Make format

* Move error handling from helper functions to API

* Remove 'is_api' flag where possible

* Make format, cleanup, add comments

* Fix typo for burn also in API

* Improve error handling for API

* Add flag 'trust_new_mint' to receive command

To enable trusting or mistrusting unknown mints via API

* Allow selecting mint for sending from API

* Fix: set specific mint via API

* Fix: select mint with maximum balance via CLI

* Use different variables for mint_nr

* Allow selecting mint when sending via nostr via API

* Remove unnessecary 'is_api' flags from 'send_nostr'

* Remove HTTPException from nostr.py

* Allow selecting mint for sending with parameter also via CLI

* Allow trusting unknown mint for receiving also via CLI

* Make format

* Enable trusting unknown mint also when receiving via nostr

* Fix: wrong indentation of in receive function

* Use relative imports for wallet API

* Unify get_mint_wallet for CLI and API

* Unify send command for CLI and API

* Unify receive for CLI and API

* Catch errors in nostr via API

* Remove flag 'is_api' from verify_mints_tokenv2

* Remove cli_helpers left from last merge

* refactor cli selection

* load mint in nostr_send

* cleanup

* add cli_helpers.py

* legacy deserialization in cli

* make format

* clean up api response

* fix tests

* try pk

* verify mints in api

* try github tests

* Fix: verify_mints for API

* Uncomment verify_mints in receive of API

* update README

* Show mint url in pending

* clean up balance response

* fix test

* mint selection in api

* clean up API

* CLI: verify mint for receive -a

* clean up

* Rest -> REST

* Remove unused imports

---------

Co-authored-by: sihamon <sihamon@proton.me>
Co-authored-by: sihamon <126967444+sihamon@users.noreply.github.com>
2023-05-11 23:27:13 +02:00