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?

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.

  • 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 Jan 15 at 15:19
  • 1
    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. Jan 15 at 15:21
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.

  • 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 Jan 16 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.