Building on Bitcoin, part one: Base layer and the Lightning Network

We will take a look at various scaling methods and then focus on the layered approach: Bitcoin’s blockchain that serves as a foundation for the Lightning Network and the emerging networks on top of it.
Read in 8 minutes

In our previous article, we analyzed the layered structure of monetary instruments throughout history and explained why it makes sense also for Bitcoin to develop in this fashion.

In this two-part series, we will further analyze Bitcoin from a technical/developer perspective. In the first part, we will take a look at various scaling methods and then focus on the layered approach: Bitcoin’s blockchain that serves as a foundation for the Lightning Network and the emerging networks on top of it. In the second part, we will analyze the non-layered approach in the form of sidechains and wrapped bitcoin.

Layers, sidechains, wrapped bitcoin – an overview

Today, we can observe multiple concurrent attempts at expanding Bitcoin’s capabilities and transaction throughput. 

These are:

  • Layers: building on the Bitcoin protocol to expand the system’s capabilities in a layered architecture, with cryptographic assurances to fall back to a preceding layer if needed.
  • Sidechains: standalone protocols that are bridged to Bitcoin’s blockchain and adopt some of its consensus mechanisms and proof-of-work settlement assurances.
  • Wrapped bitcoin: tokenized representation of bitcoin (the asset) on a separate blockchain network (e.g. Ethereum) with its own native token, monetary policy, and consensus mechanism.

Various approaches to Bitcoin scaling. Source: author.

The Layered approach

Bitcoin layers. Source: author.

Layer 1: Bitcoin blockchain

Bitcoin’s blockchain or the base layer is the very basis of Bitcoin. It has been running uninterrupted for more than 12 years now and secures around a trillion dollars worth of value at the time of writing – by far the largest amount of all the cryptoassets.

On the base layer, users can participate in the network consensus (via running a full node) and broadcast transactions that are picked by miners and confirmed via the proof of work process. Bitcoin base layer transactions are essentially simple smart contracts, where the sender defines the spending conditions for the receiver. The most basic transaction (A pays B) simply states that the bitcoin sent to B’s address is spendable by submitting a valid cryptographic signature by a particular private key.

Senders define the spending conditions through so-called opcodes: commands of the Bitcoin Script language which is intentionally limited to minimize the possibility of protocol errors, bugs, and hacks, as well as keeping the blockchain size manageable to minimize the costs of running a node.

By using and combining various opcodes, users can perform multisignature transactions, time-locked transactions, or a combination thereof. One of the most useful smart contracts thus constructed is the hashed timelock contract (HTLC). HTLCs serve as the cryptographic primitive for the Lightning Network, allowing users to construct and interconnect payment channels for instant and cheap bitcoin transactions.

Developers working on Bitcoin’s base layer either contribute to Bitcoin Core client or work on infrastructure projects such as payment processors (e.g. BTCPay Server), wallets (e.g. Samourai), decentralized exchanges (e.g. Bisq), or blockchain analysis tooling (e.g. Mempool.space). Many projects in the Bitcoin ecosystem are supported through independent grants. Development of Bitcoin protocol is coordinated via peer-review process and tracked through Bitcoin Improvement Proposals (BIPs).

The development of the Bitcoin protocol follows a very conservative path and upgrades can take years – and when they happen, it is through backward-compatible changes called soft forks. While this approach may seem too conservative for many critics, it ensures a strong consensus on Bitcoin’s rules among the nodes and also ensures a solid foundation for further layers. Two of the most important upgrades in recent years were SegWit (allowing the development of HTLC payment channels) and Schnorr signatures + Taproot (improving user privacy and greatly decreasing the size of complex transactions).

Notable changes both in the Bitcoin protocol and in the various infrastructure projects can be followed via Bitcoinops.org.

Pros:

+very long history of development, many open-source repositories, and technical questions answered

+limited Script language narrows room for bugs, attacks

+native multisig capability

+Taproot upgrade coming in November 2021 will enhance user privacy and decrease the size of complex transactions

