Need help with CLTV; I want to lock away bitcoins for 1 year

Hi /r/bitcoin
How does one actually write and broadcast a transaction with an CLTV script.
Step by Step instructions would help me a lot.
My goal is to send x.y amount of bitcoin to my address but with a lock of 1 year.
This is what I have come up:
1704666900 CHECKLOCKTIMEVERIFY DROP DUP HASH160
<ripemd160(my_address)> EQUALVERIFY CHECKSIG
The PowerShell line I use to calculate seconds since 1970:
((Get-Date).AddYears(1) – (Get-Date -Year 1970 -Month 1 -Day 1 -Hour 0 -Minute 0)).totalseconds
Where do I have to input my code if it were correct?If I have to compile it, how do I do that?When I have it compiled, where do I input the compiled code?
I didn’t find any YouTube video to my surprise and the internet articles/wiki don’t have step by step instructions on how to compile the code nor where to input the code.
Do I have to sign a message? Is there an app that allows me to do my usecase in an easy way?
**TLDR**:
I want to stop myself from spending a certain amount of bitcoin for 1 year on the blockchain.
How? Thank you!
​
EDIT:
– correct code formating
– Summary of useful links:
[https://github.com/bitcoin-core/HWI#device-support](https://github.com/bitcoin-core/HWI#device-support) [https://github.com/bitcoinjs/bitcoinjs-lib](https://github.com/bitcoinjs/bitcoinjs-lib) [https://www.reddit.com/r/Bitcoin/comments/kezc47/is_there_a_way_i_can_do_a_cltv_bitcoin/](https://www.reddit.com/r/Bitcoin/comments/kezc47/is_there_a_way_i_can_do_a_cltv_bitcoin/) [https://www.reddit.com/r/Bitcoin/comments/dswuml/wallets_that_can_spend_a_cltv_address_after_the/](https://www.reddit.com/r/Bitcoin/comments/dswuml/wallets_that_can_spend_a_cltv_address_after_the/) [https://coinb.in/#newTimeLocked](https://coinb.in/#newTimeLocked) [https://medium.com/@thomasmccabe/hodling-bitcoins-with-op-checklocktimeverify-a-step-by-step-guide-to-manually-building-a-bitcoin-ce9476725de8](https://medium.com/@thomasmccabe/hodling-bitcoins-with-op-checklocktimeverify-a-step-by-step-guide-to-manually-building-a-bitcoin-ce9476725de8) [https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch07.asciidoc#check-lock-time-verify-cltv](https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch07.asciidoc#check-lock-time-verify-cltv)– Notes:
Electrum console:
getpubkeys(“3N….”)
Important: The redeem script is needed as well. Even after the timelock expires a special transaction must be crafted to spend the bitcoins.
Take a look at
https://medium.com/@thomasmccabe/hodling-bitcoins-with-op-checklocktimeverify-a-step-by-step-guide-to-manually-building-a-bitcoin-ce9476725de8
disclaimer: I just found this via searching, I haven’t tried these instructions nor did I review them closely before posting this link here (I did skim over them). Consider trying it out with a small amount locked for a day before doing the real thing.
Check out bdk-cli. You can write a descriptor with the timelock, give it to bdk-cli and get a kittle command line wallet
Checkout the bitcoin sdk for a language of your preference and try, this can help build the transaction. Javascript for example: https://github.com/bitcoinjs/bitcoinjs-lib ( disclaimer: i never used it, only is a example )
Create this type of transactions from scratch like you are try is complex and risky
Before any real attempt, try in testnet or use small amounts!
The most important thing is to test your solution with a small amount first. Bitcoin is unforgiving. There is no one that you can call to reverse your mistakes. I guess you could call me, but I’ll just say that “I told you so”.
If anyone’s interested in a less technically sophisticated way to do this, check out https://futureme.org and their competitors.
1. generate a 12-word seed, and fund it with whatever you want to postpone spending.
2. **cut**+paste 3 of the words into a ‘future’ email, with your chosen arrival date, like 1 year into the future.
3. save the other 9 words somewhere safe and wait for the email to arrive.
Once you get the email in 1 year, you can combine those 3 words with the 9 you kept safe, and get your bitcoins. The emailing service can’t get your bitcoins, because they only ever see 3 out of the 12 words. And if that service disappears or doesn’t work, worst-case scenario, you only have to bruteforce 2048^3 combinations. Not such a big deal.
(If you ever try this, one of the most important things to make sure, is that the amount of data you send to the service is bruteforceable within a reasonable time-frame if they disappear, but not too easily bruteforceable that you can easily cheat and get your bitcoins early)
You could just exercise impulse control, a basic skill all adults need to have. Messing around with this stuff could lock your btc for 100 years by accident. Future upgrades and changes could render your lockups unspendable too.
>I want to stop myself from spending a certain amount of bitcoin for 1 year on the blockchain.
instead of doing that, learn more about self-control
Checkout coinb.in they have a couple of nice UIs for timelock https://blog.coinb.in/guide_timelock this is a good way to do it as you can generate the key pair offline and coinb.in only needs the public key. But the usual caveats of working with individual keys is hard. And timelock has no back door except time travel.