This question and its answers discussed the meaning and purpose of the vout array of a transaction in good detail. However, I have so far not been able to find any good information about how outputs in vout are ordered.

For example, suppose a collaborative transaction involves two inputs and three outputs, where two of the outputs are change utxos that are sent to the respective parties who owned the inputs, would the 0-index vout always be the non-change output? Alternatively, would it be the highest value output (i.e. outputs are arranged in descending value order)? If neither is accurate, what is the vout ordering logic?

For a general transaction, are there any constraints in Bitcoin's consensus/conventions surrounding the ordering of vouts (and I suppose inputs, while we're on the subject)? I.e. is there a possibility that a transaction could be rejected by nodes for having an 'invalid' vout ordering?


For normal transactions¹, there are no constraints on the order of outputs. The general standard seems to be that people randomize all inputs and outputs after assembling their transaction before signing. There is also a Bitcoin Improvement Proposal (BIP69) which suggests a lexicographical order for inputs and outputs. Uniform sorting is meant to help transactions from various wallets look more alike. It is explicitly declared as optional, since it interferes with some other use cases and some respondents considered it worse than just randomized order.

¹There are some exceptions, for example if you use the sighash_single sighash flag, your input will only commit to the one output with the same index.

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.