<p>Worth keeping in mind: Unless all inputs to the original transaction are segwit and at least one is sighash all, the original transaction will be vulnerable to third party malleability so your second spend could get invalidated.</p>

CC BY-SA 4.0
2019-01-16T03:21:27.300Z
This seems to be more of an improvement suggestion to [James answer](https://bitcoin.stackexchange.com/a/83676/5406) than an answer to the asker's question. Please be sure to address the asker's question if you post an answer post. When making suggestions to other answerers please use a comment.
Murch
CC BY-SA 4.0
2019-01-15T17:47:55.693Z
2019-01-15T17:47:55.693Z
G. Maxwell
<p>The UTXO is referenced as an outpoint(TXID, Index) in the input of your time-locked spending transaction.</p>

<p>So, when creating your time-locked transaction, you need to know the TXID of the (unconfirmed) transaction you are spending. </p>

<p>Simply double+sha256 and swap endianness of the over-the-wire transaction serialisation to get the TXID you wish to reference. </p>

<p>This TXID is a unique identifier (assuming no TX malleability). The outpoint you are referencing in your spending transaction is not affected by the confirmation of said UTXO.</p>

CC BY-SA 4.0
2019-01-15T15:19:00.847Z
Thank you. So, with "Simply double+sha256 and swap endianness of the over-the-wire transaction serialisation to get the TXID you wish to reference." you mean that in this way I can find TXID before spreading transaction over the network? And with it I can create the timelocked transaction. Right?
Bruce Wayne
CC BY-SA 4.0
2019-01-15T15:21:21.297Z
Exactly :) you can always chain tx together this way. As long as the immediate parent is confirmed, the subsequent tx will be accepted in mempool
James C.
CC BY-SA 4.0
2019-01-15T15:04:03.880Z
2019-01-15T15:04:03.880Z
James C.
<p>How to reference an UTXO that has not been yet mined? I want to prepare a transaction and, before spreading it, use its UTXO as input for another relative timelocked transaction. Then, spread the first prepared transaction.
How to do it? </p>

<utxo><transaction-input><locktime>
Reference an UTXO of a transaction that has not been yet mined
Bruce Wayne
# Reference an UTXO of a transaction that has not been yet mined

(Asked by: username_0 on 2019-01-15)

How to reference an UTXO that has not been yet mined? I want to prepare a transaction and, before spreading it, use its UTXO as input for another relative timelocked transaction. Then, spread the first prepared transaction.
How to do it?

**Tags:** utxo, transaction-input, locktime


---

## 2 answers

### Answer by username_3 on 2019-01-15. Score: 4 | Accepted answer

The UTXO is referenced as an outpoint(TXID, Index) in the input of your time-locked spending transaction.

So, when creating your time-locked transaction, you need to know the TXID of the (unconfirmed) transaction you are spending.

Simply double+sha256 and swap endianness of the over-the-wire transaction serialisation to get the TXID you wish to reference.

This TXID is a unique identifier (assuming no TX malleability). The outpoint you are referencing in your spending transaction is not affected by the confirmation of said UTXO.

> **Comments:**
> **username_0**: Thank you. So, with "Simply double+sha256 and swap endianness of the over-the-wire transaction serialisation to get the TXID you wish to reference." you mean that in this way I can find TXID before spreading transaction over the network? And with it I can create the timelocked transaction. Right?  
> **username_3**: Exactly :) you can always chain tx together this way. As long as the immediate parent is confirmed, the subsequent tx will be accepted in mempool  

---

### Answer by username_1 on 2019-01-15. Score: 3

Worth keeping in mind: Unless all inputs to the original transaction are segwit and at least one is sighash all, the original transaction will be vulnerable to third party malleability so your second spend could get invalidated.

> **Comments:**
> **username_2**: This seems to be more of an improvement suggestion to [James answer](https://bitcoin.stackexchange.com/a/83676/5406) than an answer to the asker's question. Please be sure to address the asker's question if you post an answer post. When making suggestions to other answerers please use a comment.  

---

