lnbits / lndhub

Access lnbits from BlueWallet or Zeus
MIT License
2 stars 6 forks source link

Support wallet creation via POST to /lndhub/ext/create #10

Open jimbojw opened 1 year ago

jimbojw commented 1 year ago

Currently, lnbits's lndhub extension allows existing lnbits wallets to be accessed from BlueWallet. However, this extension does not appear to allow creating wallets directly from BlueWallet.

When BlueWallet attempts to create a new wallet, it issues a POST request to /create under the LndHub server path (which for lnbits is /lndhub/ext). Currently this returns a 404 not found because the route is not implemented. Instead, would it be possible to create a new lnbits wallet and return the connection information?

Here is the current /create implementation from LndHub:

router.post('/create', postLimiter, async function (req, res) {
  logger.log('/create', [req.id]);
  // Valid if the partnerid isn't there or is a string (same with accounttype)
  if (! (
        (!req.body.partnerid || (typeof req.body.partnerid === 'string' || req.body.partnerid instanceof String))
        && (!req.body.accounttype || (typeof req.body.accounttype === 'string' || req.body.accounttype instanceof String))
      ) ) return errorBadArguments(res);

  if (config.sunset) return errorSunset(res);

  let u = new User(redis, bitcoinclient, lightning);
  await u.create();
  await u.saveMetadata({ partnerid: req.body.partnerid, accounttype: req.body.accounttype, created_at: new Date().toISOString() });
  res.send({ login: u.getLogin(), password: u.getPassword() });
});

https://github.com/BlueWallet/LndHub/blob/master/controllers/api.js#L142

talvasconcelos commented 1 year ago

Should we allow this? @callebtc @motorina0 @arcbtc ?

motorina0 commented 1 year ago

I don't see why not

talvasconcelos commented 1 year ago

@jimbo you want the hability to create new wallets, on the same user, right?

jimbojw commented 1 year ago

I don’t know what you mean by same user. Probably yes?

I made this ticket last year when I was looking to upgrade my family from on-chain to uncle jimbo’s shared Lightning node. Based on my experimentation at the time, lnbits worked except that wallet creation still had to go through the web interface. But I wanted my family to be able to create their wallets directly through Blue Wallet, which was not possible due to the missing /create endpoint as described in the bug.

I’m not terribly familiar with lnbits. This was the only reason I attempted to use it.

talvasconcelos commented 1 year ago

Humm, i don't think we can do that with the lndhub extension. As it stands, as far as i can tell, the extension allows you to import and use YOUR LNbits wallet on Bluewallet or Zeus. To create a wallet, you'd need to be running LNDhub. @arcbtc ?

LNbits is all you need for Uncle Jim. After creating a wallet, they can use LNDhub extension to use in BW, or use LNbits as an app (PWA) if they open it on a mobile phone!

If this makes sense, please consider closing the issue.