What are Bitcoin Timelocks?

Written by BTSE

May 22, 2020

What are Bitcoin Timelocks?

Timelocks are Bitcoin’s basic yet effective smart contract feature.

Timelocks are code that tells the entire network when a certain amount of coins can be spent. The time can be defined in both days (the real world’s time reference) or block heights (the Bitcoin network’s time reference). Until the specified moment, the Bitcoin network freezes the funds so they can’t be moved by any party.

Thanks to Timelocks, lots of one-time financial contracts can be utilized. Bitcoin is not Turing-complete, so it doesn’t enable recurring payments according to complex conditions. However, the simplicity of its smart contracts also guarantees a greater amount of security – and just in case Ethereum users want to port their contracts to the Bitcoin blockchain, they can find promising projects like RSK.

So what are the use cases of Timelocks? Well, they range from making savings unspendable for a few years (self-imposed HODLing), setting up payment escrows, creating payment channels (the pillars of the Lightning Network), and bumping fees in future blocks.

 

Signing Bitcoin smart contracts with nLockTime

Timelocks are conditional payments that are broadcast at specified times. The original Bitcoin client published by Satoshi Nakamoto allowed for nLockTime transactions to be sent. This means that users could set a minimum amount of time that needs to pass before a transaction is broadcast to network nodes.

In “nLockTime”, “n” allows users to set their time preference (in block height or unix time) before sending bitcoin. It should be noted that the instruction basically says “you can spend the coins after this block has been mined or this moment has passed” and doesn’t guarantee that the transaction will be included in a specific block without paying the required fee. Therefore, the transaction may be further delayed until the fee that the sender is willing to pay matches the cost of block space.

Though nLockTime isn’t a very popular feature and requires Bitcoin users to change parameters on their nodes through command line instructions, it was still used in roughly 23% of transactions broadcast between April 20th and May 20, 2020.

In July 2015, Bitcoin Core 0.11.0 was released and it included a special wallet feature that discourages fee snipping with nLockTime. Network fees are expected to become the main source of income for miners further down the hyperbitcoinization road, so it was important to prevent the smart contract feature from cheating network incentives. This also proves that nLockTime is a powerful component of the Bitcoin network, whose potential should not be underestimated.

 

Bitcoin Timelocks – from temporarily freezing funds to Lightning payment channels

How did a basic condition like “don’t make coins spendable until this moment” evolve into a primitive of Bitcoin’s highly scalable second layer? Well, it all happened thanks to years of contributions from Bitcoin Core developers.

In 2015, Mark Fliesenbach, BtcDrak, Nicolas Dorier, and Kiyoshi Tajona created relative time-locks. This is basically a more complex way of defining the moment when a transaction can be written into a block, by specifying the earliest time it can be added and for how long the bitcoin has been recorded in the ledger prior to being spent.

A few months later, Peter Todd introduced the BIP65 soft fork. This refinement added CheckLockTimeVerify, a feature that allows for transaction outputs to become part of the time lock. Before BIP65, only whole transactions could be used in this smart contract setup.

Last but not least, we have CheckSequenceVerify. These are the Timelocks that are used on the Lightning Network, which were introduced in 2015 through BIP112. Eric Lombrozo, BrcDrak, and Mark Friedenbach are responsible for creating the CHECKSEQUENCEVERIFY opcode, which restricts contract execution clauses according to the age of the spent output.

 

The Takeaway

The sum of these inventions has made Bitcoin smart contracts much more suitable for common needs, while also enabling great scalability solutions like pegged sidechains and second layers. In spite of their relative simplicity, the contracts have proven to be much more robust than their buggy Ethereum counterparts. In the future, Bitcoin might just also become the world’s largest network for smart contracts.

 


Our aim is to create a platform that offers users the most enjoyable trading experience. If you have any feedback, please reach out to us at feedback@btse.com or on Twitter @BTSE_Official.

Note: BTSE Blog contents are intended solely to provide varying insights and perspectives. Unless otherwise noted, they do not represent the views of BTSE and should in no way be treated as investment advice. Markets are volatile, and trading brings rewards and risks. Trade with caution.

Related Articles

Stay Informed with BTSE

Join Our Newsletter

Never miss a beat with the latest updates and industry insights from BTSE.

Follow Us

Join our rapidly growing community and exclusive events!