What are the trade-offs between the different algorithms for deciding which UTXOs to spend?

When someone would like to make a transaction, their software has to choose which of their UTXOs to spend. Here are a few different ways that one might prioritize which UTXOs get spent.

  • Oldest UTXOs first
  • Newest UTXOs first
  • UTXOs with the smallest amounts first
  • UTXOs with the greatest amounts first
  • The Core Client Selection Algorithm: What is the coin selection algorithm?
  • Others?

What the trade-offs are for the different ways of prioritizing spending of UTXOs? Are some faster? Do some make make the block chain less big (grow less quickly)? Do some make the UTXO set smaller? What about making it so that the user has to pay the least fees? Taking all these factors into consideration, is there a method that is generally accepted to be the best way?

On possibility, which I like, is to spend the most UTXOs possible while still staying in the 1kb minimum fee limit. That way if nodes that prune the blockchain of STXOs (spent transaction outputs), they can prune more and it makes the blockchain smaller for them. Although, this might cause a small amount of bloating for nodes who keep the whole block chain, so it’s a tradeoff.

What is the alt stack?

I noticed in the bitcoin wiki script page (https://en.bitcoin.it/wiki/Script) that there were two opcodes named:


It looks like there is another stack that can be used separately as a data store, simply pushing and popping data. I’ve never heard of this before, but it seems like a very useful feature.

Can anyone verify that this is what the alt stack is actually meant to be used for? If not for just pushing and popping data, what is it for? Do any specific use cases come to mind?

Difference between bitcoin-tx, bitcoin-cli, and bitcoind?

I just pulled from the bitcoin github and compiled, and noticed that there were three executable generated:

bitcoin-cli  bitcoin-tx   bitcoind

I have not heard of bitcoin-tx before, what is it? What are the main similarities/differences between these three executables?

In addition, I would be interested to find out if there are any plans to further develop these into different, complementary, executables.

Thank you!

How did Satoshi manage to mine so many bitcoins being the first user of the system?

I’m just learning about Bitcoin and if I understand its conception properly, mining bitcoins means validation of transactions by computing a hash which should satisfy some preset condition. In other words, mining == servicing network and getting money for it.

If Satoshi was the first user, how did he earn his bitcoins if there were no transactions?

I understand, that in the very beginning some geeks were involved in the network, so maybe 5 or 10 persons’ (first testers) transactions and their validation (mining) generated a lot of bitcoins, because of the low difficulty and high reward. But how did the very first coins get rewarded?

Why block height is required in coinbase?

While reading bitcoin source I found this short comment:

// Height first in coinbase required for block.version=2

(From https://github.com/bitcoin/bitcoin/blob/master/src/miner.cpp#L338).

Why this is required? Does it prevent some misuse or attack?

I found that this change was introduced in BIP-0034. In relevant pull request it is justified by following points:

Putting the height in the coinbase is desired for at least two reasons:

  1. It guarantees that every subsequent block and transaction hash is unique.
  2. It can be used to better reason about plausible difficulty for not-yet-connected blocks.

But for me this explains nothing: I don’t see how adding height guarantees unique block hashes and I don’t understand what is “plausible difficulty for not-yet-connected blocks”.