Skip to content

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

@jimbojw

Description

@jimbojw

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions