Bitcoin Forum
May 04, 2024, 08:58:54 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: How to lock bitcoin for certain days  (Read 369 times)
Little Mouse (OP)
Legendary
*
Offline Offline

Activity: 2044
Merit: 1980


Marketing Campaign Manager |Telegram ID- @LT_Mouse


View Profile WWW
November 06, 2020, 07:50:08 AM
 #1

I have been looking for a way to lock a certain amount of BTC for certain days. Say for example, I want to lock 0.01 BTC for 100 days. Within this 100 days, no matter what I do, I will not have the access to the fund to spend. Only after that lock period, the 100 days, I will have the access to the fund to spend.
Is there any way to do this?
I know about Coinbase vault but I really don't want to go with them as they are centralized service.

The purpose is simple. I want to save this for someone. I may sometime in need of fund and will spend the BTC if I have access to the fund. That’s why I want to save a fund through such a way that I will not have access certain days and thus I will not have ways to spend.

██████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
██████████████████████
.SHUFFLE.COM..███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
█████████████████████
████████████████████
██████████████████████
████████████████████
██████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
██████████████████████
██████████████████████
██████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
.
...Next Generation Crypto Casino...
1714856334
Hero Member
*
Offline Offline

Posts: 1714856334

View Profile Personal Message (Offline)

Ignore
1714856334
Reply with quote  #2

1714856334
Report to moderator
1714856334
Hero Member
*
Offline Offline

Posts: 1714856334

View Profile Personal Message (Offline)

Ignore
1714856334
Reply with quote  #2

1714856334
Report to moderator
No Gods or Kings. Only Bitcoin
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714856334
Hero Member
*
Offline Offline

Posts: 1714856334

View Profile Personal Message (Offline)

Ignore
1714856334
Reply with quote  #2

1714856334
Report to moderator
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10546



View Profile
November 06, 2020, 08:01:21 AM
Merited by ABCbits (1), Little Mouse (1)
 #2

what you are looking for is defined in BIP-65 with a new OP code called OP_CHECKLOCKTIMEVERIFY
https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki

you simply create an output script that includes a locktime and this OP code followed by the regular script that you use (eg. P2PKH) to have the CheckSig OP in it.
for example:
Code:
<locktime> OP_CheckLocktimeVerify OP_DROP OP_DUP OP_HASH160 <hash160> OP_EqulVerify OP_CheckSig

the script could also be used as the redeem script and used in P2SH or P2WSH output. in the later 2 cases the HASH160 is not needed and only the OP_CheckSig is required while the "signature" contains the sig + pubkey.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
November 06, 2020, 08:42:05 AM
Last edit: November 06, 2020, 12:47:49 PM by HCP
Merited by pooya87 (1), ABCbits (1), Little Mouse (1)
 #3

Why not to open an account on exchange which allows you to save and gain profit on this?

Would seem the OP does not want to use a centralized service:
I know about Coinbase vault but I really don't want to go with them as they are centralized service.


Personally, I would just go with the nLocktime CheckLockTimeVerify solution. I'm not sure of any "mainstream" wallets that offer this service... but I know you can create a "Time Locked Address" on coinb.in fairly easily: https://coinb.in/#newTimeLocked

You just need to provide a public key (for a private key that you already hold) and a datetime... it'll automagically create the P2SH address and redeem script for you. You then simply send the funds you want to "lock" to the created address. Later, when you want to spend the funds after the timelock expires, you can simply provide the redeem script to coinb.in (and the private key necessary to sign) and you'll be able to create and broadcast the spending transaction.

Would probably be a good idea to create a standalone "throwaway" private key for this... to avoid having to use one from an existing wallet and the potential security issues with exposing private keys from HD wallets etc.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
PawGo
Legendary
*
Offline Offline

Activity: 952
Merit: 1367


View Profile
November 06, 2020, 08:45:01 AM
 #4


Maybe prepare/configure a hardware wallet and deposit at notary?
Coin_trader
Copper Member
Legendary
*
Offline Offline

Activity: 2772
Merit: 1169


