lightninglabs / lightning-terminal

Lightning Terminal: Your Home for Lightning Liquidity
MIT License
508 stars 90 forks source link

How to copy `admin.macaroon` to my local machine? #285

Closed LAMike310 closed 2 years ago

LAMike310 commented 2 years ago

I'm trying to connect to data on my cloud node from my local machine. I copied the tls.cert locally, and then I tried to copy the macaroon text through VIM, but when I copy and paste from VIM, I don't think the correct data is being transferred over. When I run xxd -p -c2000 admin.macaroon on my local machine and cloud node, the length doesn't match up.

One way I tried to copy over the macaroon was to take the hex output and remake it into a string w/ this script:

const fs = require('fs');

const convert = (from, to) => str => Buffer.from(str, from).toString(to)
const utf8ToHex = convert('utf8', 'hex')
const hexToUtf8 = convert('hex', 'utf8')
const macaroon_hex = '......'
fs.writeFileSync('./admin.macaroon', hexToUtf8('{macaroon_hex}'))

The hex didn't match up either, but is this still a valid way of copying over the .macaroon file?

guggero commented 2 years ago

That's a weird way of copying a file. Did you try something like scp?

Anyway, you can use xxd for doing the reverse as well:

# cloud machine
xxd -p -c9999 admin.macaroon > admin.hex

# local machine
cat admin.hex | xxd -p -r > admin.macaroon

Closing as this isn't exactly an issue with lnd. Please use the Discussions section or join our Slack server for troubleshooting questions.

LAMike310 commented 2 years ago

Please excuse my hacks @guggero, I barely know javascript so trying anything on the command line is foreign to me.

In this case, the issue is directly linked to LND because to my knowledge, it is the only project using the .macaroon format. If it was something like JSON, it wouldn't be a problem copying over the data from vim.

I opened a discussion for that here: https://github.com/lightningnetwork/lnd/discussions/6044