For any given transaction, I would like to know which input corresponds to which output. I am specifically referring to the case where there are multiple inputs/outputs.
Is this possible? If yes, are there exceptions that you could elaborate on?
Bitcoin Stack Exchange is a question and answer site for Bitcoin users, developers, and enthusiasts. It only takes a minute to sign up.
Sign up to join this communityFor any given transaction, I would like to know which input corresponds to which output. I am specifically referring to the case where there are multiple inputs/outputs.
Is this possible? If yes, are there exceptions that you could elaborate on?
You can think of a transaction as a melting pot. All the inputs get melted down and recast into the outputs, so there is some of every input in each input. All inputs create all outputs together.
Exceptions would perhaps be if an input uses the SIGHASH_SINGLE
flag that make inputs only commit to one output in the transaction instead of all outputs, or if an input declares SIGHASH_NONE
that only commits to the inputs of a transaction but not the outputs. (See Raghav Sood's excellent explanation of the Signature Flags for more information.) These may appear in the context of multi-user transactions.
There may be other hints that may allow a surveillant to guess the ownership of outputs, though. E.g. if a transaction only spends one type of UTXOs for its inputs and creates two different output types of which one matches the inputs, that may be an indicator that the matching output is a change output. The Bitcoin Wiki has an excellent page on Privacy, further describing this and other privacy leaks.
If a transaction has multiple inputs and multiple outputs, but the values of some inputs (or subset sums of some inputs) directly correspond with amounts appearing in the outputs, it may be guessed that certain input sets funded the creation of specific outputs, but multiple users banded together to create a transaction. A colleague of mine, Felix Maurer wrote his master thesis “Anonymity in Bitcoin - Unlinkable transactions in cryptocurrencies” in 2016 on a topic closely related to that, but I could not quickly find the thesis online. IIRC it resulted in the paper Maurer et al (2017): Anonymous CoinJoin Transactions with Arbitrary Values which you may find interesting.
In general this is not possible.
In some cases, where the transaction creator doesn't care about privacy and, for example, the transaction has one input and two outputs, you can sometimes work out which of the two outputs is change