lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.73k stars 2.09k forks source link

Setting up lightningnetwork #5011

Closed pablomendezroyo closed 3 years ago

pablomendezroyo commented 3 years ago

Hi there, I come from another open source project: DAppNode. Said in one phrase, DAppNode is a docker ecosystem for blockchain projects that makes interactions easier for users. We incentivate users to run their own node.

I am currently coding a DAppNode package for lightningnetwork, also using Ride-The-Lightning to provide the user a UI. Would be great if I can get some help from you to finish setting it up.

My environment:

I have already a bitcoin node (as a dappnode package) running on a container. Also, I have a compose with 2 services (1 for lightningnetwork and the other one Ride-The-Lightning). I have set up both services using official Docker images (shahanafarooqui/rtl:0.10.0 and lightninglabs/lnd:v0.12.0-beta) and adding their corresponding config files ( RTL-Config.json and lnd.conf) respectively.

When initialize the compose and set up a new wallet, seems to be working fine, successfully communicate each other as well with the bitcoin node.

Issue

After loggout and login again, I have to unlock the wallet. When unlock it, it starts as usual but after a few seconds I get the following errors from the lightning network daemon:

lnd_1  | 2021-02-11 12:30:34.876 [INF] CHBU: Updating backup file at ~/.lnd/data/chain/bitcoin/mainnet/channel.backup
lnd_1  | unable to start server: unable to refresh backup file: unable to update multi backup: unable to create temp file: open ~/.lnd/data/chain/bitcoin/mainnet/temp-dont-use.backup: no such file or directory
lnd_1  | 2021-02-11 12:30:34.879 [ERR] LTND: unable to start server: unable to refresh backup file: unable to update multi backup: unable to create temp file: open ~/.lnd/data/chain/bitcoin/mainnet/temp-dont-use.backup: no such file or directory

Not sure where does temp-dont-use.backup come from, it is not defined in any env variable nowhere. I have tried to unlock it using the cli: lncli unlock but the same problem. My backup file path is: backupfilepath=~/.lnd/data/chain/bitcoin/mainnet/channel.backup

I would really appreciate your help and sorry for the long extension of my issue.

Love your project :heart:

Roasbeef commented 3 years ago

If you don't set the backup path manually does it work?

guggero commented 3 years ago

This is because we forgot to expand the path for that flag. I've created a fix. Until then, try with a full, absolute path instead of the tilde (/home/<youruser>/.lnd instead of ~/.lnd).

pablomendezroyo commented 3 years ago

Hey! thank you all for the quick response

Seems to be in the good direction, now I have other different error:

unable to start server: unable to refresh backup file: unable to extract on disk encrypted SCB: read /root/.lnd/data/chain/bitcoin/mainnet/channel.backup: is a directory

More info about my setup:

Dockerfile

FROM lightninglabs/lnd:v0.12.0-beta
COPY ./lnd.conf /root/.lnd/
EXPOSE 8080

lnd.conf (aplication options)

[Application Options]
datadir=/root/.lnd/data
logdir=/root/.lnd/logs
maxlogfiles=3
maxlogfilesize=10
tlscertpath=/root/.lnd/tls.cert
tlskeypath=/root/.lnd/tls.key
letsencryptdir=/root/.lnd/letsencrypt
adminmacaroonpath=/root/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
readonlymacaroonpath=/root/.lnd/data/chain/bitcoin/mainnet/readonly.macaroon
invoicemacaroonpath=/root/.lnd/data/chain/bitcoin/mainnet/invoice.macaroon
listen=0.0.0.0:9735
rpclisten=0.0.0.0:10009
restlisten=0.0.0.0:8080
debuglevel=debug,PEER=info
maxpendingchannels=10
backupfilepath=/root/.lnd/data/chain/bitcoin/mainnet/channel.backup

Is there any documentation about the API that exposes LND? I would like to test myself this API since I'm having some issues between the communication of RTL and LND, saying:

rtl_1  | ERROR: GetInfo(17) => LND Get info failed due to bad or missing macaroon!
guggero commented 3 years ago

How exactly are you starting the docker container? Sounds to me like you're mounting a volume incorrectly and docker creates folder where lnd expects files.

Also just a hint: you don't need to set any of those paths if you just set lnddir=/root/.lnd. All other paths will be placed in their default location below that dir then.

pablomendezroyo commented 3 years ago

Yes! good point, I did not found info about which data should be tracked in docker volumes so I just defined the ones I have considered relevant.

docker-compose

version: "3.4"
networks:
  default:
    external:
      name: dncore_network
services:
  lnd:
    build: ./buildLnd
    image: "lnd.lightning-network.dnp.dappnode.eth:0.1.0"
    ports:
      - "9735:9735"
    environment:
      ALIAS: ""
      EXT_IP: ""
      COLOR: "#5ACDC5"
    volumes:
      - 'lnd_data:/root/.lnd/data'
      - 'lnd_backup:/root/.lnd/data/chain/bitcoin/mainnet/channel.backup'
      - 'lnd_macaroon:/root/.lnd/data/chain/bitcoin/mainnet/admin.macaroon'
    restart: always

  rtl:
    build: ./buildRtl
    image: "rtl.lightning-network.dnp.dappnode.eth:0.1.0"
    volumes:
      - 'rtl_backup:/shared/lnd/backup'
    restart: always

volumes:
  lnd_data: {}
  lnd_backup: {}
  lnd_macaroon: {}
  rtl_backup: {}

Related to the paths, I know it (you have well explained that those paths are set by default), anyway Just wanted to write them down to know exactly where is everythin stored.

guggero commented 3 years ago

This is your problem:

      - 'lnd_backup:/root/.lnd/data/chain/bitcoin/mainnet/channel.backup'
      - 'lnd_macaroon:/root/.lnd/data/chain/bitcoin/mainnet/admin.macaroon'

A volume is always a folder, not a file. Try this:

      - 'lnd_backup:/root/custom-backup-path'
      - 'lnd_macaroon:/root/custom-macaroon-path'

And then in your lnd.conf:

adminmacaroonpath=/root/custom-macaroon-path/admin.macaroon
backupfilepath=/root/custom-backup-path/channel.backup
pablomendezroyo commented 3 years ago

Oh men, much appreciate your help now I fully understand how to set it up.

Amazing support

Thanks again!