<div dir="ltr">FWIW, The Open Assets colored coin protocol (CoinPrism) places special significance on the zeroth input and the position of the OP_RETURN colored coin marker output to distinguish colored coin issuance outputs from transfer outputs. Reordering the inputs or the outputs breaks the colored coin representation.<div><br></div><div>Recommending sorting of the inputs and outputs as a best practice is fine (and better than random, IMO), but not as part of IsStandard() or consensus rules.  There are cases where the order of the inputs and outputs is significant.</div><div><br></div><div>-Danny</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 5, 2015 at 9:42 PM, Rusty Russell <span dir="ltr">&lt;<a href="mailto:rusty@rustcorp.com.au" target="_blank">rusty@rustcorp.com.au</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Title: Canonical Input and Output Ordering<br>
Author: Rusty Russell &lt;<a href="mailto:rusty@rustcorp.com.au">rusty@rustcorp.com.au</a>&gt;<br>
Discussions-To: &quot;Bitcoin Dev&quot; &lt;<a href="mailto:bitcoin-development@lists.sourceforge.net">bitcoin-development@lists.sourceforge.net</a>&gt;<br>
Status: Draft<br>
Type: Standards Track<br>
Created: 2015-06-06<br>
<br>
Abstract<br>
<br>
This BIP provides a canonical ordering of inputs and outputs when<br>
creating transactions.<br>
<br>
Motivation<br>
<br>
Most bitcoin wallet implementations randomize the outputs of<br>
transactions they create to avoid trivial linkage analysis (especially<br>
change outputs), however implementations have made mistakes in this area<br>
in the past.<br>
<br>
Using a canonical ordering has the same effect, but is simpler, more<br>
obvious if incorrect, and can eventually be enforced by IsStandard() and<br>
even a soft-fork to enforce it.<br>
<br>
Specification<br>
<br>
Inputs should be ordered like so:<br>
        index (lower value first)<br>
        txid (little endian order, lower byte first)<br>
<br>
Outputs should be ordered like so:<br>
        amount (lower value first)<br>
        script (starting from first byte, lower byte first, shorter wins)<br>
<br>
Rationale<br>
<br>
Any single wallet is already free to implement this, but if other<br>
wallets do not it would reduce privacy by making those transactions<br>
stand out.  Thus a BIP is appropriate, especially if this were to<br>
become an IsStandard() rule once widely adopted.<br>
<br>
Because integers are fast to compare, they&#39;re sorted first, before the<br>
lexographical ordering.<br>
<br>
The other input fields do not influence the sort order, as any valid<br>
transactions cannot have two inputs with the same index and txid.<br>
<br>
Reference Implementation<br>
<br>
<a href="https://github.com/rustyrussell/bitcoin/tree/bip-in-out-ordering" target="_blank">https://github.com/rustyrussell/bitcoin/tree/bip-in-out-ordering</a><br>
<br>
------------------------------------------------------------------------------<br>
_______________________________________________<br>
Bitcoin-development mailing list<br>
<a href="mailto:Bitcoin-development@lists.sourceforge.net">Bitcoin-development@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/bitcoin-development" target="_blank">https://lists.sourceforge.net/lists/listinfo/bitcoin-development</a><br>
</blockquote></div><br></div>