chill117 / lnurl-node

Flexible lnurl server implementation with API and CLI implemented in nodejs.
MIT License
98 stars 26 forks source link

Error when running with config file #34

Closed prusnak closed 2 years ago

prusnak commented 3 years ago

Steps to reproduce:

  1. install lnurl locally npm install lnurl (without -g)
  2. create config file as per documentation
  3. run ./node_modules/.bin/lnurl server --configFile ./config.json
  4. observe the following error:
internal/validators.js:124
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:124:11)
    at Object.join (path.js:1148:7)
    at Server.prepareStore (/home/bitcoin/node_modules/lnurl/lib/Server.js:580:25)
    at new Server (/home/bitcoin/node_modules/lnurl/lib/Server.js:34:20)
    at Object.createServer (/home/bitcoin/node_modules/lnurl/index.js:7:10)
    at Command.<anonymous> (/home/bitcoin/node_modules/lnurl/cli.js:269:9)
    at Command.listener [as _actionHandler] (/home/bitcoin/node_modules/commander/lib/command.js:466:17)
    at /home/bitcoin/node_modules/commander/lib/command.js:1170:65
    at Command._chainOrCall (/home/bitcoin/node_modules/commander/lib/command.js:1088:12)
    at Command._parseCommand (/home/bitcoin/node_modules/commander/lib/command.js:1170:27) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Oddly enough, this works when I specify options from config file manually on the command line. šŸ¤·

I am using NodeJS 14.x

prusnak commented 3 years ago

Edit: it seems I observe the same error even when I install lnurl globally (npm install -g lnurl)

chill117 commented 3 years ago

It looks like your config.json is missing "store". It might not be so intuitive, but the store and lightning configurations are defined as objects in the config.json file. For example:

{
    "host": "localhost",
    "port": 3000,
    "url": "http://localhost:3000",
    "endpoint": "/lnurl",
    "auth": {
        "apiKeys": []
    },
    "lightning": {
        "backend": "lnd",
        "config": {}
    },
    "store": {
        "backend": "memory",
        "config": {}
    }
}
prusnak commented 3 years ago

You are correct. It was indeed missing store. Thanks!

I got confused, because when passing arguments via command-line, the lnurl command correctly uses default values for store. So I assumed it is not mandatory to add this to the config json file.

chill117 commented 3 years ago

I think it's a reasonable expectation that the defaults should be used when providing a config file. I'll mark that as a bug and fix it when I have a bit of time. Thanks for bringing it to my attention.

chill117 commented 2 years ago

Fixed and will be in the next release.