Leading Crypto Sports Betting & Casino Platform


View Profile WWW
November 06, 2020, 08:51:29 AM
 #5

what you are looking for is defined in BIP-65 with a new OP code called OP_CHECKLOCKTIMEVERIFY
https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki

you simply create an output script that includes a locktime and this OP code followed by the regular script that you use (eg. P2PKH) to have the CheckSig OP in it.
for example:
Code:
<locktime> OP_CheckLocktimeVerify OP_DROP OP_DUP OP_HASH160 <hash160> OP_EqulVerify OP_CheckSig

the script could also be used as the redeem script and used in P2SH or P2WSH output. in the later 2 cases the HASH160 is not needed and only the OP_CheckSig is required while the "signature" contains the sig + pubkey.

This is not simple for people like me that don't have any background on programming. Even though all code was written. It will need a step by step guide on how to do it like open a note and etc. A video tutorial will be very helpful to easily follow this guide. I will be happy to learn how to this since I need this feature too for saving my money that I earn here. Actually, creating a tutorial thread for this topic is very helpful pooya.  Cheesy

Is this guide requires fee?

..Stake.com..   ▄████████████████████████████████████▄
   ██ ▄▄▄▄▄▄▄▄▄▄            ▄▄▄▄▄▄▄▄▄▄ ██  ▄████▄
   ██ ▀▀▀▀▀▀▀▀▀▀ ██████████ ▀▀▀▀▀▀▀▀▀▀ ██  ██████
   ██ ██████████ ██      ██ ██████████ ██   ▀██▀
   ██ ██      ██ ██████  ██ ██      ██ ██    ██
   ██ ██████  ██ █████  ███ ██████  ██ ████▄ ██
   ██ █████  ███ ████  ████ █████  ███ ████████
   ██ ████  ████ ██████████ ████  ████ ████▀
   ██ ██████████ ▄▄▄▄▄▄▄▄▄▄ ██████████ ██
   ██            ▀▀▀▀▀▀▀▀▀▀            ██ 
   ▀█████████▀ ▄████████████▄ ▀█████████▀
  ▄▄▄▄▄▄▄▄▄▄▄▄███  ██  ██  ███▄▄▄▄▄▄▄▄▄▄▄▄
 ██████████████████████████████████████████
▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄
█  ▄▀▄             █▀▀█▀▄▄
█  █▀█             █  ▐  ▐▌
█       ▄██▄       █  ▌  █
█     ▄██████▄     █  ▌ ▐▌
█    ██████████    █ ▐  █
█   ▐██████████▌   █ ▐ ▐▌
█    ▀▀██████▀▀    █ ▌ █
█     ▄▄▄██▄▄▄     █ ▌▐▌
█                  █▐ █
█                  █▐▐▌
█                  █▐█
▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀█
▄▄█████████▄▄
▄██▀▀▀▀█████▀▀▀▀██▄
▄█▀       ▐█▌       ▀█▄
██         ▐█▌         ██
████▄     ▄█████▄     ▄████
████████▄███████████▄████████
███▀    █████████████    ▀███
██       ███████████       ██
▀█▄       █████████       ▄█▀
▀█▄    ▄██▀▀▀▀▀▀▀██▄  ▄▄▄█▀
▀███████         ███████▀
▀█████▄       ▄█████▀
▀▀▀███▄▄▄███▀▀▀
..PLAY NOW..
NeuroticFish
Legendary
*
Offline Offline

Activity: 3668
Merit: 6373


Looking for campaign manager? Contact icopress!


View Profile
November 06, 2020, 08:55:55 AM
 #6

This is not simple for people like me that don't have any background on programming.

That's correct. And I think that the easy solution is to use Timelock feature in Electrum, which is available on the advanced tab at/"after" sending.
The initial purpose is slightly different, but this thread shows how to use Timelock in Electrum: [Tutorial] Making your crypto inheritible

PS. Obviously I recommend trying it out for free on Testnet  Wink

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
November 06, 2020, 09:01:39 AM
 #7

Maybe prepare/configure a hardware wallet and deposit at notary?

