I see two ways:

Txid + index

Txid + script hash

Pros of the txid + index:

  • Simple and short

Cons of txid + index:

  • It relies on array iteration being deterministic and all third party services using the same iteration method.

Txid + script hash does not rely on iteration order and since script hashes are stored on the blockchain they are not malleable after 6 confirmations.

Which would be the preferred way to go?

  • 3
    What if there are two outputs of the same transaction with the same scriptPubKey, but different amount? Also why would index not be deterministic? Transactions have a well defined order of their outputs. It's also not a question, as the Bitcoin protocol requires referring to the output being spent using txid+index. – Pieter Wuille Mar 2 '19 at 18:02
  • @PieterWuille Great points, didn't consider multiple identical scripts having different amounts. That completely excludes that option. I will rely on txid+index like bitcoin then. Thanks a lot! – Soggiorno Mar 2 '19 at 18:16

Your Answer

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

Browse other questions tagged or ask your own question.