A neat overview

Bitcoin transactions can be best understood as a series of transaction inputs and outputs chained together. The output of one transaction becomes the input of another and this repeats over and over. Here is a flowchart describing this (each blue box represents a separate transaction).

Note: recall that addresses are anonymous and do not contain any names or personal data! The names here are for simplification only.

  1. transactionsAlice receives 10BTC.
  2. She uses the output of the receiving transaction as input for Bob.
  3. Bob receives 10BTC from Alice.
  4. Bob uses the output of Alice’s transaction as input for Chloe and Dan.
  5. Dan uses the output of Bob’s transaction as input for future transactions.
  6. Chloe also uses the output of Bob’s transaction as input for future transactions.

There are two important rules: every input must be consumed entirely and each output can be referred to only once! The following flowchart shows what this means (steps 4 and 5).

  1. Alice receives 10BTC.transactions 2
  2. She uses the entire output of the receiving transaction as input for Bob.
  3. Bob receives 10BTC from Alice.
  4. Bob must use the entire output of Alice’s transaction. He only sends 7BTC to Chloe. Because there are 3 unspent BTC, he creates another output sending them back to himself.
  5. Bob receives 3BTC back from himself. This is called change. The output of the 3BTC transaction is used as input for future transactions. He can not refer to any used outputs again – they are marked as spent.
  6. Chloe also uses the output of Bob’s transaction as input for future transactions.

Although it can be done, the change is usually not sent back to the original address, but to a newly created one. This means that every Bitcoin address is used for only one transaction. After this its entire balance is spent and if necessary, change is sent to a new address. This ensures a higher degree of security and prevents statistical analysis which could expose information about Bitcoin users and their behavior. Because the entire transaction history is visible to anyone, by using an entirely new change address every time, an observer can not know which output was transferring BTC to another person and which was simply change. If Bob would send the 3BTC change back to his original address, an observer would know that he send 7BTC to another person and 3BTC back to himself. Such information is extremely valuable for deanonymizing Bitcoin users. Additionally it is possible for Bob to create several outputs – each to a different address which belongs to Chloe and some back to himself as change:
transactions 3

An observer would have no clue which address belongs to who and what amount of BTC was transferred to who.
This process may seem complicated, but is done seamlessly by your Bitcoin software. You do not even have to remember your Bitcoin addresses – the software does everything for you. You may wonder where the private keys mentioned in Bitcoin addresses come in play. In short, these are used to sign transactions, so that only the owner of a BTC address’ private key can spend its balance. Therefore it is extremely important to keep them very, very secret.

The dirty details

Again, what was described above was very simplified and abstract. If you only wanted to get a basic idea of BTC transactions, this should be the case now. If you are interested in more details, read on.

Recall that we said Bitcoin addresses are public key hashes – this was only half the truth. Bitcoin transactions make heavy use of a simple scripting language. Without going too much into details, this scripting language is used to set the conditions of who gets to spend Bitcoins. When you transfer BTC to someone, you do not simply send it to their address, but instead you create a script, which specifies who is allowed to use your output as input for their future transactions. The simplest and most commonly used script is “The person who can provide a public key that hashes to value XXXXXXXXX AND who can prove that he owns the corresponding private key, is allowed to use these BTC“. When you make a transaction yourself, you use somebody else’s output as input by satisfying the conditions that he set. If this sounds confusing, consider the following dialog between two BTC users:

Bob: I want to send you 5BTC.
Alice: OK, my address is XXXXXXYYX. This is the hash of my public key.
Bob: I will set the unlocking script to require the public key which hashes to XXXXXXYYX and a valid signature from the corresponding private key.
Alice: Great. Since I am the only one who knows which public key hashes to XXXXXXYYX and who possesses the private key, I will be the only person able to spend these 5BTC.

The use of a scripting language is extremely useful. The conditions you may set are only limited by your imagination. You can set the spending condition to be “the person who can prove owning the private keys to address a, b, and c gets to use this output“. This is a so called multisig condition, because in order to spend it you are required to supply three different signatures from private keys a, b, and c. You can either own a, b, and c yourself and profit from three times the security of a single private key, or you can split them between three people. If the output is to be used (if the BTC on the address are to be spend), all three people need to agree and supply their private keys (escrow). Other useful conditions may be “Supply 5 valid signatures for any of the following 8 addresses a, b, c, d, e, f, g, h“. 5 out of the 8 private keys would be required to spend this output, requiring a majority of the key holders (voting). The BTC amount in the output will be protected by five private keys! You get the basic idea.

As a silly example you could also set the unlocking condition (the script) of a 5BTC output to be “The person who solves 2+2 gets to use this output“. Someone knowing the answer will point to this output in his input, provide the solution “4” and use the 5BTC.

A typical transaction consists of many inputs and outputs (up to hundreds) and looks like this:
transWith all this information, you now how a very solid understanding of how Bitcoin transactions work, how flexible they are, and how public key cryptography secures the whole system.

- Back to top -