Cons:

-complete transaction transparency due to blockchain’s public nature

-limited Script language narrows use cases on the base layer, further layers are required

-miner fees will likely increase in the future, services on the base layer need to take this into account

Suitable for the development of:

1) Bitcoin base layer infrastructure: wallets, on-chain analysis tools, block explorers

2) services utilizing multisig capabilities (such as Unchained Capitals’ Bitcoin Vault)

3) decentralized exchanges (e.g. Bisq, Hodl Hodl)

4) point of sale solutions (e.g. BTCPay Server)

Useful tools:

Bitcoin Design Guide

Bitcoin Dev Kit

Bitcoin Miniscript

Programming Bitcoin (book)

Mastering Bitcoin (book)

Stack Exchange: Bitcoin

BIPs repository

Bitcoinops Newsletter

Layers 2 & 3: Lightning Network and services on top

The Lightning Network is Bitcoin’s onion routing network, similar in some aspects of its architecture to the TOR browser. The basic building stone of Lightning Network is a two-party payment channel, where one or both parties lock some bitcoin to enable instant, near-costless transactions within the channel. But the real magic happens when the individual payment channels are interconnected and form a proper network that allows for payment routing – participants then have the option to send instant and cheap payments to every participant in the network.

Transactions on the Lightning Network are secured by the Bitcoin network without being directly broadcast to it. Every change in the payment channel balance needs to be co-signed by both channel users and either user can choose to broadcast a settlement transaction at any time. As long as both parties are constantly monitoring the channel state (via their node or wallet service), this makes Lightning highly trust-minimised since neither of the channel’s users need to trust each other in order to transact.

Participating in the Lightning Network requires running a separate Lightning node that connects to a Bitcoin full node. There are many 1-click solutions for a smooth set up of the Bitcoin and Lightning infrastructure, such as MyNode or Umbrel. Alternatively, users can use a lightweight Lightning wallet (e.g. Phoenix) that connects to a third-party Lightning node – easier from a UX perspective, but with some compromise on privacy and possibly also security.

At the time of writing, these are the main metrics pertaining to Lightning Network:

  • 65,000 channels (+96% year-on-year)
  • 14,000 nodes (+133% YoY)
  • 2,300 bitcoin capacity (+130% YoY)

(Source: 1ML.com)

Note, however, that the capacity isn’t representative of the volume of payments that is transferred over the Lightning Network. Such metric is impossible to measure, as Lightning transactions do not leave any trace as the base layer transactions do.

How does Lightning fare in terms of transaction capacity and costs? According to Desiree Dickerson of Lightning Labs, the capacity is in the ballpark of tens of millions of transactions per second – real throughput depending on the shape of the Lightning graph, channel capacity and balance, etc. In any case, there is no limitation caused by a limited block size as we see on the base layer. The base transaction cost on Lightning is 1 satoshi (0.00000001 bitcoin), but can run up to hundreds of satoshis, depending on the payment path and volume – contrary to the base layer, the transaction costs on Lightning are a function of a volume in satoshis, not a size in bytes. You can read more about the economics of routing fees in a BitMEX research post.

The ability to send bitcoin globally with an instant settlement and for little cost is revolutionizing the remittance business, as witnessed in El Salvador. Moreover, we can see developers working on a myriad of services that leverage the ability to perform micropayments from anywhere in the world.

The most interesting applications of Lightning micropayments are:

  • Zebedee – bitcoin micropayments in the gaming industry. The most popular application so far is Counter Strike: Global Offensive tournaments for bitcoin prize money.
  • Podcasting 2.0 – podcast listeners now have the ability to directly support their favorite shows by streaming satoshis as they listen. Breez wallet is at the forefront of this development.
  • Tipping on social networks – LNtxbot allows users to tip each other in bitcoin on Telegram, Tippin does the same on Twitter; and Jack Dorsey is looking to integrate Lightning tips for Twitter natively, without a third-party service like Tippin.

