Intro
I wanted to know how to get a Bech32 version of my LND Lightning Node's Public Key, for use in DNS SRV records outlined in the Bolt-12 proposal at https://github.com/tyzbit/lightning-rfc/blob/bolt12-node-dns-advertisement/12-node-dns-advertisement.md
There's an App for that!
This didn't seem easily done in LND command-line, however I found the following tool:
- https://github.com/nym-zone/bech32
- https://bitcointalk.org/index.php?topic=2664728.msg27178628#msg27178628
Installation
To install, clone to a directory as follows:
git clone https://github.com/nym-zone/bech32
cd bech32
However I get an error on the documented instructions.
Input:
make -f Makefile.linux && make -f Makefile.linux check && sudo make -f Makefile.linux install
Output:
make: Nothing to be done for 'all'. make: *** No rule to make target 'check'. Stop.
So instead I went with the following which worked out fine.
Input:
make -f Makefile.linux && sudo make -f Makefile.linux install
Output:
cc -O2 -std=c99 -c -o bech32.o bech32.c
cc -O2 -std=c99 -c -o segwit_addr.o segwit_addr.c
cc -o bech32 bech32.o segwit_addr.o
[sudo] password for bretton:
install bech32 /usr/local/bin
install bech32.1 /usr/local/man/man1
Then to encode my LN node's public key to a Bech32 string I'll use:
Outline:
bech32 -e -h <human readable part> <my-node-pubkey>
For the human readable part we're going to use ln
for Lighting Network. As follows:
Input:
bech32 -e -h ln 02262bbc21c171bc91a1d6bbf89571c95873849b9a60d3ea9671b777d852d39ecd
Output
ln1qgnzh0ppc9cmeydp66al39t3e9v88pymnfsd865kwxmh0kzj6w0v694s62v
I can now do this for all my lightning nodes and update DNS accordingly.
Useful
Find your node at https://www.robtex.com/lightning/node/ and there is output to check what is expected from DNS, along with validation once it's setup.
There is also a python library here: https://github.com/sipa/bech32/tree/master/ref/python