Skip to content

Instantly share code, notes, and snippets.

Last active July 13, 2018 15:45
What would you like to do?
Convert pubkey from lightning node into Bech32 format for (proposed) Bolt-12 DNS SRV record usage


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

There's an App for that!

This didn't seem easily done in LND command-line, however I found the following tool:


To install, clone to a directory as follows:

git clone
cd bech32

However I get an error on the documented instructions.


make -f Makefile.linux && make -f Makefile.linux check && sudo make -f Makefile.linux install


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.


make -f Makefile.linux && sudo make -f Makefile.linux install


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:


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:


bech32 -e -h ln 02262bbc21c171bc91a1d6bbf89571c95873849b9a60d3ea9671b777d852d39ecd



I can now do this for all my lightning nodes and update DNS accordingly.


Find your node at 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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment