[RFC] Canonical input and output ordering in transactions



Summary:

In June 2015, Rusty Russell proposed a Bitcoin Improvement Proposal (BIP) that provides a canonical ordering of inputs and outputs when creating transactions. The motivation behind this proposal was to avoid trivial linkage analysis by randomizing the outputs of transactions created by most bitcoin wallet implementations. However, such implementations have made mistakes in this area in the past. Using a canonical ordering has the same effect but is simpler, more obvious if incorrect, and can be eventually enforced by IsStandard() and even a soft-fork to enforce it. The specification provided by Russell stated that inputs should be ordered by index (lower value first) and txid (little endian order, lower byte first). Outputs should be ordered by amount (lower value first) and script (starting from first byte, lower byte first, shorter wins). Any single wallet is already free to implement this, but if other wallets do not, it would reduce privacy by making those transactions stand out. Thus, a BIP is appropriate, especially if this were to become an IsStandard() rule once widely adopted.The reference implementation for this proposal can be found here: https://github.com/rustyrussell/bitcoin/tree/bip-in-out-ordering.


Updated on: 2023-06-09T22:18:27.299586+00:00