Monday 14 July 2014

The Transfer, the Block chain's missing link

There is more to the block chain than Blocks and Transactions.

Bitcoin and most of its alternatives have one fundamental element - the Block chain.  The block chain is a shared list of all the bitcoin transactions that were ever made.  The transactions are conveniently grouped up into sets called blocks that get created roughly once every 10 minutes.

However, I believe that there is another type of object scattered across the block chain that you may not be directly aware of.  In fact, even though it is by far the most prevalent, it has remained unnamed (AFAIK).

I like to call it the OutIn  Transfer*.

Bitcoin transactions are made up of a number of inputs (which are references to outputs from previous transactions or "coinbase" in the case of newly mined bitcoin) and a number of outputs (which collectively contain information about who the transaction should pay and how much it should pay them).

Every input can reference nought or one output and every output can only be referenced by nought or one input.  Furthermore, once a relationship has been formed between an output and an input, it can never be broken except by a major event such a block chain split.  So basically, these output and input pairs behave an awful lot like two sides of the same coin (pun definitely intended).

It was this realisation that made me think about what it would mean to treat outputs and inputs as Transfer objects connected to two transactions on either side but existing separately from both. This was in contrast to how they are thought of at present as simply a set of transaction attributes.

At this point a pretty graph may be in order:

The Block chain with missing Transfer "links"

In this graph you can easily see a few things:

  • Transfers are clearly shown as being distinct entities and not subsets of either transactions or blocks.
  • The value in bitcoin associated with a Transfer is always held in the "Out-side transaction".
  • You can see that "Unspent Transaction Outputs" (UTxOs) are actually just Transfers that have not yet been linked to an "In-side transaction".
  • Similarly, it is easy to surmise that freshly mined bitcoin would come from Transfers with coinbase In-related data.
 I believe that this way of viewing the block chain as a series of block-bound transactions connected by a number of Transfer "links" extremely useful for a number of reasons:

  • It's easy to visualise and think about.
  • It's intuitive.
  • It clarifies the chain-like nature of the Block chain. Transfers are actually the missing links of the Block chain.
  • Contrary to popular belief, transactions are not user or address specific but Transfers are. Although today most transactions tend to have inputs from and outputs to addresses all owned by one entity, with the increased need for scale and the growing desire for privacy, the use of services such as CoinJoin will mean that more and more transactions will involve multiple parties.  Over time, a representation such as the Transfer will become more and more useful as a way of thinking about the subset of transactions that relate to an address or set of addresses in isolation.
  • Transfers are efficient ways of thinking about address specific block chain operations (see below).
An example of the utility of Transfers can be seen if one thinks about retrieving a list of unspent transaction outputs (UTxOs) for a particular address.

Currently, if you were to explain to someone how to generate this list you might tell them to do the following:
  1. Go to each block where you have transactions confirmed and list the transactions.
  2. For each of these transactions, list the outputs that you were responsible for.
  3. Record each output.
  4. For each subsequent block, locate transactions that have inputs referencing one of the recorded outputs.  If there is a match remove it from the recorded list.
  5. If you have any outputs left this is your list of unspent transaction outputs.
In contrast, if you are thinking about the connections between transactions as Transfers you would describe how to get the list of unspent transaction outputs as follows:
  1. Get a list of all Transfers with no In-side transaction details.
  2. Return the Out-related data only.
It is a similar story if you want to retrieve a list of past transactions or any other address specific query.  

I will continue to explore the Transfer object, focussing especially on its query efficiency compared to more traditional block chain representations.


* Thanks Matt W for the alternative name suggestion.
Thanks Eze and Matt for a number of suggestions with respect to improving the approach.

No comments:

Post a Comment