How to create a bitcoin timelocked transaction and how to redeem/claim it

in bitcoin •  4 years ago 

You can create a new time lock which prevents anyone from spending your coins (including yourself) until a specific date/time.

CREATING THE TIME LOCK

  1. Download https://github.com/OutCast3k/coinbin/archive/master.zip --> coinbin-master.zip
  2. Unzip and open coinbin-master\index.html
  3. Click New > Address
  4. Click Generate. Click Show to view private key. Save Address, Public Key, Private key (WIF key). You will need this to claim your funds.
    Address (Share): 1736c1XXXXXXXXXXXXXXXXXXXXXXXX
    Public key (Share): 03c73XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Private key (WIF key): L2MzXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
  5. Select New > Time Locked Address
  6. Enter public key (Share) from above
  7. Enter date and time MM/DD/YYYY hh:mm to unlock funds, in LOCAL TIME ZONE, 24 hour format.
    i.e. 01/15/2021 19:30
  8. Click Submit
  9. Save Payment Address, Redeem script, you will need this to claim your funds.
    Payment Address: 36zvYNrXXXXXXXXXXXXXXXXXXXXXX
    Redeem Script: 04a84XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
    (Note, this script contains the payment address, required address (signature), and unlock time and can be verified with the Verify tab option)
  10. Open your wallet and send desired funds to the payment address. You can use a block explorer to display the QR code:
    i.e. https://www.blockchain.com/btc/address/36zvYNrXXXXXXXXXXXXXXXXXXXXXX

If you send 0.003 BTC, with a fee = 0.00040000 BTC = 0.0026 BTC is timelocked in wallet after confirmations

WAIT UNTIL DESIRED DATE/TIME

Redeem/claim transaction:

  1. Open coinbin-master\index.html
  2. Click New > Transaction
  3. In the "Address, WIF key, Redeem Script or Transaction ID" field, paste your redeem script from above:
    Redeem Script: 04a84fXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  4. Click Load
  5. Enter the target bitcoin address you would like to send the funds to, probably your main wallet.
  6. Enter the amount you would like to receive. IMPORTANT Subtract the transaction fee from the total (shown in inputs).

To calculate transaction fee: This should be at least 10000 sats, or 0.00010000 BTC. For example, if the balance is 0.0026, you should send 0.0025 BTC in outputs.
Transaction fee is based on the size of the transaction and mempool time, typically 150-250 bytes (1 input-->2 outputs) x bytes/sat for the transaction time.
See https://bitcoinfees.earn.com or https://bitcoinfees.net to calculate transaction time.
For faster transactions, multiply 250 bytes times the desired time, i.e. If 100 sats/byte for less than 1/hour = 25800 sats (0.000258)
Depending on the age of your timelock, you will want to check what the typical transaction fee is on these sites.

Target Address: 3PEXXXXXXXXXXXXXXXXXXXXXXXXXXXXxx
Amount: 0.0025 BTC
Transaction Fee: 0.00010000

NOTE: In the advanced section, you can see the epoch time of the timelock. Make sure before you submit that it is past the time, you can post that time into https://www.epochconverter.com/ and it will show you current time and relative time to that epoch number.

  1. Click Submit
  2. Copy the transaction (unsigned)
    Transaction: 0100000001b6fXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  3. Click the Sign tab at the top of the page
  4. Paste your Private key (WIF key) from step 4 when you created the timelock.
  5. Paste the unsigned transation from step 8.
  6. Click Submit
  7. Copy the transaction (signed)
    Signed Transaction: 0100000001bXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  8. Click the Broadcast tab at the top of the page.
  9. Paste the Signed transaction from step 13.
  10. Click Submit

If you submit the signed transaction before the lock date, you will get error: non-final (code 64)

Otherwise, you should get a transaction ID that can be checked on a block explorer:
https://www.blockchain.com/btc/tx/99946XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxx

Congratulations! You can test this with a smaller amount or create larger transactions for months or even years down the road, just remember to save your keys and redeem script. It's best to print this out or save it somewhere non-digital ;-)

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!