Commit Graph

68 Commits

Author SHA1 Message Date
Vlad Stan
352fd23c0b
refactor: dev-friendly payment status name (#2322)
* refactor: dev-friendly payment status name
* refactor: change `PaymentStatus(True, ...)` to `PaymentSuccessStatus(...)`
2024-03-13 16:17:33 +01:00
Pavol Rusnak
8eabf53642 introduce Wallet.normalize_endpoint to remove code duplication 2024-01-22 10:06:22 -06:00
Pavol Rusnak
824a8fa7c8 refactor __init__ functions of Wallets (funding sources)
- better error messages when a conf variable is not provided
- unify approaches among different source files
2024-01-22 10:06:22 -06:00
Vlad Stan
031ce14857
refactor: extract AESCipher to crypto.py (#2202) 2024-01-15 11:51:15 +02:00
callebtc
165d7499ea
LndResWallet: catch http errors (#2133) 2023-12-19 15:33:18 +00:00
Pavol Rusnak
62b0e3fe89
set User-Agent when accessing external resources (#2100)
* set User-Agent when accessing external resources

* refactor User-Agent into settings.user_agent
2023-11-30 12:54:07 +00:00
Sébastien Krafft
31782040c6 formatted code 2023-11-12 22:53:03 +01:00
Sébastien Krafft
1195dd3eb3 Fix according to suggestion from prusnak
Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
2023-11-12 22:53:03 +01:00
Sébastien Krafft
a61d74deff Fixed payment isn't initiated on lndrest 2023-11-12 22:53:03 +01:00
dni ⚡
eb73daffe9
[FEAT] Node Managment (#1895)
* [FEAT] Node Managment

feat: node dashboard channels and transactions
fix: update channel variables
better types
refactor ui
add onchain balances and backend_name
mock values for fake wallet
remove app tab
start implementing peers and channel management
peer and channel management
implement channel closing
add channel states, better errors
seperate payments and invoices on transactions tab
display total channel balance
feat: optional public page
feat: show node address
fix: port conversion
feat: details dialog on transactions
fix: peer info without alias
fix: rename channel balances
small improvements to channels tab
feat: pagination on transactions tab
test caching transactions
refactor: move WALLET into wallets module
fix: backwards compatibility
refactor: move get_node_class to nodes modules
post merge bundle fundle
feat: disconnect peer
feat: initial lnd support
only use filtered channels for total balance
adjust closing logic
add basic node tests
add setting for disabling transactions tab
revert unnecessary changes
add tests for invoices and payments
improve payment and invoice implementations
the previously used invoice fixture has a session scope, but a new invoice is required
tests and bug fixes for channels api
use query instead of body in channel delete
delete requests should generally not use a body
take node id through path instead of body for delete endpoint
add peer management tests
more tests for errors
improve error handling
rename id and pubkey to peer_id for consistency
remove dead code
fix http status codes
make cache keys safer
cache node public info
comments for node settings
rename node prop in frontend
adjust tests to new status codes
cln: use amount_msat instead of value for onchain balance
turn transactions tab off by default
enable transactions in tests
only allow super user to create or delete
fix prop name in admin navbar

---------

Co-authored-by: jacksn <jkranawetter05@gmail.com>
2023-09-25 15:04:44 +02:00
dni ⚡
4e6f229db2
[CHORE] string formatting default length 88 (#1887)
* [CHORE] string formatting default length 88

uses blacks default off 88 and enabled autostringformatting

* formatting

* nitpicks jackstar

fix
2023-08-24 10:26:09 +01:00
dni ⚡
355806608b
[CHORE] E722 bare exception fix (#1871)
* [CHORE] E722 bare exception fix
remove all bare exceptions from codebase and change it in `.flake8`
2023-08-16 12:17:54 +02:00
callebtc
2d4c9f349b
Wallets: Catch errors during cleanup (#1829)
* jetz aba

* catch RuntimeError
2023-07-21 09:50:50 +02:00
jackstar12
e6499104c0
Wallets refactor (#1729)
* feat: cleanup function for wallet

* update eclair implementation

* update lnd implementation

* update lnbits implementation

* update lnpay implementation

* update lnbits implementation

* update opennode implementation

* update spark implementation

* use base_url for clients

* fix lnpay

* fix opennode

* fix lntips

* test real invoice creation

* add small delay to test

* test paid invoice stream

* fix lnbits

* fix lndrest

* fix spark

fix spark

* check node balance in test

* increase balance check delay

* check balance in pay test aswell

* make sure get_payment_status is called

* fix lndrest

* revert unnecessary changes
2023-06-19 12:12:00 +02:00
Arc
07946d873f
Merge pull request #1630 from lnbits/update/flake8
FEAT: improve on flake8 linting
2023-04-20 09:49:11 +01:00
dni ⚡
adae3b4302
optional ssl certifiace for lndrest 2023-04-19 10:51:00 +02:00
dni ⚡
156a19f05c
improve errorhandling for lndrest #252 (#1631) 2023-04-17 09:26:37 +02:00
dni ⚡
0af22a6256
E471 2023-04-17 08:21:45 +02:00
dni ⚡
be5f909d1c
merge issue in lnd_rest 2023-04-04 08:00:43 +02:00
dni ⚡
2a1a0f3a2f
fix pyright issues 2023-04-04 07:49:13 +02:00
Pavol Rusnak
9c8a79eb9b
fix pyright lnbits/wallets
Co-authored-by: dni  <office@dnilabs.com>
2023-04-04 07:34:50 +02:00
Pavol Rusnak
689c443d72
increase readability by using f-strings (#1597)
* increase readability by using f-strings

* readd merge conflict stuff

---------

Co-authored-by: calle <93376500+callebtc@users.noreply.github.com>
2023-04-03 15:34:17 +02:00
Pavol Rusnak
a49a654137
fix flake8 F401+F403 (module imported but unused + unable to detect undefined names) 2023-01-30 11:46:45 +00:00
Pavol Rusnak
a0cc55c5a1
fix pylint C0209 (consider-using-f-string) 2023-01-30 11:46:43 +00:00
Pavol Rusnak
15d7fbeace
run autoflake
```
autoflake -i --remove-unused-variables $(find . -name "*.py")
```
2023-01-30 11:46:43 +00:00
calle
f0d58a8365
Wallets: add custom invoice expiry (#1396)
* expiry for fakewallet

* expiry for lnd

* lnbits backend

* fix: eclair descriptionHash fixed and expiry added

* cln and sparko

* test expiry

* Eclair from AdminUI and bugfix for nonexistent payments

* add to settings and .env and remove lntxbot

* remove duplicate and format

* add invoice expiry

* add min max and step

* UI works now

* test should fail, sanity check, will revert

* revert, ready for merge

Co-authored-by: Tiago Vasconcelos <talvasconcelos@gmail.com>
2023-01-26 11:08:40 +01:00
dni ⚡
ad81bb322a change settings in wallets 2022-10-05 13:05:11 +02:00
calle
2ee10e28c5
Backend: Unstuck outgoing payments (#857)
* first attempts

* lndrest works

* fix details

* optional fee update

* use base64.urlsafe_b64encode

* return paymentstatus

* CLN: return pending for pending invoices

* grpc wip

* lndgrpc works

* cln: return pending for pending invoices really this time

* retry wallet out of exception

* wip eclair

* take all routines into try except

* cliche: return error

* rename payment.check_pending() to payment.check_status()

* rename payment.check_pending() to payment.check_status()

* eclair: works

* eclair: better error check

* opennode: works

* check payment.checking_id istead of payment.ok

* payment.ok check as well

* cln: works?

* cln: works

* lntxbot: works

* lnbits/wallets/lnpay.py

* cln: error handling

* make format

* lndhub full detail update

* spark: wip

* error to False

* wallets: return clean PaymentResponse

* opennode: strict error

* cliche: works

* lnbits: works

* cln: dont throw error

* preimage not error

* fix cln

* do not add duplicate payments

* revert cln

* extra safety for cln

* undo crud changes until tests work

* tasks: better logging and 0.5s sleep for regular status check

* 0.1 s

* check if wallet exists

* lnbits unhashed description

* remove sleep

* revert app.py

* cleanup

* add check

* clean error

* readd app.py

* fix eclaid
2022-08-30 13:28:58 +02:00
calle
e5d8c500d2
Wallets/unhashed_description (#870)
* new argument: unhashed_description

* accept in api

* set unhashed_description for memo case

* bolt11.py: dont be like CLN, accept the hash

* send hash to lnd in b64

* fix cln

* skip descr_hash for cln

* skip

* format
2022-08-13 14:29:04 +02:00
calle
4fc0a25d41
Mega-merge 4: Reenable LndWallet gRPC and use TrackPaymentV2 (#745)
* readd lndgrpc

* debug logging

* Use TrackPaymentV2

* /v2/router/track

* lnd_router_grpc

* flag for blocking check

* error handling

* fix name

* regtest lndgrpc

* new test pipeline

* fix env

* check for description hash

* remove unnecessary asserts for clarity

* assume that description_hash is a hash already

* no lock

* description hashing in backend

* restore bolt11.py

* /api/v1/payments with hex of description

* comment

* refactor wallets

* forgot eclair

* fix lnpay

* bytes directly

* make format

* mypy check

* make format

* remove old code

* WIP status check

* LND GRPC docs

* restore cln to main

* fix regtest

* import

* remove unused import

* format

* do not expect ok

* check ok

* delete comments
2022-08-09 11:49:39 +02:00
calle
f1ec7e33f0
Mega-merge 2: Invoice/refactor description hash (WIP) (#814)
* description hashing in backend
2022-08-01 16:20:25 +02:00
calle
0c5cb8cb9e
Wallets: increase timeouts (#787)
* increase pay timeouts to infinite
2022-07-27 15:29:44 +02:00
calle
f4e7d62ca3
make format everything (#743) 2022-07-16 14:23:03 +02:00
calle
089313f613
Logging with loguru (#708)
* logging

* requirements

* add loguru dependency

* restore it

* add loguru

* set log level in .env file

* remove service fee print

* set log level

* more logging

* more logging

* more logging

* pyament.checking_id

* fix
2022-07-07 14:30:16 +02:00
calle
0f97f8f18b
Fee reserve for lightning backends (#557)
* preparing fees

* fee_limit_msat

* await resp result

* clightning

* fix tests

* fix test

* add fee to test

* mypy

* invoice_status

* checking id fix

* fee reserve error message

* only for external payments
2022-03-16 07:20:15 +01:00
Graham Krizek
251e6a8233
Add a fallback to LND_REST_CERT to use the system chain if its not present (#539) 2022-03-01 22:58:54 +03:00
calle
0764f4fdf1
Support for encrypted macaroons (#521)
* encrypted macaroons

* fix GRPC env entry

* example config entry

* add pycryptodomex to requirements

* documentation

* Added pycryptodomex to pip file

Co-authored-by: Ben Arc <ben@arc.wales>
2022-02-14 17:54:05 +01:00
benarc
228717195b back 2022-01-30 19:43:30 +00:00
calle
43b48376bb
lndrest fees for fastapi (#459) 2021-12-09 00:26:08 +01:00
callebtc
12c2a04b2a LNDRest fee limit 2021-11-29 18:10:11 +01:00
benarc
1d3bb016a2 I want them to turn black 2021-10-17 18:33:29 +01:00
Stefan Stammberger
d9849d43d2
refactor: replace Trio with asyncio/uvloop 2021-08-30 19:55:02 +02:00
fiatjaf
688149fade add trio typing. 2021-06-20 21:17:32 -03:00
fiatjaf
59aaea47fd lndrest: capture the pay error properly. 2021-04-06 10:22:37 -03:00
fiatjaf
d4d069fc77 make all methods from all wallets async. 2021-03-24 01:01:09 -03:00
fiatjaf
42bd5ea989 remove exception to black line-length and reformat. 2021-03-24 00:40:32 -03:00
fiatjaf
0dc60d4795 increase timeouts for http wallets when stuff may take more than 5 seconds.
before we were using requests which had no default timeouts, but httpx has a
default timeout of 5 seconds. should have noticed that earlier.

when the timeout expires we are left with a pending payment on the db with a
temporary checking_id so we can never know if it was completed or not.

this is still an issue, because technically a lightning payment may take 2 weeks
or more, and we must have a way to dispatch a payment and check for it later.

that should be the default (and we already do check for the payment status later,
so half of the work is done), but on the other hand backends like lnpay and
opennode do not give us a checking_id before the thing is already settled.
2020-10-13 20:39:24 -03:00
fiatjaf
b1f30390b0 retrieve preimage from wallet backends, save it and show on UI dialog.
closes https://github.com/lnbits/lnbits/issues/77
2020-10-12 23:19:16 -03:00
fiatjaf
f2ea8a0c74 fix lndrest payment checking: b64/hex mismatch.
finally fixes https://github.com/lnbits/lnbits/issues/55
and https://github.com/lnbits/lnbits/issues/110
2020-10-12 23:18:58 -03:00
fiatjaf
b5a07c7ae7 add status() method to wallets to be used in initial check. 2020-10-12 22:30:19 -03:00