The Lightning Network: Packets to Circuits

There are three problems that developers see in regards to scaling Bitcoin:

  • Micropayments are not exactly cheap to make
  • the size of blocks/the blockchain over time
  • malleability

The Lightning Network aims to solve these problems by creating hash-locked payment channels facilitating instant off-chain real bitcoin transactions.

Before we can understand what the Lightning network enables, we need to have a baseline understanding of what exactly a hash and payment channel is.

Hash

A cryptographic hash function is a way to encrypt data and verify that data has not changed. The SHA256 hash function will take any input and output a 64 character string output. In order to produce a certain hash output you must know the secret input. The Sha256 hash will always produce the same output for a given data input.

domsteil –> SHA256 –> 1773a0ebb54be6bbc0c6be79fae0799046b7ecb089b11460e0070a62c6e319af

Payment Channel

A payment channel is an off blockchain P2P payment where confirmation is done by the parties involved and does not need to be announced to the network.

By combining these two technolgies we can create the hash-locked smart contracts between multiple parties to facilitate a counterparty-risk free transaction layer on top off the Bitcoin protocol.

T+3 an existing method in the financial system was created as a settlement period. The Lightning Network also creates a similar T+time settlement system using a hash-locked smart contract and appending a transaction to the resulting hash output.

Trustless Transaction Example:

Alice, Bob, Carol, and Dave.

1

Alice wants to pay Dave .01 BTC, but does not have a direct route.

Alice pays Bob, Bob pays Carol, Carol Pays Dave.

2

Dave has R, a preimage which produces cryptographic hash H within n blocks.

Dave can now get 0.01 BTC if she discloses R to Carol.

Carol discloses R to Bob.

Bob discloses R to Alice.

3

Pure P2P offchain settlement.

For more information read about the Lightning Network here.

 

21.co: The Bitcoin Computer

After months of anticipation my 21.co Bitcoin computer finally arrived. I anxiously opened up what felt like Pandora’s box to a new age of the internet. The 21.co Bitcoin Computer is the first of its kind and is the foundation for a new range of applications.

First things first, if you want to run this as a standalone machine (linux) you will need:

  • Keyboard/Mouse
  • HDMI Cord
  • Monitor
  • Wifi Dongle (Included)
  • Powercord (Included)

I plugged in the powercord and the machine is up and running.

I’m feeling nastalgic, reminds me of when I set up my first raspberrypi, USB powered hub, ASIC mining rig. The command line experience is definitely helping with the setup.

I have just logged into the system, I setup my WiFi, and I am ready to begin building!

First Hour with the Bitcoin Computer

Off that bat the first tutorial I want to setup is the Bitcoin Payable proxy to one of my Antminer Tutorials. Since S5 is still getting a lot of hits I will go with that one.

Correction: First things first, run the 21 update command in the command line.

21 update

Daft Punk Pandora in the background definitely adding to the experience I might add.

Over a year ago, I built my first Raspberry Pi Bitcoin Node preconfigured with wifi and the blockchain preloaded to an SD card, bundle it with whatever ASIC you would like. The problem I wanted to solve: Increase the number of Nodes around the world, read here. That was when there were 7,000 nodes, now we are down to 5,000. Hopefully these Bitcoin Computers are the key to strengthening the network and bringing back a decentralized state to the network.

This machine takes that idea to the next level, still running updates…

Again before I setup this proxy server for one of my tutorials, I need to setup my 21.co account and start the miner.

Updates are done I believe the screen went dark.

21 Successfully installed!

Ok now to start the miner:

21 mine

Creates a wallet for my with a 12 word HD wallet.

Ok got that written down.

Next:

Set up my Account with 21.co, have my mining payout address, and I am mining, again!

Now to check out this mining dashboard:

21 mine --dashboard

Let’s take a look. Dashboard Overview, Monitor, Log.

Running around 50Gh/s I just made 20000 Satoshis I can now use to buy API calls.

THIS.

21 mine

Another 20000 Satoshis.

Ok now i’m starting to get it.

(Probably not even at the tip of the iceberg realistically)

Ok so I have 100000 Satoshi now after running 21 mine a few more times.

Time to start testing out some of these apps.

THIS.

Concept of “buffered pooled mining”.

It basically allows you to quickly mine some satoshis in order to make an API call.

Caution: Before you think wait I can just run 21 mine (command) all day and I’ll be rich! If you run it too many times in a row you will be rate-limited by a difficult hashing problem sent to your chip, so don’t abuse it!

Ok sending out sms with Bitcoin. Only cost 1000 Satoshi.

Search on the web; also just a few satoshis.

Now to do this programmatically:

sudo nano search-client.py

 

#!/usr/bin/env python3
import json
from two1.commands.config import Config
from two1.lib.wallet import Wallet
from two1.lib.bitrequests import BitTransferRequests

# Set up a bittransfer. The wallet's private key
# is used to sign transactions, confirming that the
# balance is spendable by the given 21 username.
wallet = Wallet()
username = Config().username
requests = BitTransferRequests(wallet, username)

# Determine the price of a given endpoint, in satoshis
url = 'https://market.21.co/search/bing'
info = requests.get_402_info(url=url)
print(info)

# Buy the endpoint
results = requests.post(url=url, data=dict(query='how to flip bitcoins'))
print(json.loads(results.text))

Setting up my own digital store when someone can pay me in bitcoin for access to tutorials on how to setup bitcoin miners.

This is powerful technology.

It wraps around Bitcoin as a Protocol. Enabling you to create an unlimited range of decentralized applications. I just created another user in the system.

I can now have multiple agents. This is also a great way to test any application you are building, you can have multiple users with different balances and simulate the application behavior.

12/28/2015

21.co has released an API documentation library with four primary modules:

 

I am currently redoing exercises in Learn python the Hard way and building out the examples in the API documentation tutorials.