Reference an UTXO of a transaction that has not been yet mined

0

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?

Bruce Wayne

Posted 2019-01-15T14:53:50.130

Reputation: 337

Answers

4

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.

James C.

Posted 2019-01-15T14:53:50.130

Reputation: 2 183

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 2019-01-15T15:19:00.847

1Exactly :) you can always chain tx together this way. As long as the immediate parent is confirmed, the subsequent tx will be accepted in mempoolJames C. 2019-01-15T15:21:21.297

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.

G. Maxwell

Posted 2019-01-15T14:53:50.130

Reputation: 6 039

This seems to be more of an improvement suggestion to James answer 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 2019-01-16T03:21:27.300