Knowledge Base

What Lock Time means in Bitcoin transaction: LockTime: Block height, Date?

Upon constructing a Bitcoin transaction on electrum and core Bitcoin wallet you’ll find this option called Lock Time.

On core wallet it gives an option to choose confirmation time target for your transaction. Whereas on electrum you can specify the block time and date.

electrum bitcoin locktime

On most transactions you do not need to make use of this locktime feature. If you want your transaction to be final then simply leave this field to default setting. Depending on the mempool traffic and your fees the transaction will get confirmed in the next few blocks.

Some beginners without knowing what this function does they accidentally lock their transaction for days or even months.

Recently one of our users had their transaction stuck for weeks. Upon checking the transaction on the block explorer there was a field called lock time that specified lock time block: 664777. It simply means that this particular transaction will only get valid at the given block height. The transaction cannot be included in a block until the block 664777 has been mined.

So what lock time means in Bitcoin transaction? What is the purpose of this feature and when you need to set lock time for your transaction?

What is lock time in Bitcoin transaction?

Lock time in Bitcoin transaction are specified by the user. It is the time at which a particular transaction can be added to the blockchain.

Locktime is the last field in a piece of transaction data that is used for post-dating. This sets the earliest time or earliest block the miners can pick the transaction and attach it to latest block on the blockchain.

When a sender specifies a lock time the transaction will simply remain locked until the specified block height or time.

For example if a user specified locktime block height @ 664777 and if the current block height is 664700 then the user have to wait until the block 664777 is reached. Only after the block 664777 has been mined miners will attempt to include their transaction in a block. In Bitcoin the block time is 10 minutes so more or less the user have to wait for 770 hours (close to a month) for their transaction to get confirmed.

Why use this function?

First of all most of the Bitcoin transaction does not require this function and they do not use a set locktime. So any transactions that does not use this feature will have a locktime set to 0x00000000.

If you do not want your transaction to be locked until specific block height or time you can simply set the lock time to less than the current block height or the UNIX time. This will set the locktime field to 0x00000000. This way your transaction will be made final. So when exactly do we need this function?

In simple LockTime function is used to lock a transaction until a specific block height or point of time. Setting locktime means the transaction will be confirmed only when the required time or block height has been met. The transaction won’t be valid until the specified function is met.

Nodes validate every transaction and if a transaction contains locktime script then they will simply reject it. The transaction that has locktime specified will only get added to the blockchain after the set time or block height that has been elapsed and not before it.

Think of this feature as a post dated cheque written with a future date. The cheque will not be cleared prior to that specified date. Similarly with locktime the coins cannot be spent until a specified time or until certain block height has been past. This will simply lock the UTXO for a predetermined amount of time.

How Bitcoin’s locktime feature can be used?

For example let’s say you want to send Bitcoin to someone now but you only want them to receive it in the future date. Or let us say you wish to send money to your children’s saving account which they cannot spend until the lock expires. With locktime you are basically signing a transaction in advance which won’t get confirmed until the lock expires.

LockTime can be set in two ways. It can be either the actual time or it can be specified in block height. Bitcoin core, electrum and most other Bitcoin wallets will have lock_time set to current block height by default. You’ll need to specify the date or block number only if you wish to lock your transaction.

This feature specifies time-based conditions in which a transaction becomes valid. Its a powerful tool and is completely an optional function. If you are not sure about this feature then simply leave the locktime field to default settings. This way your transaction will be instantly relayed to the network.

Don’t complicate things and do not accidentally lock up your coins for years.

Hope it clears out.

Show More

coinguides

We are crypto enthusiasts and our main intention with Coin Guides is to educate people about Cryptocurrency and Blockchain technology. We regularly publish content about Bitcoin, Ethereum, Altcoins, wallet guides, mining tutorials and trading tips.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button