What is TimeLock? The Bitcoin Clause

Qué es TimeLock

Centralized methods, essentially banks, have their own times and procedures for handling money, which are already controlled and regulated. 

Therefore, before making a transaction, we know that it will take hours or days to transfer money from one bank to another bank.

Of course, before disbursing any money, they pass our data through different mechanisms, entities and bank officials to know if the money is real, is legal and our account is in order. Without any of that, it cannot be transferred. 

So far, so good and we know it very well. However, it is different for the world of cryptos, as they are decentralized.

For this reason, there are timelocks which, although very similar to the common procedures, are different in their operation. Make yourself comfortable, today we will talk about a slightly more technical topic.

What is TimeLock?

Timelock is a clause or a primitive smart contract that serves to establish under what conditions transactions on a blockchain will be validated. They were developed by Satoshi Nakamoto and are applied in bitcoin purchases.

Its function is that transactions are only processed in a period already established by us, in which certain preconditions must already be resolved.

This process is as if, for example, you had a clothing store. After a customer arrives and chooses the clothes he will buy, you start making a checklist of the aspects you must take into account in order to make the purchase effective, such as that his money is not fake, his ID card is real, his signature matches his ID, among others.

Commonly, they are used in hash contracts, in the payment channels that occur in a smart contract and in postage or shipping fees and there are two ways for it to be added to a blockchain:

  • According to the height of the block,that is, the position in the block chain of the block in which the transaction will be included. Ex. The transaction is added within 10 blocks. 
  • According to a time parameter (minutes, hours, days, months, etc.). The transaction is recorded in 12 hours.
Qué es TimeLock Bitnovo

Types of locks

nLocktime

It is a type of full time lock that acts on transactions. It was the first one created and the one available in Satoshi Nakamoto’s original Bitcoin software. 

It specifies the earliest time in UNIX time – or milliseconds elapsed since midnight on January 1, 1970, so each day is treated as having 86400 seconds – or the lowest block height at which a transaction can be added to a valid block. If this time does not elapse, a block cannot be accepted. 

An example of this could be that we decide to send a gift to a person who is in another part of Spain. We determine and pay so that, in 864000 seconds (10 days in UNIX time), it will be at the house of the person we want.

  • If it is less than 500 million, the block number after which the transaction can be included in the block is specified.
  • If greater than 500 million, the UNIX timestamp after which this transaction can be included in the block is determined. 

In the past, they worked with 32 bits without signs, but nowadays they are more complex and can block a transaction for more than 9000 years with block numbers or 2000 years if it is with timestamps.


nSequence

This type of blockchain is part time and was introduced in 2016 in the BIP 68 soft fork. It is a parameter that is applied to each transaction entry, as it sets an earlier or nearer time to add to some of the blocks in the blockchain.

It looks the same as an nLockTime, but their distinction is that this earlier or nearer time is much shorter than that of an nLocktime, since they use 18 of the 32 bits and are limited to 65,535 block units and only 18 hours (64,800 in seconds).

Following the example of sending a package, with nSequence we would no longer be able to send the gift so far in advance. In this case, we would send it the day before.

Checklocktimeverify (CLTV)

In late 2015, in the BIP65 soft fork, the NOP2 opcode was redefined as the CheckLockTimeVerify (CLTV) transaction code. It acts at the script level and locks transaction outputs so that they cannot be spent before a certain time/date.

It has two possible functions: 

  • Set in advance the specific day on which the transactions will take place.
  • Change the authentication parameters used by multi-signature addresses, allowing funds to be retrieved if a return is necessary.

So far, it is understandable. But how does it work if there is an active nLocktime? What the nLocktime does is to add the transaction we are performing to the block. 

However, the transaction cannot be recorded on the blockchain, without being disbursed, so the nLocktime, must be, primarily, after the CTLV to ensure that the CTLV has expired and the transaction can be included in a valid block.

Checksequenceverify (CSV)

It is also part of the BIP68 soft fork and it is the CheckSequenceVerify opcode that provides a relative blocking time. 

The difference is that, instead of looking at time, it blocks transaction outputs so that they cannot be spent before a certain number of blocks have been mined.

This Timelock operates at the script level. CheckSequenceVerify can block transactions in a range of more than 65,000 blocks. In time measure, we are talking about almost 460 days.

que es timelock

What are the advantages and disadvantages?

Regarding its advantages, it is very useful to prevent attackers from accessing your assets and to provide Bitcoin with new programming capabilities that allow the construction of new features such as Lightning Network.

Regarding its disadvantages, because of the time locked, it is money that even you cannot touch until a specific date or block number. In addition, it is complex, because it requires programming knowledge to be able to implement them.

This is the end of our tour. If you are interested in reading more articles associated with the news of the crypto universe and its basic concepts, you can click on the topics below. We know that they will be very useful for you. 

For the time being, see you in a future article!

IT MAY INTEREST YOU…