I doubt OP wants to do this since this also is a centralized approach.



This is not simple for people like me that don't have any background on programming. Even though all code was written. It will need a step by step guide on how to do it like open a note and etc. A video tutorial will be very helpful to easily follow this guide. I will be happy to learn how to this since I need this feature too for saving my money that I earn here. Actually, creating a tutorial thread for this topic is very helpful pooya.  Cheesy

There are tutorials and guides available here on this forum and the world wide web. You just need to search for them.


@OP
OP_CHECKLOCKTIMEVERIFY seems to be your best bet here.
But be assured that there is no way to access / send your coins before the specified date. If you lock them for 100 days, they are locked for 100 days. There is no way around it.

pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10546



View Profile
November 06, 2020, 09:35:44 AM
 #8

This is not simple for people like me that don't have any background on programming. Even though all code was written. It will need a step by step guide on how to do it like open a note and etc. A video tutorial will be very helpful to easily follow this guide. I will be happy to learn how to this since I need this feature too for saving my money that I earn here. Actually, creating a tutorial thread for this topic is very helpful pooya.  Cheesy

Is this guide requires fee?
unfortunately i don't know of any wallet that allows working with scripts or has pre-defined ones like OP_CLTV. there are some "tools" that have this capability and if run offline from their source code they could be useful. although lack of popularity could mean possible bugs which you have to keep in mind when using them.
one tool was already mentioned (https://coinb.in/#newTimeLocked) and here is a link explaining the steps: https://bitcointalk.org/index.php?topic=2415595.msg24712087#msg24712087
for more information on timelocks you can check out bitcoin book: https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch07.asciidoc#timelocks

sorry i can't make video tutorials but feel free to ask any questions you have here.

Personally, I would just go with the nLocktime solution.
nLocktime is the last 4 bytes of all the transactions. what you meant was the lock time OP codes. but this gave me an idea for an easier method of locking funds which may be a little silly but it could work.

if you already have the funds (control the private key of the output) you can create a new transaction and send the coins to a new address from a new wallet but set the nLocktime of the transaction to a future value (like 100 days). you obviously can't broadcast this transaction because it will be rejected but you can create a backup of it. write it down on a piece of paper, put it on the internet,... then destroy the private key of the output you are spending. that means you can't double spend this output and have to wait 100 days until you can broadcast this tx and have it mined to have access to the new output in the new address from the new wallet you create in the beginning.
the problem with this method would be fees which you can't predict how much they will be in the future and you may over/under-pay.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
ABCbits
Legendary
*
Offline Offline

Activity: 2870
Merit: 7464


Crypto Swap Exchange


View Profile
November 06, 2020, 09:44:57 AM
Merited by hosseinimr93 (1), Little Mouse (1)
 #9

It's weird no one mention Bitcoin Core command createrawtransaction, which have option to set locktime. Here's output of help createrawtransaction

Code:
createrawtransaction [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount},{"data":"hex"},...] ( locktime replaceable )

Create a transaction spending the given inputs and creating new outputs.
Outputs can be addresses or data.
Returns hex-encoded raw transaction.
Note that the transaction's inputs are not signed, and
it is not stored in the wallet or transmitted to the network.

Arguments:
1. inputs                      (json array, required) The inputs
     [
       {                       (json object)
         "txid": "hex",        (string, required) The transaction id
         "vout": n,            (numeric, required) The output number
         "sequence": n,        (numeric, optional, default=depends on the value of the 'replaceable' and 'locktime' arguments) The sequence number
       },
       ...
     ]
2. outputs                     (json array, required) The outputs (key-value pairs), where none of the keys are duplicated.
                               That is, each address can only appear once and there can only be one 'data' object.
                               For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also
                               accepted as second parameter.
     [
       {                       (json object)
         "address": amount,    (numeric or string, required) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC
       },
       {                       (json object)
         "data": "hex",        (string, required) A key-value pair. The key must be "data", the value is hex-encoded data
       },
       ...
     ]
