Simulate your first Lightning transaction on the Bitcoin regtest network Part 1 (MacOS)
Objective
The goal of this article is to help you
configure the Bitcoin environment
create a Bitcoin wallet
create an address, give it a label
mine some blocks to that address
configure two Lightening nodes
📜 Introduction
This was me after I recently started my journey in Bitcoin development.

I felt so overwhelmed by the resources online mainly because I found out that certain information where either left out or now deprecated. so I was inspired to write my take on this topic because it confused me the most.
📜 Requirements
To be able to follow along, you must have both bitcoind and lnd installed.
Below are two articles that helped me through this topic's installation, setup, and research phases.
Their work heavily inspires this article and has made use of references appropriately.
⚙️ My system specs
Machine: MacBook Pro
Operating System: macOS Monterey
terminal: kitty
shell: ZSH
Editor: Neovim
Package Manager: Homebrew
📜 The boring but very important stuff

Before we get to copying and pasting stuff into our terminal(the fun part), let's look at what the internet has to say about the following:
The lightning network and how it interacts with the Bitcoin network
The various Bitcoin network modes.
"The Lightning Network is a second-layer protocol built on top of the Bitcoin blockchain. It enables faster and cheaper transactions by creating off-chain payment channels between users. These channels allow multiple transactions to occur without needing to be recorded on the main Bitcoin blockchain. Instead, only the opening and closing transactions of the channel are settled on the blockchain. This interaction reduces congestion on the Bitcoin network and enables microtransactions with almost instant settlement times."
📡 The Bitcoin testnet network mode
"It’s a public test blockchain where the bitcoin does not have a real-world value that works similarly to the mainnet blockchain. In this way, it is safe to test out some functionality." source: https://studygroup.moralis.io/
📡 The Bitcoin regtest network mode 👈🏿 (this is the mode we are going to be using)
*"Regtest (regression test) mode creates a local private blockchain where you can adjust the parameters to what you want. You usually use this when it is not needed to communicate with other peers and blocks. An example of what you can do with the parameters is you can create blocks instantly"*Source: https://studygroup.moralis.io/
📡 The Bitcoin signet network mode
*"Signet is a proposed new test network parallel to the Bitcoin network. Like testnet and regtest, developers would use signet as a testing environment. Unlike the Bitcoin mainnet or the other test networks, signet would use digital signatures to validate blocks, not a Proof-of-Work system."*Source: https://river.com/
Now to the good stuff:
⚙️ Configuring our Bitcoin environment

Step 1a
This part is very important. if you have gone over the Setting Up a Bitcoin/Lightning Network Test Environment as I suggested above you would realize that the author manually created a bitcoin.conf but we'll be using the one at /Users/user/Library/Application Support/Bitcoin/bitcoin.conf auto-generated while installing bitcoin core.
now let's open up the autogenerated bitcoin.conf file with our text editor
Add these settings below
Now, you can run your Bitcoin node service and the following commands from the terminal. Ensure your Bitcoin backend is all set and ready to run your lightning network.
Take note of the corresponding outputs to make sure you're on the right track. please note that I have truncated some outputs.
Start bitcoin service
Output:
ensure you are on regtest
output:
create a Bitcoin wallet
output:
Create an address (we'll be generating a legacy address)
**Quick note: ** A legacy address refers to a format for cryptocurrency addresses that was used in older versions of the blockchain protocol. For example, in Bitcoin, legacy addresses typically start with the number "1". These addresses are still functional but are being gradually phased out in favor of newer address formats like Segregated Witness (SegWit) addresses, which offer benefits like lower transaction fees and improved scalability.
output
Assign a label to the address generated above to make it easy to identify it
get a list of all our generated addresses
output
Mine some block to the address (This is important)
Quick note: I faced a sticky issue when trying to run my
lncli commandsand so after doing some research found a solution which was basically to generate some blocks check here to know more about the issue https://github.com/lightningnetwork/lnd/issues/1177#issuecomment-1100012559
output
Check our wallet info
Output
⚙️ Configuring two LND nodes
Step 1a
we'll be creating a base or root directory called .lnd using the mkdir Linux command. please note that this directory can be named anything you wish same
Create a configuration file and add the settings below then save it as lnd.conf in the .lnd1 directory.
Step 1b
Now just like in step 1a above, Create a configuration file add the settings below, and then save it as lnd.conf in the .lnd2 directory.
**Quick note: ** Notice that the config above has different ports and settings for network, RPC, and REST connections configured. well, to mention a few reasons:
Each LND instance needs to listen on different ports to avoid conflicts.
You might want
lnd1andlnd2to use different wallets or have different wallet configurations. _ You might configure different network settings for each LND instance. For example, one might be configured to run on theBitcoin mainnetwhile the other runs on theBitcoin testnetbut note that it is required that you run the two LN nodes on the same network for the sake of running transactions between them
Step 2
lastly, let's configure some aliases so let's open up ~/.zshrc with our favourite text editor once again
Now add this to the bottom.
This is the end of the first part of the series. we'll be going over some preliminary setup and configuration for a successful transaction between 2 lightning nodes in the next part
📜 Conclusion

you feel rushed, don't you? Don't worry It took me close to a week to understand this so it's fine if you don't entirely get what's going on for now. check out some of these useful links below chainquery: bitcoin-cli documentation
Last updated