Moreover, there is a Layer 3 gradually emerging on top of the Lightning Network. This layer can be described as apps and services using Lightning Network’s graph and routing capabilities, while facilitating data transfers as well as payments.

Following are the most exciting Layer 3 experiments currently unfolding:

  • Sphinx chat – P2P instant messaging system built on top of the Lightning Network graph. Each message is a Lightning transaction. No reliance on third-party providers.
  • Impervious – data transmission ecosystem on top of Lightning Network graph. One of the first applications is Red – a voice-over-Lightning service, allowing users to perform audio calls via Lightning Network, with optional streamed micropayments. Further demo applications have been submitted in a recent Impervious Hackathon.
  • Lightning Login – user logins via Lightning node ID. Still in a trial phase, but potentially powerful when combined with services like those already mentioned.
  • RGB – scalable and confidential off-chain smart contracts for Bitcoin and Lightning.

Illustration of the layered approach by the Impervious team. Source: https://www.impervious.ai/.

The Lightning Network protocol itself is developed mostly by Lightning Labs, ACINQ and Blockstream. The respective implementations of these development studios are lnd, Eclair and c-lightning. The protocol development is coordinated via Basis of Lightning Technology (BOLT) – a peer review process similar to the base layer’s BIPs. Compared to the base layer, Lightning Network is much more agile in its development both on a protocol and application levels, as there is no need to maintain a protocol consensus among the nodes and there are no blockchain limitations. Still, the users maintain the ability to interact without any trust prerequisite, having the ability to always close their channels and settle the outstanding bitcoin amounts on the base layer.

Pros:

+bitcoin as the unit of account (no need for another token)

+instant micropayments for minuscule cost

+Lightning graph and routing can be leveraged for data transfer

+potentially unlimited transaction throughput

+improved user privacy compared to the base layer

Cons:

-Lightning wallets are hot wallets (private keys are in an online environment)

-pull payment architecture: receiver needs to generate an invoice before a payment; this can be confusing at first as it’s an opposite approach to base layer’s push payments

-Lightning wallets need to stay online to receive/route payments

-Lightning isn’t suitable for larger payments

-still a young technology, in active use since 2018

Suitable for the development of:

1) use cases leveraging cheap permissionless micropayments (e.g. remittance and gaming industries)

2) use cases leveraging finance and data streaming (e.g. Podcasting 2.0, Red phone)

3) hybrid infrastructure combining base layer and Lightning features (e.g. Phoenix wallet)

4) decentralized derivatives markets (e.g. LNMarkets)

5) globally accessible content paywalls (e.g. Yalls)

6) real-time auctions (e.g. Scarce.city)

Useful tools:

Mastering Lightning book

Lightning Development Kit

Awesome Lightning repository

1ML.com – network statistics

BOLTs repository

Stack Exchange/Lightning

Conclusion

Development on top of Bitcoin is very dynamic, when we observe the full layered Bitcoin stack. The base layer is quite conservative in its development to provide a reliable foundation, both in a sense of predictable monetary policy and the protocol rules, making the outgrowth of further layers possible. However, it’s important to distinguish a development on consensus rules – which really do change as seldom as possible – and the development of base layer infrastructure such as wallets, fee estimators, node management tools, payment gates, and other tooling, which has developed dramatically over the years.

Lightning Network enjoys exponential growth so far in 2021, and it seems that it is beginning to mature into a viable platform for developers and their novel ideas that leverage the ability to stream micropayments and data globally. Unconstrained by a slow and expensive blockchain, the development activity on Bitcoin’s second and third layers will bring many exciting things in the near future.

In Part two of this series, we will cover Bitcoin sidechains and wrapped bitcoin – two further attempts to expand Bitcoin’s capabilities.

We are hiring

Software engineer
Product Owner
Product Designer

Life @ Vacuumlabs

About Vacuumlabs

Vacuumlabs provides teams of flexible software engineers and designers with years of experience building fintech, online marketplaces, and digital products. Every step of the way, Vacuumlabs experts collaborate with clients, so that they can move fast, learn and iterate as they build world-class products together.