Is it possible to submit some coins to some address and make them spendable after some period of time?
Like I want submit 1btc to address 1Kc24m... and make that output to be spendable after january 1st 2030.
Bitcoin Stack Exchange is a question and answer site for Bitcoin users, developers, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
Yes, you can use
OP_CHECKLOCKTIMEVERIFY opcode in the locking script of the output. This opcode takes either blocks or Unix Epoch Time (seconds since 1-Jan-1970) as the parameter to lock. If the parameter is non-zero and below 500 million, it is interpreted as a block height, if it is greater than or equal to 500 million, it is interpreted as a Unix Epoch timestamp. When you would reference this UTXO at the time of spending, you need to set the transaction
nLocktime equal to or great than the
nLocktime parameter while spending should be same as what was specified in the CLTV; i.e. if the CLTV locking parameter was in blocks, it should be specified in blocks, otherwise in Unix Epoch timestamp.
Since you want it to be spendable after 1st Jan 2030, that is equivalent to timestamp of 1,893,456,000 (or 0x70dbd880). So your locking script will be concatenation of:
OP_DATA (size of CLTV_expiry): 0x04 CLTV (little endian): 0x80d8db70 OP_CLTV: 0xb1 OP_DROP: 0x75 OP_DUP: 0x76 OP_HASH160: 0xa9 OP_DATA (size of address): 0x14 Address: <address> OP_EQUALVERIFY: 0x88 OP_CHECKSIG: 0xac
Two things to note: (1) When you are spending this transaction, the input referencing this UTXO needs to have
nSequence value between 0xF0000000 to 0xFFFFFFFE. (2) Median_time (time of last 11 blocks) is used to check
nLocktime when the script is evaluated which is generally about hour behind the actual time on your wall clock.