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
  • 71,155
  • 33
  • 180
  • 600
Nick ODell
  • 29,184
  • 11
  • 69
  • 129
  • related: [What is the coin selection algorithm?](http://bitcoin.stackexchange.com/q/1077/5406) – Murch Aug 13 '15 at 10:26

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
  • 71,155
  • 33
  • 180
  • 600
Jonas Schnelli
  • 5,992
  • 1
  • 20
  • 33