2

What order does Bitcoin core place the inputs it spends in? Is it random? Is it sorted by anything? What, if anything, can you tell about the originator of a transaction by the input ordering?

Murch
  • 75,206
  • 34
  • 186
  • 622
Nick ODell
  • 29,396
  • 11
  • 72
  • 130

1 Answers1

5

The inputs are chosen by the function SelectCoins() in CreateTransaction() and then added one by one (without shuffling) to the transaction.

The order is defined by the coin selection (CWallet::SelectCoinsMinConf) which does a random shuffle of the potential useful inputs and a stochastic approximation.

Mind also that Bitcoin-Core's coin selection could be improved and there are several issues and improve proposals ([1], [2], [3])

Murch
  • 75,206
  • 34
  • 186
  • 622
Jonas Schnelli
  • 6,052
  • 1
  • 21
  • 34