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.

Saturday 25 January 2014

How Bitcoins work - a clear and (relatively) simple explanation

Bitcoins are cool and will change the world.

I would say this however as I have more than a passing interest.

But it is fair to say that it is not easy to find a clear and relatively simple description of how a Bitcoin transaction works.

That was until I came across this infographic from Dr. Constantin Gurdgiev

(best viewed when opened in a new window)


I will likely return to write about more specific aspects of Bitcoin, the Bitcoin protocol and the Block chain at a later stage but for now enjoy.


Thursday 9 January 2014

After Earth - A movie more important than 12 Years a Slave, Django, The Butler and Mandela combined?

Bear with me while I explain myself ...

After Earth, the movie starring Jaden Smith and his father Will Smith, received mix reviews from the critics and the public alike and has so far struggled to make a profit.



Conversely, 12 Years A Slave, starring one of my favourite British actors, Chiwetel Ejiofor, has been nominated for two Oscars while Django Unchained, The Butler and Mandela: Long Walk To Freedom have all received strong reviews.

So why do I believe that After Earth is more significant than all of the above? Because it is one of the few examples of a big budget film that completely eschews the stereotypical portrayal of a black lead actor.

In the movie, Will Smith is a giant among men.  He has no vices, is a family man, a dutiful soldier and revered by all who know him.  By the end of the movie, his son played by Jaden also goes on to become just as fearless and accomplished as he.  No mention is made of the colour of their skin and although the leads are both black, it is completely incidental to the plot.

Contrast this with 12 Years A Slave directed by the uber-talented Steve McQueen.  Although it is undeniably an amazing movie, the plot follows the well-worn path of showing a black man, cruelly tricked and oppressed by evil white men.  Although executed extremely well this is not a new idea.

What Will Smith has done is create a film which doesn't just make black people feel angry and white people feel at best guilty and at worst pity.  Instead, it creates a new narrative - one where both black and white moviegoers can come away with a feeling of respect, admiration and even a little jealousy towards the protagonists.  The unapologetically positive depiction of the black leads presented in After Earth is extremely rare, especially in such a big budget movie.

I believe more movies like After Earth need to be made.  Films like this will in the long run, have more of an effect on changing the perception the public has of black people than any movie about, slaves, servants or the downtrodden ever could.

In case you were wondering, I have watched After Earth and found it to be a very enjoyable movie.