3. locktime                    (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs
4. replaceable                 (boolean, optional, default=false) Marks this transaction as BIP125-replaceable.
                               Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.

Result:
"hex"    (string) hex string of the transaction

Examples:
> bitcoin-cli createrawtransaction "[{\"txid\":\"myid\",\"vout\":0}]" "[{\"address\":0.01}]"
> bitcoin-cli createrawtransaction "[{\"txid\":\"myid\",\"vout\":0}]" "[{\"data\":\"00010203\"}]"
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "createrawtransaction", "params": ["[{\"txid\":\"myid\",\"vout\":0}]", "[{\"address\":0.01}]"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "createrawtransaction", "params": ["[{\"txid\":\"myid\",\"vout\":0}]", "[{\"data\":\"00010203\"}]"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/

It's mostly manual (select input TXID, input output number, etc.), but at least you don't need to deal with creating script manually.

Is this guide requires fee?

You need to create a transaction where the output contains custom script, so technically it requires fee (transaction fee).

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Coin_trader
Copper Member
Legendary
*
Offline Offline

Activity: 2772
Merit: 1169


Leading Crypto Sports Betting & Casino Platform


View Profile WWW
November 06, 2020, 09:50:17 AM
 #10


This is not simple for people like me that don't have any background on programming. Even though all code was written. It will need a step by step guide on how to do it like open a note and etc. A video tutorial will be very helpful to easily follow this guide. I will be happy to learn how to this since I need this feature too for saving my money that I earn here. Actually, creating a tutorial thread for this topic is very helpful pooya.  Cheesy

There are tutorials and guides available here on this forum and the world wide web. You just need to search for them.


Agreed and I already search on world wide web, I have trust issue on using online tutorial out that's why I want to know a method directly from the person I trust(In this case pooya). There still no step by step tutorial using the code he mention which I find much safer to use if I do it correctly compared on using 3rd party service provider.

Anyway coinb.in is the simplest way to this coin timelock.

EDIT:

Just read the post above. Thanks ETFBitcoin.

..Stake.com..   ▄████████████████████████████████████▄
   ██ ▄▄▄▄▄▄▄▄▄▄            ▄▄▄▄▄▄▄▄▄▄ ██  ▄████▄
   ██ ▀▀▀▀▀▀▀▀▀▀ ██████████ ▀▀▀▀▀▀▀▀▀▀ ██  ██████
   ██ ██████████ ██      ██ ██████████ ██   ▀██▀
   ██ ██      ██ ██████  ██ ██      ██ ██    ██
   ██ ██████  ██ █████  ███ ██████  ██ ████▄ ██
   ██ █████  ███ ████  ████ █████  ███ ████████
   ██ ████  ████ ██████████ ████  ████ ████▀
   ██ ██████████ ▄▄▄▄▄▄▄▄▄▄ ██████████ ██
   ██            ▀▀▀▀▀▀▀▀▀▀            ██ 
   ▀█████████▀ ▄████████████▄ ▀█████████▀
  ▄▄▄▄▄▄▄▄▄▄▄▄███  ██  ██  ███▄▄▄▄▄▄▄▄▄▄▄▄
 ██████████████████████████████████████████
▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄
█  ▄▀▄             █▀▀█▀▄▄
█  █▀█             █  ▐  ▐▌
█       ▄██▄       █  ▌  █
█     ▄██████▄     █  ▌ ▐▌
█    ██████████    █ ▐  █
█   ▐██████████▌   █ ▐ ▐▌
█    ▀▀██████▀▀    █ ▌ █
█     ▄▄▄██▄▄▄     █ ▌▐▌
█                  █▐ █
█                  █▐▐▌
█                  █▐█
▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀█
▄▄█████████▄▄
▄██▀▀▀▀█████▀▀▀▀██▄
▄█▀       ▐█▌       ▀█▄
██         ▐█▌         ██
████▄     ▄█████▄     ▄████
████████▄███████████▄████████
███▀    █████████████    ▀███
██       ███████████       ██
▀█▄       █████████       ▄█▀
▀█▄    ▄██▀▀▀▀▀▀▀██▄  ▄▄▄█▀
▀███████         ███████▀
▀█████▄       ▄█████▀
▀▀▀███▄▄▄███▀▀▀
..PLAY NOW..
Little Mouse (OP)
Legendary
*
Offline Offline

Activity: 2044
Merit: 1980


Marketing Campaign Manager |Telegram ID- @LT_Mouse


View Profile WWW
November 06, 2020, 12:05:35 PM
 #11

It seems like you are referring to create a tx which will be released at certain date, isn’t it? If so, will I be able to use the same input once I decide to spend them before the lock time? And that's not exactly my purpose.
I'm yet to figure out all the process as I'm not much techy guy but I'm trying to figure out the process and will do soon.

██████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
██████████████████████
.SHUFFLE.COM..███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
█████████████████████
████████████████████
██████████████████████
████████████████████
██████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
██████████████████████
██████████████████████
██████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
.
...Next Generation Crypto Casino...
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
November 06, 2020, 12:19:17 PM
 #12

It seems like you are referring to create a tx which will be released at certain date, isn’t it? If so, will I be able to use the same input once I decide to spend them before the lock time? And that's not exactly my purpose.

Actually it should exactly be what you are looking for.

The locktime sets the date (block height) from which the output can be spent.
The process would be that you'll generate a transaction containing the locktime to an address you have the private key of with a locktime of roughly X days and broadcast it.
After the transaction has been included into a block, you'll only be able to spend that new output (to the new address) after the locktime is over.

Little Mouse (OP)
Legendary
*
Offline Offline

Activity: 2044
Merit: 1980


Marketing Campaign Manager |Telegram ID- @LT_Mouse


View Profile WWW
November 06, 2020, 12:27:45 PM
 #13


After the transaction has been included into a block, you'll only be able to spend that new output (to the new address) after the locktime is over.
This sounds good. I'm exactly looking for this. I thought the tx itself will be locked. If the fund sent to the address can't be spent, then that’s what I'm looking for. I actually misread above posts and mixed it with something I mentioned (the tx lock). Thanks a lot. No merit to spend.

██████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
██████████████████████
.SHUFFLE.COM..███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
█████████████████████
████████████████████
██████████████████████
████████████████████
██████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
██████████████████████
██████████████████████
██████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
.
...Next Generation Crypto Casino...
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
November 06, 2020, 02:04:59 PM
Last edit: November 15, 2023, 12:42:48 AM by HCP
Merited by pooya87 (5), ABCbits (3), BitMaxz (1), hosseinimr93 (1)
 #14


After the transaction has been included into a block, you'll only be able to spend that new output (to the new address) after the locktime is over.
This sounds good. I'm exactly looking for this. I thought the tx itself will be locked. If the fund sent to the address can't be spent, then that’s what I'm looking for. I actually misread above posts and mixed it with something I mentioned (the tx lock). Thanks a lot. No merit to spend.

But unfortunately, that's not how it works... if you specify "nLockTime" in a transaction, it means that the transaction is not able to be included in a block until AFTER that time period has passed. It's like "post dating" a cheque... it can't be cashed until at least the date printed on the cheque.

If you set the locktime for a transaction to be in 100 days, no miner will be able to include that transaction in a block for 100 days... and a lot of nodes won't even propagate the transaction as they will not consider it "final"... this is the error code I get when trying to broadcast a transaction before the LockTime:
Quote
non-final (code -26)

Even if you have a transaction that is locked, you could quite easily just create another transaction that spends those same funds, that has no locktime and can be broadcast/confirmed immediately.

To prevent spending, the OP_CHECKLOCKTIMEVERIFY option (aka OP_HODL) is the answer. I have been experimenting with the "Time Locked Address" functionality on coinb.in (via TestNet) and it works as advertised. The only caveat being that you will need to use coinb.in in the future to generate and sign the spending transaction, as I don't seem to be able to get it working properly with Bitcoin Core (but that might be something I'm doing wrong)




NOTE: for the purposes of this tutorial, I have used a TestNet address and that the coinb.in code requires some tweaking to automatically retrieve the UTXOs for TestNet addresses.


Step 1 - Get a private key
- You want this in WIF format.
- You can use one from an existing wallet, but be warned, you will need to put this into coinb.in to be able to sign the spending transaction later.

Example (TestNet) PrivKey in WIF format:
cQxRyfN5wBmDAc4tX1kP2bDZ5A3woXsayc1VLXu74WVc7ukmqQb6


Step 2 - Get the public key that matches your private key
- you need the hex public key, NOT the address

Example Hex Pubkey matching PrivKey:
032371229be41fd3d89d5dddd02cdfbcafbea07ec25ff2e8d9db1c8cd5983361bc


Step 3 - Create the "Time Locked Address":
- You can do this here: https://coinb.in/#newTimeLocked
- Alternatively, you can download the coinb.in code base and run it offline
- Enter the hex public key from Step 2, and pick the date/time you want the address to be locked to.
- Click "Submit"



Step 4 - Note down the "Time Locked Address" and "Redeem Script":


Example TLA:
2NAkEGEghkTs5BGn9kgK2PbMhaE2gThPgA3

Example Redeem Script:
04e056a55fb17521032371229be41fd3d89d5dddd02cdfbcafbea07ec25ff2e8d9db1c8cd598336 1bcac


Step 5 - Send funds to the "Time Locked Address"
- This is just a "standard" transaction
- Send using whatever wallet/fee etc. that you find appropriate.


Example Funding Transaction:
64ad87ac7789eae5190b8e76570ca6ad350ffccf1a5f59af0ae774dbde190a25


Step 6 (Optional) - Try and send "locked" funds

6.a: - Load "Inputs":
- Visit https://coinb.in/#newTransaction (or use your downloaded, offline version)
- Enter redeem script and click "Load" (won't work with "offline" mode)
- Click the "Inputs" tab
- You should get the UTXO(s) in your locked address loaded:


6.b: - Create "Outputs":
- Click on the "outputs" tab
- Enter the receive address and amount you want to send (IMPORTANT NOTE: any amount you don't specify in outputs, will be used as the TOTAL fee!!)


You can see I specified an output of 0.01999700... the difference between that and the total input (0.02) is going to be used as the total fee amount (0.00000300)... Unfortunately, there isn't a way to specify a fee rate, you need to work it out yourself... these "Legacy" transactions end up being around ~200 bytes... so my total fee of 300, ends up being around 1.5 sats/byte. Pretty low, but testnet is forgiving like that Wink

6.c: - Get unsigned transaction:
- Once you're happy with the outputs and fee, click Submit:


Example raw unsigned transaction:
Code:
0100000001250a19dedb74e70aaf595f1acffc0f35ada60c57768e0b19e5ea8977ac87ad64010000002a04e056a55fb17521032371229be41fd3d89d5dddd02cdfbcafbea07ec25ff2e8d9db1c8cd5983361bcacfdffffff0154831e00000000001976a91444cb040fe56b0f22411da75b1458ac8864802bfb88ace056a55f

6.d (Optional, but recommended): - Verify your transaction:
- https://coinb.in/#verify
- Enter your unsigned transaction and click submit


Double check that everything is in order

6.e - Sign the transaction:
- Enter the unsigned transaction
- Enter the private key from Step #1
- Click Submit


As per the note, make sure to double check that your fee rate is going to be OK... in this example... size = 200, fee was 300... 300/200 = 1.5 sats/byte. If you screwed up the fee rate, you can simply go back and start Step 6 again, and use a higher fee... the transaction should end up being about the same size (maybe 1 or 2 bytes in either direction), so you should be able to calculate it easily the 2nd time round Wink


6.f - (Try) Broadcast the transaction:
- I tried to broadcast before locktime using the BlockStream Explorer (https://blockstream.info/testnet/tx/push):




and using Bitcoin Core:


Congrats... your funds are now LOCKED! Smiley


Step 7 - Broadcast once the timelock has expired:
- Now we just repeat Step 6 again, but broadcast AFTER the locktime has passed, and we can see that the transaction was a success:

2972b09a1f0f52d8810368acc894cc6b2af6a1a7ae23e73d89aec68ddf6dd8ae






Personally, I would just go with the nLocktime solution.
nLocktime is the last 4 bytes of all the transactions. what you meant was the lock time OP codes.
That is indeed what I meant... I just typed the wrong thing... this is what happens when you try to be clever after midnight! Tongue Roll Eyes

I've edited my post to reflect that.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
igor72
Legendary
*
Offline Offline

Activity: 1834
Merit: 2003


Crypto Swap Exchange


View Profile
November 06, 2020, 02:54:09 PM
 #15

nLocktime is the last 4 bytes of all the transactions. what you meant was the lock time OP codes. but this gave me an idea for an easier method of locking funds which may be a little silly but it could work.

if you already have the funds (control the private key of the output) you can create a new transaction and send the coins to a new address from a new wallet but set the nLocktime of the transaction to a future value (like 100 days). you obviously can't broadcast this transaction because it will be rejected but you can create a backup of it. write it down on a piece of paper, put it on the internet,... then destroy the private key of the output you are spending. that means you can't double spend this output and have to wait 100 days until you can broadcast this tx and have it mined to have access to the new output in the new address from the new wallet you create in the beginning.
the problem with this method would be fees which you can't predict how much they will be in the future and you may over/under-pay.
I do not see the problem, CPFP will be cheaper than a p2sh-transaction.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
LoyceV
Legendary
*
Offline Offline

Activity: 3304
Merit: 16596


Thick-Skinned Gang Leader and Golden Feather 2021


View Profile WWW
November 06, 2020, 09:29:58 PM
 #16

I want to save this for someone. I may sometime in need of fund and will spend the BTC if I have access to the fund. That’s why I want to save a fund through such a way that I will not have access certain days and thus I will not have ways to spend.
I wrote this last year: Using Locktime for inheritance planning, backups or gifts. It's important to know the Risks before doing this. I suggest to try with a small amount before funding a lot.

pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10546



View Profile
November 07, 2020, 05:48:19 AM
Merited by ABCbits (1), igor72 (1)
 #17

I do not see the problem, CPFP will be cheaper than a p2sh-transaction.
CPFP has to create a new transaction spending the unconfirmed one and pay for its own fee plus any extra fee that is needed to get the unconfirmed one bumped to high priority. that will always be more expensive than just paying higher fee in the unconfirmed tx.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
igor72
Legendary
*
Offline Offline

Activity: 1834
Merit: 2003


Crypto Swap Exchange


View Profile
November 07, 2020, 07:40:46 AM
 #18

that will always be more expensive than just paying higher fee in the unconfirmed tx.
I was sure that this p2sh-transaction would definitely be larger than 220 bytes (220 vbytes take up two P2WPKH-transactions). But I was wrong, it only takes 200 bytes. So at worst, it will be 10% more expensive. Although sometimes it will still be cheaper because there are always two transactions in the cltv-scheme rather than one.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
thepeterson
Jr. Member
*
Offline Offline

Activity: 70
Merit: 6


View Profile
July 04, 2023, 09:53:09 AM
 #19

We're you able to do it successfully and redeem without problems?

bc1qayjc2zk32dthw9pqakrv8twtm8neawux4l72t7
Flexystar
Full Member
***
Offline Offline

Activity: 1092
Merit: 227



View Profile
July 04, 2023, 03:53:55 PM
 #20

The one that is being discussed here and the one I am about to write below, are these one and the same locking processes for the transactions/bitcoin in the wallet? I mean what is being asked in OP reads out as, I have bitcoins in my wallet which I should be able to lock and I can’t just spend them in any way possible.

However, checkout this article here Locktime Field in a Transaction used for Post-dating.

So just would like to know that whatever explained in the article linked above is related to transactions that we do which can be locked until specific block is mined. I think this is one of the way to do it? We can always send the transaction to our own address and use the method mentioned in the article thus locking it for specified time period.
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!