Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Key [read-only] #328

Open
PraiaBitcoin opened this issue Nov 24, 2021 · 7 comments
Open

API Key [read-only] #328

PraiaBitcoin opened this issue Nov 24, 2021 · 7 comments

Comments

@PraiaBitcoin
Copy link

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
Copy link

up

@xraid
Copy link
Contributor

xraid commented Nov 24, 2021

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 ...

@as-schug
Copy link

as-schug commented Dec 1, 2021

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
Copy link
Contributor

xraid commented Dec 2, 2021

You could also try use the API call :

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

that would return status of decoded invoice string

@godSaysHODL
Copy link

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
Copy link

#291

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

@xraid
Copy link
Contributor

xraid commented Jan 30, 2022

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

  • create a new Lightning wallet with 'lndhub-invoice-only' url:6000 in settings for new wallet
  • create a invoice
  • pay invoice
  • try send from wallet (where an error would occur !!!)
  1. 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 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants