Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: voileipa on September 09, 2014, 12:59:09 PM



Title: Correct steps for a delayed transaction?
Post by: voileipa on September 09, 2014, 12:59:09 PM
I'm trying to create create a delayed transaction for myself. I'm using nLockTime and the following steps. The situation what I'm trying to reach is that there are 1 BTC that is not reachable until 10 000 blocks are found.

Are the following steps correct?

1. I create a new key-address pair. (KEY1 1Address1)
2. I send 1BTC to address 1Adddress1
3. I create new key-address pair. (KEY2 1Address2)
4. I create a transaction with nLockTime (currentblockheight + 10000). The input is 1Address1 and output 1Address2. I sign it with KEY1. HOWEVER, I do not broadcast the transaction.
5. I destroy KEY1.
6. Now I have a transaction, which is now valid until 10 000 blocks are found and I store it. After 10 000 blocks are found I broadcast the transaction and unlock the bitcoins with KEY2.

Does this work or can I just replace the nLockTime in the transaction with 0, so the transaction becomes instantly valid?


Title: Re: Correct steps for a delayed transaction?
Post by: DannyHamilton on September 09, 2014, 01:50:40 PM
I'm trying to create create a delayed transaction for myself. I'm using nLockTime and the following steps. The situation what I'm trying to reach is that there are 1 BTC that is not reachable until 10 000 blocks are found.

Are the following steps correct?

1. I create a new key-address pair. (KEY1 1Address1)
2. I send 1BTC to address 1Adddress1
3. I create new key-address pair. (KEY2 1Address2)
4. I create a transaction with nLockTime (currentblockheight + 10000). The input is 1Address1 and output 1Address2. I sign it with KEY1. HOWEVER, I do not broadcast the transaction.
5. I destroy KEY1.
6. Now I have a transaction, which is now valid until 10 000 blocks are found and I store it. After 10 000 blocks are found I broadcast the transaction and unlock the bitcoins with KEY2.

Does this work

Yes.

or can I just replace the nLockTime in the transaction with 0, so the transaction becomes instantly valid?

No.  If you replace nLockTime, then the signature is no longer valid.


Title: Re: Correct steps for a delayed transaction?
Post by: Buffer Overflow on September 10, 2014, 07:15:35 AM
I should do some attempts on the testnet before trying out for real. Just in case something goes wrong.


Title: Re: Correct steps for a delayed transaction?
Post by: voileipa on November 02, 2014, 02:20:08 PM
Hhhm.. the nLockTime is not working.

I created a transaction with locktime = 630000 but it is still included in the blockchain

https://blockchain.info/tx/18b598bd76110151d6bea797d3c10bcfdc44454303da6d74fbd3f15c5e851d0a



Title: Re: Correct steps for a delayed transaction?
Post by: Buffer Overflow on November 02, 2014, 02:55:23 PM
Hhhm.. the nLockTime is not working.

I created a transaction with locktime = 630000 but it is still included in the blockchain

https://blockchain.info/tx/18b598bd76110151d6bea797d3c10bcfdc44454303da6d74fbd3f15c5e851d0a



If all TxIn inputs have final (0xffffffff) sequence numbers then locktime is ignored.


Title: Re: Correct steps for a delayed transaction?
Post by: voileipa on November 02, 2014, 05:43:28 PM
Hhhm.. the nLockTime is not working.

I created a transaction with locktime = 630000 but it is still included in the blockchain

https://blockchain.info/tx/18b598bd76110151d6bea797d3c10bcfdc44454303da6d74fbd3f15c5e851d0a



If all TxIn inputs have final (0xffffffff) sequence numbers then locktime is ignored.

Thanks for the response. I set the sequence number to 0 and after that my bitcoind didn't broadcast the transaction until the given block height was reached:

Code:
>./bitcoin-cli sendrawtransaction $SIGNED_RAW_TX                  
error: {"code":-26,"message":"64: non-final"}

After the block height was reached I finally got the transaction in the block chain as expected:
https://blockchain.info/tx/d61839fb690395ba638ba804c5af4bf0111ff269ca1e0b251cff737ca6189557


I hope all nodes will relay (now and in future) transactions with custom nLockTimes and sequences!