Simulate your first Lightning transaction on the Bitcoin regtest network Part 3 (MacOS)
📜Objective
The goal of this article is to help you
Connect the lightning nodes to form a peer
Open a payment channel between
lnd1andlnd2nodesAdd some confirmations to the block that the channel opening transaction was mined on
Check the list of channels to ensure our channel is ready and funded
Create an invoice on
lnd2inspect the invoice created above from
lnd1Pay or satisfy the invoice created by
lnd2vialnd1Close the payment channels, kill both Bitcoin and lightning daemons
Celebrate the success of this tutorial with a cold bottle of beer.
📜 Introduction
Hey there, welcome to the final part of this 3 part series on simulating your first lightning transaction.

If you are as happy as I am to finally wrap up the series, let's get right to it....
Prerequisites
To be successful in this tutorial in case if you haven't already gone through the previous parts leading up to this one, ensure you;
✅ checkout Part 1
✅ checkout Part 2
✅ Have a running Bitcoin network daemon (on regtest)
✅ Have two active and running lightning node instances as lnd1 and lnd2
If the above prerequisites list has been satisfied then you can proceed beyond this point.
📜 Connect the lightning nodes to form a peer
Now that both of our nodes are ready for some action, we need to connect them to form a peer-to-peer network this would enable our nodes to communicate with each other on the network by opening and closing channels.
From lnd1 run
command:
output:
From lnd2 run the command below to get its identity_pubkey which we would use in connecting the node to lnd1
command:
output:
Now let's connect lnd2 to lnd1 by passing the identity_pubkey, IP address and port
command:
output:
Let's check for the list of peers once again at lnd1
command:
output:
🎉 Both Nodes are now successfully connected as a peer on our local lightning network.

📜 Open a payment channel between lnd1 and lnd2 nodes
lnd1 and lnd2 nodesNow let's open up a payment channel between lnd1 and lnd2
Quick note: A payment channel on the lightning network is a two-way connection between two parties (lightning nodes) that enables them to exchange bitcoin.
To create a payment channel between lnd1 and lnd2, we'll be making use of the pub_key of lnd2 and we'll then be funding the channel with 100,000 SAT. the 100,000 SAT is lnd1's contribution to the channel
command:
output:
📜 Mine some blocks to increase the confirmations for the Channel opening transaction
Once the channel has been created and lnd1's BTC contribution has been added to the channel, we need to mine/generate some blocks to increase confirmations for the Channel opening transaction.
command:
output:
📜 Check the list of channels
Run the command below to check the list of active channels and to confirm that the channel between both nodes is well-funded and ready.
command:
output:
📜 Create an invoice on lnd2
lnd2Now that we have confirmed that our channel is ready for transactions, let's go ahead and create a payable invoice for an amount of 50,000 SAT on lnd2
command:
output:
Let's quickly inspect or confirm the details of this newly created invoice from lnd1 by making use of the invoice's payment_request
command:
output:
📜 Pay or satisfy the invoice created by lnd2 via lnd1
lnd2 via lnd1Time for lnd1 to pay up 🧾

Run the command below and follow the prompts to confirm payment
command:
output:
Now that we have made payment, let's look up the invoice on lnd2 we'll be using the payment hash above
command:
output:
📜 Close the payment channel, kill both Bitcoin and lightning daemons
"Eventually, all good things must come to an end"

We are finally done with all lightning transactions so let's go ahead and close the payment channel and kill all running lightning and Bitcoin daemons as we close for the day.
Run the command below from any of the two nodes
command:
output:
Check the list of channels
command:
output:
Run the command below to kill all running daemons
command:
output:
📜 Conclusion
Finally, an amazing end to a three part journey.

I hope this article helped you gain some hands-on experience in working with the lightning network. Remember, Lightning payments are faster, cheaper and less complex than the conventional bitcoin transaction. see you in the next one 👋🏿
Last updated