BlueWallet / LndHub

Wrapper for Lightning Network Daemon. It provides separate accounts for end-users
http://LndHub.io
MIT License
778 stars 197 forks source link

API Key [read-only] #328

Open PraiaBitcoin opened 2 years ago

PraiaBitcoin commented 2 years ago

Here at Bitcoin Beach Brazil, we are using LND Hub and Bluewallet.

Now, we are trying to generate some invoices with LNDHUB API.
All goes fine, but we are missing a great API feature, that is, a read-only API Key.
A API Key that only generates and checks the status of that invoice.

It would be a great feature. []'s Fernando

as-schug commented 2 years ago

up

xraid commented 2 years ago

try use lncli on LND machine :

lncli decodepayreq <invoice to be decoded>

lncli lookupinvoice <r_hash of decoded invoice>

lncli lookupinvoice <r_hash of decoded invoice> | grep state

and maybe make a script of above dance ...

as-schug commented 2 years ago

try use lncli on LND machine :

lncli decodepayreq <invoice to be decoded>

lncli lookupinvoice <r_hash of decoded invoice>

lncli lookupinvoice <r_hash of decoded invoice> | grep state

  • "state": "OPEN",
  • "state": "SETTLED",

and maybe make a script of above dance ...

Thank you for your help, but your solution does not help to solve our problem. We need to create an invoice, but we only have a full (read/write) url for lndhub. Luckly we solved that with LNbits. LNbits has lndhub plugin so we can have a read only (invoice) url. It would be great if lndhub has support for that in its own protocol.

xraid commented 2 years ago

You could also try use the API call :

GET LndHub-URL/decodeinvoice { invoice: <invoice> }

that would return status of decoded invoice string

godSaysHODL commented 2 years ago

I think I understand what you're asking for and this is genius. Needs to happen. So maybe LNDhub could generate a password that only it knows (different for each node), and run any lightning wallet string through a hashing function using that password. The resulting hash could be used as an API key. When feeding this hash into a normal API call rather than the "account:password" authorization, LNDhub could decode which wallet and password to use, but because it was that format, know not to allow spending, only generating invoices to recieve money.

You could literally implement things like the strike tips that are on twitter with this API. WOULD BE MASSIVE. Or fork plebpay as well.

Is this sort of what you were thinking?

godSaysHODL commented 2 years ago

https://github.com/BlueWallet/LndHub/pull/291

This pull request has the functionality I think you would need for this feature. It has not been merged though.

xraid commented 2 years ago

For a quick MVP of above described functionality one could do the following --takes 10 minutes.

1) Copy folder of a already verified to run 'lndhub' cp -r lndhub lndhub-invoice-only

2) Comment out 'line 207' in 'lndhub-invoice-only/controllers/api.js' // router.post('/payinvoice', async function (req, res) {

3) Change 'line 51' in 'lndhub-invoice-only/index.js' where port is 3000 to port 6000 const bindPort = process.env.PORT || 6000;

4) Start the instance of 'lndhub-invoice-only', that can run 'side by side' with a regular 'lndhub' instance

5) Verify in Bluewallet

6) Profit

The above enables Node operator of a 'lndhub-invoice-only' instance to let people create invoices where funds is controlled by the Node Operator, where eXtracurricular is make a script for create a admin account and a new endpoint in 'lndhub-invoice-only/controllers/api.js', that would show balances of all accounts in instance that has memo flagged X: in line 104 of 'lndhub-invoice-only/controllers/api.js' add pre identifier X: in invoice creation ...