C-Otto / rebalance-lnd

A script that can be used to balance lightning channels of a lnd node
MIT License
343 stars 82 forks source link

Support for LND@BTCPay Server #321

Open petzsch opened 10 months ago

petzsch commented 10 months ago

While trying to help a BTCPay Server user run rebalance-lnd on their instance, we came across the following issue:

Here you expect a very specific path for the admin.macaroon, however it also loads the tls.cert from the lnd_dir : https://github.com/C-Otto/rebalance-lnd/blob/ab400de7cffe9cecf7c893643486dc6b18d4e961/lnd.py#L53

Here is the folder contents for btcpayserver's generated_lnd_bitcion_datadir volume:

root@cryptonode:/var/lib/docker/volumes/generated_lnd_bitcoin_datadir/_data# ls
admin.macaroon  invoice.macaroon  lnd.conf  readonly.macaroon  tls.key
data            letsencrypt       logs      tls.cert

if you try to find the admin.macaroon in data/chain/bitcoin/{network}/ you'll find the following:

root@cryptonode:/var/lib/docker/volumes/generated_lnd_bitcoin_datadir/_data/data/chain/bitcoin/mainnet# ls -al
total 1484
drwx------ 2 root root    4096 Aug 30 17:39 .
drwx------ 3 root root    4096 Apr 16 10:07 ..
-rw-r--r-- 1 root root      83 Apr 16 10:08 chainnotifier.macaroon
-rw-r--r-- 1 root root      45 Aug 30 17:39 channel.backup
-rw-r--r-- 1 root root      91 Apr 16 10:08 invoices.macaroon
-rw------- 1 root root   20480 Aug 30 17:38 macaroons.db
-rw-r--r-- 1 root root      91 Apr 16 10:08 router.macaroon
-rw-r--r-- 1 root root      92 Apr 16 10:08 signer.macaroon
-rw------- 1 root root 1458176 Sep  3 15:45 wallet.db
-rw-r--r-- 1 root root     114 Apr 16 10:08 walletkit.macaroon
-rw-r--r-- 1 root root     274 Apr 16 10:07 walletunlock.json

To solve this, we would need a seperate config option to specifiy the admin.macroon file path, so that the rest still works.

Hope there is a simple solution to this problem.