Commit Graph

97 Commits

Author SHA1 Message Date
Stefan Kostic
f93bdd54f9 Replace hardcoded strings with common constants 2022-02-09 22:27:01 +01:00
Stefan Kostic
3f4cc70d22 Revert commits related to constants 2022-02-09 22:24:52 +01:00
Stefan Kostic
3152f6f2e6 Replace hardcoded strings with common constants 2022-02-09 22:17:49 +01:00
Stefan Kostic
0da4b359d6 Pass in ctx as service methods first argument 2022-02-08 13:35:02 +01:00
kiwiidb
c3bec5f80c chore: wrap LND client 2022-02-04 12:13:40 +01:00
kiwiidb
1ae5df6b8c Feature: integration testing
Add integration tests with testify/suite. Moved some structs
outside of controller funcs so we can re-use them in the testing
package. Add CI workflow for running tests on every push.
2022-02-01 11:47:11 +01:00
kiwiidb
7e2b432790 add optional custom node name 2022-02-01 09:22:44 +01:00
Michael Bumann
2f44889be6 300 sat it is for now. this should work for most payments 2022-01-31 13:31:07 +01:00
Michael Bumann
f2ca4ac0ca Set fixed fee limit
Very small amounts have problems with the percentage based fee limit.
This has to be changed soon to be smarter and more dynamic
2022-01-31 13:27:45 +01:00
Michael Bumann
3f01c3304d Calculate timestamp in Go to not use PostgreSQL specific function 2022-01-30 20:30:19 +01:00
Michael Bumann
dd0d168b5b Use the HTTP error code define by the error if available
This handler handles all errors. those are not necessarily http 500 erros.
We should use the code from the error if available
2022-01-27 18:21:36 +01:00
Michael Bumann
d10701ad2f Custom HTTP error handler and send sentry notifications 2022-01-24 23:37:03 +01:00
Michael Bumann
9b292398da Add sentry notification to invoice subscription 2022-01-24 23:05:08 +01:00
Michael Bumann
55b7943579 Do not handle invoices not found in the subscription handler as errors
the app will get notfied of any invoice and not just the invoices we have created.
Thus we ignore the updates for invoices we do not know about. This is not an error
2022-01-24 23:04:53 +01:00
Michael Bumann
f6367b33a0 Merge pull request #69 from getAlby/bugfix/fix-invoices-without-description
Do not fail if invoice does not have a description
2022-01-24 20:12:29 +02:00
Michael Bumann
3053ad0549 Merge pull request #68 from getAlby/payinvoice-response
Better payinvoice response + DRY errors
2022-01-24 20:12:21 +02:00
Michael Bumann
906578ff57 Merge pull request #67 from getAlby/do-not-return-initialized-invoices
Do not return invoices that are in the initialized state
2022-01-24 20:12:12 +02:00
Michael Bumann
a2c75110c2 Log correct error 2022-01-23 21:06:34 +02:00
Michael Bumann
95a979a05f Merge branch 'main' into feature/configurable-port 2022-01-23 19:42:52 +02:00
Michael Bumann
bbada328d5 Longer login/passwords 2022-01-22 23:59:05 +01:00
Michael Bumann
436baeeccb Merge pull request #64 from getAlby/invoice-update-subscriptions
First draft to subscribe for LND invoice update
2022-01-23 00:22:46 +02:00
Michael Bumann
f6559a6a0c Make port configurable 2022-01-22 23:11:13 +01:00
Michael Bumann
edd2abedfb Do not fail if invoice does not have a description 2022-01-22 23:05:21 +01:00
Michael Bumann
35e7da2f30 Search for correct state 2022-01-22 22:57:14 +01:00
Michael Bumann
af8c72d2c9 Store invoice expiry and use search for not expired invoices in the invoice subscription
When subscribing for invoice updates we only subscribe to not expired invoices.
We assume expired invoices will never get paid.
2022-01-22 21:11:19 +01:00
Michael Bumann
891dd8394c DRY up error responses 2022-01-22 20:38:14 +01:00
Michael Bumann
1359d97d6a Better payinvoice response
This is not exactly the response that lndhub gives but it should be good enough
2022-01-22 19:20:40 +01:00
Michael Bumann
39e162088a Do not return invoices that are in the initialized state
Initialized is an internal state before the invoice was created on LND.
We should not expose those. If an invoice is in that state it means it is either currently created or something went wrong.
2022-01-22 15:44:05 +01:00
Michael Bumann
d90a695172 Context how do they work... 2022-01-22 13:32:15 +01:00
Michael Bumann
b54f04701f Start invoice subscription from the last unsettled invoice
We want to get updates starting from those invoices.
This allows us to catch up in case the app was offline while some invoices got settled
2022-01-22 13:24:51 +01:00
Michael Bumann
c75e703d80 Try reconnecting on invoice subscription errors 2022-01-22 12:57:00 +01:00
kiwiidb
366f66a2e2 use bun.Tx to avoid db locked err 2022-01-22 10:33:54 +01:00
Michael Bumann
71eabae443 Split up process invoice updates 2022-01-21 21:29:16 +01:00
Michael Bumann
12dbb48c8d First draft to subscribe for LND invoice update 2022-01-21 20:57:41 +01:00
Michael Bumann
3e088a7652 Pass invoice description hash string to LND 2022-01-21 17:40:52 +01:00
Michael Bumann
2606403489 Use tx to call do the db updates 2022-01-21 15:12:08 +01:00
Michael Bumann
43aba70dd8 Fix invoice preimages for internal payments
We create the preimage on incoming invoices. If it is an internal incoming payment (meaning from one user to another user) we use that preimage and save it on the outgoing invoice.
This makes sure we can give wallets the correct preimage for a payment request even though no lightning transaction happened
2022-01-21 13:56:02 +01:00
Michael Bumann
89acf29b24 cleanup 2022-01-21 12:25:19 +01:00
Michael Bumann
228edcbe39 Return user invoices
and maybe correctly encode the Buffers?
2022-01-21 11:49:08 +01:00
Michael Bumann
2097807c85 Support Amount values as string/integer in request JSON 2022-01-21 11:15:35 +01:00
Michael Bumann
289d7405f1 Rollback only in the SendPayment call
this one handles the transactions which is passed to the SendPaymentSync and SendInternalPayment call
2022-01-20 19:00:49 +01:00
Michael Bumann
9ed269dedf Split up functions for internal vs. external payments 2022-01-20 18:31:03 +01:00
Michael Bumann
7d955a1d7b Support self-payments
If the destination of the invoice is our node we only create internal transaction entries and do not call the underlaying lightning node
2022-01-20 16:50:26 +01:00
Michael Bumann
90a686677f Save invoice destination
And save the node pubkey in the service to make it usable
2022-01-20 15:41:50 +01:00
Michael Bumann
3a67f86a34 Merge main 2022-01-20 14:15:40 +01:00
Michael Bumann
6822b274e5 Add check payment endpoint 2022-01-20 13:58:46 +01:00
kiwiidb
d3466aa0cc remove pointer to interface 2022-01-20 13:24:59 +01:00
Michael Bumann
70a7e1a8eb Add DB constraints to check for user balances 2022-01-20 02:03:51 +01:00
Michael Bumann
d4183c100b Add payinvoice endpoint 2022-01-20 01:57:31 +01:00
Michael Bumann
1db6f77dd9 Add check payment endpoint 2022-01-19 22:11:24 +01:00