Skip to content

Latest commit

 

History

History
163 lines (96 loc) · 5.13 KB

bitcoin.md

File metadata and controls

163 lines (96 loc) · 5.13 KB

Bitcoin

http://en.wikipedia.org/wiki/Bitcoin

Alternatives

Bitcoin is the most popular one today, but there are others:

Specification

Bitcoin is a protocol.

TODO There seems to be no specification besides the source of the original implementation?

General concepts

There is no centralized entity that verifies the money. That is why anarchists like Bitcoin. And why it's more efficient and makes part of baking useless.

If a transaction is done, everyone knows it, can attach it to an user ID, and where the money come from. This is interesting as it puts trust on everyone's eyes instead of that of a bank.

The question is of course who is behind the hash ID.

There is no entity that corresponds to a single bitcoin: only transactions. When you send a bitcoin, you are making a transaction, and saying from which other transaction the money comes from.

Ledger

http://en.wikipedia.org/wiki/Ledger

Specification Overview

This supposes you know what SHA-256 does.

Data is JSON encoded as follows (with abbreviated hex SHA-256 hashes):

{
    "hash": "7c4025...",
    "ver": 1,
    "vin_sz": 1,
    "vout_sz": 1,
    "lock_time": 0,
    "size": 224,
    "in": [
        {
            "prev_out": {
                "hash": "2007ae...",
                "n": 0
            },
            "scriptSig": "304502... 042b2d..."
        }
    ],
    "out": [
        {
            "value": "0.31900000",
            "scriptPubKey": "OP_DUP OP_HASH160 a7db6f... OP_EQUALVERIFY OP_CHECKSIG"
        }
    ]
}

Where:

  • hash: hash of the rest of the transaction. This is the ID of the transaction.

  • ver: protocol version. The only one so far is 1.

  • vin_sz, vout_sz: number of inputs and outputs. This transaction has one of each, but more are possible. TODO.

  • lock_time: 0 is the most common. TODO.

  • size: length in bytes of the data that follows

  • in:

    List of transactions from which the money to be transfered comes from: every sent bitcoin comes from an older transaction.

    Their valued is summed. Each input comes from an older transaction.

    • prev_out:

      • hash: hash of the transcation the money for this transaction comes from
      • n: the number of output of that transacation that the money comes from, in this case the first, 0

      If you backtrack more and more, you will reach either of:

      • https://en.bitcoin.it/wiki/Genesis_block which was necessary to start up the system, and must be treated specially.
      • coinbase transaction (huge majority), which were bitcoins generated as miner rewards
    • scriptSig:

      • 304502: TODO
      • 042b2d: TODO
  • out:

    • value: value being sent

      The sum of the output values of the input transactions must be equal or greater than this.

      If greater, the remainder goes to the miner who verified the transaction. TODO rationale?

      To avoid losing money this way, you can create a transaction with 2 outputs:

      • the real target with the correct address
      • yourself for the rest
    • scriptPubKey:

      • a7db6f: destination address

You can trace transactions back

Scripting

TODO

Implementations

Bitcoin core is the reference implementation by the core developers.

Tools

Trivia