Add LndHub wallets #33

Merged
raucao merged 13 commits from feature/lndhub into master 2021-11-22 23:04:19 +00:00
Owner

This adds LndHub Lightning wallets and wallet setup UI for user accounts. Also adds lnurl-pay endpoints to support lnurl-based payments, and one of the endpoints can also be proxied to for the Lightning Address .well-known URLs.

The latter means that, as soon as the addresses are enabled, you can easily send sats to any Kosmos user address, e.g. from resolving your XMPP contacts' JIDs. However, that is not part of this PR, but only the wallets themselves, which you can set up to use with Blue Wallet, as well as the lnurl-pay endpoints for generating invoices from URLs.

I tested it with our production LndHub, but we'll have to add something for simple development testing (local lndhub against remote LND I guess).

Deployment

There's a Rake task for generating wallets for all users via Sidekiq jobs, after this code has been deployed to production.

bundle exec rails lndhub:generate_wallets

Caveat

CI for this repo is currently broken, but not due to code changes in the repo. I created an issue for that in the Chef repo. You should be able to run the suite locally without problems.

refs #34

This adds [LndHub](https://github.com/BlueWallet/LndHub) Lightning wallets and wallet setup UI for user accounts. Also adds [lnurl-pay](https://github.com/fiatjaf/lnurl-rfc/blob/luds/06.md) endpoints to support lnurl-based payments, and one of the endpoints can also be proxied to for the [Lightning Address](https://lightningaddress.com/) `.well-known` URLs. The latter means that, as soon as the addresses are enabled, you can easily send sats to any Kosmos user address, e.g. from resolving your XMPP contacts' JIDs. However, that is not part of this PR, but only the wallets themselves, which you can set up to use with [Blue Wallet](https://bluewallet.io/), as well as the lnurl-pay endpoints for generating invoices from URLs. I tested it with our [production LndHub](https://lndhub.kosmos.org/), but we'll have to add something for simple development testing (local lndhub against remote LND I guess). ### Deployment There's a Rake task for generating wallets for all users via Sidekiq jobs, after this code has been deployed to production. bundle exec rails lndhub:generate_wallets ### Caveat CI for this repo is currently broken, but not due to code changes in the repo. I created [an issue for that](https://gitea.kosmos.org/kosmos/chef/issues/352) in the Chef repo. You should be able to run the suite locally without problems. refs #34
raucao added 1 commit 2021-11-20 21:31:11 +00:00
raucao changed title from WIP: Add LndHub wallets to Add LndHub wallets 2021-11-20 21:52:46 +00:00
raucao changed title from Add LndHub wallets to WIP: Add LndHub wallets 2021-11-20 21:53:00 +00:00
raucao added 1 commit 2021-11-20 22:14:25 +00:00
Add wallet page
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is failing
0a1052fcb7
With setup code to connect Blue Wallet to Kosmos account wallets
raucao added 1 commit 2021-11-21 19:28:37 +00:00
Fix small issue with turbolinks
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
21c6ebc137
The JS was run again, and failed to assign variables using `const` then.
raucao added 1 commit 2021-11-21 21:34:35 +00:00
Formatting
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
3c350155de
raucao added 1 commit 2021-11-21 22:48:11 +00:00
Show available balance on wallet page
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
884070a3cb
raucao added 1 commit 2021-11-22 21:41:53 +00:00
Add LndHub service, lnurl-pay endpoints
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is failing
dbc811b840
Enables the lnurl-pay payment workflow
raucao added 1 commit 2021-11-22 21:52:02 +00:00
Don't overwrite existing lndhub wallet credentials
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is failing
8662a4c8c1
raucao added 1 commit 2021-11-22 22:19:34 +00:00
Configure LndHub for production
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
e2ee33a1da
raucao added 1 commit 2021-11-22 22:23:06 +00:00
Add Rake task for generating wallets
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
4f20cd0d0a
raucao added 1 commit 2021-11-22 22:24:57 +00:00
Adjust spec for new development config
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
bfa38ad7b2
raucao added 1 commit 2021-11-22 22:26:15 +00:00
Remove obsolete comment
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
1078c034ad
raucao added 1 commit 2021-11-22 22:29:33 +00:00
Remove obsolete files
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
40e5c3609e
raucao changed title from WIP: Add LndHub wallets to Add LndHub wallets 2021-11-22 22:29:47 +00:00
raucao requested review from bumi 2021-11-22 22:37:06 +00:00
bumi approved these changes 2021-11-22 22:56:10 +00:00
bumi left a comment
Owner

looks good to me.
utACK

looks good to me. utACK
@ -0,0 +9,4 @@
maxSendable: 1000000,
minSendable: 1000,
metadata: metadata(@user.address),
commentAllowed: 255
Owner

we should set this to 0 because we do not allow the payer to send a comment with the payment.

we should set this to `0` because we do not allow the payer to send a comment with the payment.
raucao added 1 commit 2021-11-22 23:03:49 +00:00
Do not allow comments for lnurlp senders
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
bf76ac55ee
raucao merged commit 25ddab9241 into master 2021-11-22 23:04:19 +00:00
raucao deleted branch feature/lndhub 2021-11-22 23:04:27 +00:00
galfert approved these changes 2021-11-22 23:26:16 +00:00
galfert left a comment
Owner

Nice. That looks pretty dope 👍 Looking forward to using it.

Haven't tested it locally, but code looks all good to me.

Just left one comment/question.

Nice. That looks pretty dope 👍 Looking forward to using it. Haven't tested it locally, but code looks all good to me. Just left one comment/question.
@ -0,0 +49,4 @@
def validate_amount(amount)
if amount > 1000000 || amount < 1000
render json: { status: "ERROR", reason: "Invalid amount" }
Owner

Shouldn't this also give an error response code? Maybe 422?

Shouldn't this also give an error response code? Maybe 422?
Author
Owner

You would think so, but no. That's how ldnhub clients are expected to implement errors. ;)

You would think so, but no. That's how ldnhub clients are expected to implement errors. ;)
Owner

WHUT?

WHUT? ![](https://storage.5apps.com/galfert/public/shares/170629-1354-lebowski.gif)
Owner

the lnurl spec specifically says to ignore HTTP status codes :( - no idea why... but because of that it's better to return a 200

the lnurl spec specifically says to ignore HTTP status codes :( - no idea why... but because of that it's better to return a 200
bumi reviewed 2021-11-23 19:12:34 +00:00
@ -0,0 +20,4 @@
validate_amount(amount)
payment_request = @user.ln_create_invoice({
amount: amount,
Owner

this must be amount/1000 - amount is in msats but we create invoices for sats.

this must be `amount/1000` - amount is in msats but we create invoices for sats.
Sign in to join this conversation.
No description provided.