Commit Graph

157 Commits

Author SHA1 Message Date
callebtc
3d676dd35f Add custom error types (#290)
* add error types

* better subclassing

* add response models

* fix comments

* add response_description to mint endpoints
2023-07-25 23:26:50 +02:00
callebtc
b196c34427 [WIP] [NUTs] NUT-06 update: deprecate amount field in /split (#263)
* mint upgraded and still backwards compatible

* cleanup

* fix tests

* fix things

* add deprecated message to new struct

* fix test

* fix typo

* readd endpoint that got lost during merge

* version bump in pyproject.toml

* remove wallet backwards compatibility because it makes no sense

* comment for backwards compat

* fix comment
2023-07-25 11:13:20 +02:00
callebtc
0b2468914d Determinstic secrets / ecash restore (#131)
* first working version but some sats go missing

* back at it

* make format

* restore to main

* move mint database

* fix some tests

* make format

* remove old _construct_outputs we reintroduced in merge with main

* add type annotations

* add wallet private key to tests

* wallet: load proofs

* fix tests

* _generate_secrets with deterministic generation (temporary)

* allow wallet initialization with custom private key

* add pk to wallet api test

* mint scope=module

* remove private_key from test_wallet.py to see if it helps with the github tests

* readd private keys to tests

* workflow without env

* add more private key!

* readd env

* ledger scope session

* add default private key for testing

* generate private keys if not available

* testing

* its working!!!

* first iteration of bip32 working

* get mint info and add many type annotations

* tests

* fix tests with bip32

* restore from multiple mints

* disable profiler

* make format

* failed POST /mint do not increment secret counter

* store derivation path in each token

* fix tests

* refactor migrations so private keys can be generated by the wallet with .with_db() classmethod

* start fixing tests

* all tests passing except those that need to set a specific private key

* bip39 mnemonic to seed - with db but restore doesnt work yet with custom seed

* mnemonic restore works

* enter mnemonic in cli

* fix tests to use different mnemonic

* properly ask user for seed input

* tests: dont ask for inputs

* try to fix tests

* fix cashu -d

* fixing

* bump version and add more text to mnemonic enter

* add more comments

* add many more comments and type annotations in the wallet

* dont print generated mnemonic and dont wait for input

* fix test

* does this fix tests?

* sigh....

* make format

* do not restore from an initialized wallet

* fix mnemonics

* fix nitpicks

* print wallet name if nonstandard wallet

* fix merge error and remove comments

* poetry lock and requirements

* remove unused code

* fix tests

* mnemonic.lower() and add keyset id if not present for backwards compat

* edit comment
2023-07-24 13:42:56 +02:00
callebtc
337456333e P2PK: Sighash flags and multisig ecash because why not (#284)
* refactor split

* add sigflag to Secret base model

* add better comments

* add comments

* add witnesses inside /split

* more comments

* sign outputs if proofs indicate it

* add signature to outputs but mint does not check it yet

* multiple scriptsigs

* signatures on outputs

* add multisig tests

* rename test

* timelock -> locktime

* move parameters to tags

* convert back to List[List[str]]

* errors are back!

* fix all the stuff

* more testing

* make format
2023-07-18 21:38:31 +02:00
callebtc
1b6c68bc47 invalidate proofs before unsetting pending state (#288) 2023-07-18 15:17:15 +02:00
callebtc
73b015b642 Nut07/proof pending (#277)
* add pending state

* proofs spendable check and tests

* bump version to 0.12.3

* remove sleep for testing

* comment clarify

* use list comprehension in pending list
2023-07-08 22:50:17 +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
a3e67d21aa Use m̶u̶l̶t̶i̶p̶r̶o̶c̶e̶s̶s̶i̶n̶g̶ asyncio locks instead of db locks (#256)
* use mp locks instead of db locks

* replace mp.Lock with asyncio.Lock

* make format

* push

* remove db connection (and lock) and delete asyncio locks
2023-06-23 19:10:32 +02:00
callebtc
12bc0c23cb [Mint] Fix: check keyset id in mint and allow custom split amounts for LIGHTNING=False (#253)
* check keyset existence and return error

* fix split specific amounts for LIGHTNING=False

* wallet loading

* remove wallet balance checks
2023-06-18 14:00:34 +02:00
xphade
21069fb61a Implement dynamic amount of tokens for change (#223)
With the recent update to NUT-08, we can ensure that the amount of blank
outputs is always enough to cover any overpaid lightning fees. This
change implements this functionality for both the wallet and the mint.
The mint updateis backwards-compatible with respect to old wallets.
2023-05-23 17:40:48 +02:00
callebtc
f0735cfc4a fix postgres views, closes #206 (#222) 2023-05-16 22:14:13 +02:00
callebtc
d0283670d3 Refactor Compat and Database for LNbits comaptibility (#219)
* remove changes to Compat and Database so its compatible with the classes from LNbits

* ledger.py: Annotate Connection type

* fix invoice memp
2023-05-15 22:15:56 +02:00
callebtc
6272aee189 make format (#218) 2023-05-15 17:11:02 +02:00
Semisol
d4c7a15e89 add transactions and locking for certain operations (#217) 2023-05-15 17:09:28 +02:00
callebtc
ddd8cebdb0 more logging (#216) 2023-05-15 00:37:46 +02:00
callebtc
4789e2a504 Mint/moremore_traces (#215)
* more trace logging

* a lot more logging
2023-05-15 00:15:07 +02:00
callebtc
352f77f9e9 more traces (#214) 2023-05-14 23:39:03 +02:00
callebtc
68d9020cb3 mint: add trace logs (#213) 2023-05-14 23:06:35 +02:00
sihamon
e7df2028fa Allow to set maximum peg in/out for mint (#209)
* Allow to set maximum peg in/out for mint

* Make format

* remove duplicate error

* move business logic to ledger

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
2023-05-13 20:41:24 +02:00
callebtc
c31f008fb4 [Mint] load the latest keyset from db based on the derivation path (#193)
* load the latest keyset from db based on the derivation path and not the on-line generated keyset id (necessary because we changed the keyset id derivation algorithm)

* better comments

* generate keys for keyset from db
2023-05-07 17:47:38 +02:00
callebtc
e9f33337db Fix/nut 04 payment hash (#191)
* payment_hash -> hash

* add aes encryption

* urlsafe base64 for free

* move files to crypto

* use random hash instead of encryption

* get rid of useless code

* simplify
2023-05-04 00:12:18 +02:00
calle
89fb2787e6 Python/relative_import (#186)
* relative import all the things

* make format

* add __init__.py to cli/

* fix mypy errors

* get rid of more mypy

* mypy fix crud.py

* fix another mypy error
2023-05-01 22:39:23 +02:00
calle
f25e36f333 improve logging for keyests (#184) 2023-04-30 00:05:53 +02:00
calle
87f9241de1 [Mint] Fix key rotation (#177)
* rotate keys every 5 seconds

* every 10 seconds

* do not regenerate all past keys for each epoch cycle

* remove automatic rotation

* make format

* print to logger

* rephrase print
2023-04-26 20:20:17 +02:00
calle
6b631111d1 Fix/ln unsuccessful payment (#159)
* throws error for unsuccessful payment so that wallets get error message

* bump to 0.11.2
2023-04-03 20:52:14 +02:00
calle
47f886487c nut-09 mint info (#155)
* nut-09 mint info

* bump to 0.11.1

* make format
2023-04-01 00:47:27 +02:00
calle
70828b59d5 NUT-08 Lightning fee return (#114)
* skeleton

* works

* comments

* docsctrings ledger.py

* bump version to 0.10.

* fixes mypy stuff

* make format

* remove unwanted changes
2023-03-16 01:28:33 +01:00
calle
f3a31fd09e use settings module (#136)
* use settings module
2023-03-16 00:59:50 +01:00
calle
e8011a0f78 Type annotations for bdhke (#140)
* annotate dhke

* raise for errors

* remove backwards compatibility

* remove old code

* remove test code
2023-03-09 17:45:50 +01:00
calle
a7eef68c97 wallet: load keys without keysets (#123)
* wallet: load keys without keysets

* fix cli
2023-03-05 02:51:20 +01:00
calle
23f2b58430 wallet: mint specific amounts (#121)
* wallet: mint specific amounts

* make format
2023-03-04 21:49:39 +01:00
calle
2d66aeb79c Fix invoice asyncio wrapper (#113)
* mypy: fix lightning backend warnings

* fix asyncio invoice creation

* ignore weird mypy error
2023-02-25 16:44:51 +01:00
calle
7e39e1b036 BREAKING: PostMeltRequest, CheckSpendableResponse ` (#106)
* fix PostMeltRequest and /checkfees to GET

* POST /check -> GET /check

* fix GetCheckSpendableResponse

* rename models

* make format

* revert GET

* bump version to 0.9

* skip nostr test
2023-01-30 09:13:46 +01:00
calle
e63db82641 update readme and errors for mint (#107) 2023-01-28 00:08:33 +01:00
callebtc
ff11e7878b mint: endpoint get pubkeys for keyset 2022-12-25 11:42:37 +01:00
callebtc
3d2c6540ab refactor invoice pending 2022-12-23 20:18:55 +01:00
callebtc
1082f2c9d1 refactor 2022-12-14 23:41:36 +01:00
callebtc
cdabc86ba9 defer unpending 2022-12-14 23:27:40 +01:00
callebtc
d08b8a00f6 check pending proofs 2022-12-14 22:50:25 +01:00
callebtc
9f12abebff option to autosave keyset 2022-11-26 02:45:18 +01:00
callebtc
9ca2756f18 load newly generated keyset 2022-10-22 21:47:03 +02:00
callebtc
6481a2d5cd coverage badge 2022-10-16 13:41:46 +02:00
callebtc
223a40e9bd bump version to 0.4.0 2022-10-15 01:08:35 +02:00
callebtc
6f913e3cc9 make format 2022-10-15 00:59:21 +02:00
callebtc
ee16b3e0f9 disable starlette_context 2022-10-15 00:19:44 +02:00
callebtc
167eaf89f2 remove comment 2022-10-14 01:02:19 +02:00
callebtc
5022d4e47f test melt without lightning 2022-10-14 00:05:47 +02:00
callebtc
a84b04605e refactor 2022-10-13 22:11:00 +02:00
callebtc
3437af041e ability to specify the keyset for generating promises mint 2022-10-13 20:07:04 +02:00
callebtc
fcc2c5c3e0 lnbits migrations work 2022-10-12 23:16:08 +02:00