Learning objectives:
- to be able to setup a sandbox to learn more about LND
- what is LND?
- what is c-lightning?
- why the need to install this on top of LND
- what are the commands (cli) use for?
- what are the use cases for the commands?
- how to do up a simple smart contract?
- understand what is meant by programmable money
- give 1 to 2 examples how layer 2 BTC can be used this way
- roll out a project to illustrate how layer 2 BTC is used this way
Resource materials:
- Setting up a full Bitcoin Lightning node and wallet
- slides
- #20: terminal basics
- #23: The Onion Router (TOR)
- slides
- LND Overview and Developer Guide
- software components –
- lnd – stands for Lightning Network Daemon
- manages a database, connects to peers, opens / closes channels, generates payment invoices, sends, forwards, and revokes payments, responds to potential breaches
- lncli
- opens up a command line interface for driving lnd
- lnd – stands for Lightning Network Daemon
- software components –
- alternatively, click
- Helpful references
- Understanding the Technical Side of Bitcoin
- Git
- Programming with Bitcoin Core and Lightning by Christopher Allen
- lightning-cli – work-in-progress
- The Bitcoin Lightning Network: A Technical Primer by Joe Kendzicky
- IDE
- JetBrains
- PyCharm
- Lightning Network Development for Modern Applications
- client and server
- bitcoin node and lightning network node
- Bitcoin
- Bitcoin Core – bitcoind
BTCD – btcd
- Lightning Network
- C-Lightning
- LND
- friendly and easy-to-use gRPC/REST API
- Eclair
- Bitcoin
- Chaincode Lightning Residency
- Working with lnd
- tutorial
- requirements: installation of Go, btcd, and lnd on simnet
- tutorial
Exercises: assuming that the setup is completed
- Running
- bitcoind or
- bitcoin-qt
can run either one (bitcoind , bitcoin-qt) not both
- Test whether bitcoind is running
- bitcoin-cli getblockchaininfo
- ps|grep bitcoind
- shutdown and power up
- controlling services
- Start: sudo systemctl start
- Restart: sudo systemctl restart
- The services names are: bitcoind,lightningd,btc-rpc-explorer,eps and spark-wallet
Questions:
- Node address – does the TOR hide the full node address?
- Tor Hidden Services and other – how to remote access the node and wallet in order to test out cli commands e.g.
- Node address does not accept incoming connections – do we need to open port and expose IP? –
- what abt TOR – what purpose does it serve?
- Test drive commands
- start lightningd
- lightning/lightningd/lightningd
- ~/lightning/cli$ ./lightning-cli []
- lightning/lightningd/lightningd
- lightning-cli help
- lightning-cli newaddr
- pay via any segwit HD (hierarchical deterministic) wallet
- lightning-cli connect id [host] [port]
- lightning-cli getinfo
- lightning-cli newaddr
- hands-on example: how to send lightning payments using the terminal?
- lightning-cli newaddr
- Layer 1 BTC transaction
- Bech32 – a segwit address format specified by BIP 0173)
- bc1 format
- lightning-cli listfunds
- lightning-cli connect
03e5f9d1935c67a029bf0a26af5f63109f4f4c45993a8f45177a8f2f39bcb46144 77.58.162.148 9735- nodeId@host:port
- lightning-cli list peers
- lightning-cli fundchannel
- lightning-cli listpeers
- lightning-cli decodepay
- lightning-cli pay
- lightning-cli listpayments
- lightning-cli newaddr
- start lightningd
- Down the rabbit hole … and took a detour
- need to take a look into bitcoin-cli and bitcoind, together with chapter 3 of Andreas Antonopoulos’ book Mastering Bitcoin
- elliptic curve cryptography – generating the public key in Python
- bitcoin scripts
- using python to test drive the command-line interface (cli)
- need to take a look into bitcoin-cli and bitcoind, together with chapter 3 of Andreas Antonopoulos’ book Mastering Bitcoin
- Back from the rabbit hole … to setup similar environment for writing Lightning Network applications in python
- c-lightning (Elements Project)
- library – pylightning
- tool for spinning up a Lightning Network topology for testing and demo’ing LN applications
- First python code
- Import library/module
- from lightning import LightningRpc
- Create an instance of the LightningRpc object
- l1 = LightningRpc(“/home/[username]/.lightning1/lightning-rpc”)
- infol1 = l1.getinfo()
- print(infol1)
- Error messages
- OSError: [Errno 98] Address already in use
- sudo lsof -i:8080
- kill <PID>
- OSError: [Errno 98] Address already in use
- Additional steps
- mkdir
- pwd
- Import library/module
[ifpaid 0.00001 BTC text=”Please pay 0.00001 BTC to continue reading.” button=”Click here to pay using the Lightning Network”]
- what is:
- sudo ufw allow from 192.168.1.0/24 to any port 50002,3002,9737,22 proto tcp