Author Archives: James

2015 – Year of the Payment Channel

If 2014 was the year of multisig in bitcoin, then 2015 should be the year of the payment channel. Multisig solved the most near term problem everyone was facing by helping them prevent coins from being stolen or services from taking control of users private keys. While it hasn’t been completely rolled out to every service, we have seen the leaders in space adopt the new technology, like Coinbase’s Multisig Vault. If we assume that this immediate challenge has been tackled, we should look forward to see what the next is, and I believe they can be solved with payment channels.

Continue reading

Why the “Internet of Things” will be run on the Blockchain

Why aren’t all refrigerators connected to the Internet?

When the Internet of Things is discussed, the example of a refrigerator connected to the Internet always comes up. This fridge is supposed to monitor what is contained inside of it, and automatically order items when they get depleted. These items will then be delivered via a service like Instacart, right to your door.

I personally can’t wait for this, since I spend a majority of time scavenging in our kitchen, looking for what I can make without having to go to the store to buy more food. Also, even though I use Instacart, it still takes time to figure out what we need, and also think about meeting minimum requirements so the delivery fee doesn’t seem astronomical compared to the purchase (e.g. $5 delivery fee for $3 of milk).

So why doesn’t this exist? The technology is available to connect things to the Internet, research has been done to put cameras into a fridge and know what is missing, and we already have food delivery services. The only explanation is economics.

Nest Thermostat

Let’s take a look at one of the few existing success stories for Internet connected appliances, the Nest Thermostat. The Nest Thermostat is sold for a pretty high price of approximately $250. Assuming the hardware costs approximately $100 and the retailer captures approximately $50 of the price, this leaves approximately $100 left over for the company.

You may say “Great!” the company gets $100 per sale of each device, but the problem is that the liability of the company is ongoing. For each device the company sells, they need to provide some sort of centralized cloud service over the Internet that each device connects to, gets updates from, and communicates with in order to be “Smart”.

My guess is that most people don’t plan on changing their thermostat very often. If the Nest is supposed to last 10 years on average, this means that the company gets $10 per year, per device to support all the functions of the smart device. Also, there is no explicit End of Life date, so in theory, people may expect the Nest to function for the next 40 years, without ever paying another penny to the company. This is just a giant liability and may actually make the company lose money in the long run.

This is why my fridge isn’t connected to the Internet.

On the Blockchain

In order to incentivize device makers to make them “smart”, there needs to be an income opportunity for supporting the devices as long as the device is in existence. While there is a possibility for charging a monthly service fee, I doubt anyone would sign up for a monthly subscription for their toaster. Also, we could potentially embed advertisement displays into every device, but most people would probably not see that as acceptable in the privacy of their home.

If each smart device was blockchain aware, instead of charging fees or showing ads, they could each mine bitcoins. The owner would essentially be burning a small extra amount of electricity in order to allow the device have greater capabilities. The user would also have the ability to turn this function off, and have the device lose its smart capabilities in order to save electricity.

The device could then use the fractions of bitcoins it earned to use services available over the Internet, and this would provide incentive for services to be hosted in the cloud to provide data or other functionality. When devices become blockchain aware, they go from a long-term liability to a long-term revenue opportunity for Internet of Things device manufacturers and service providers.

I am hopeful that one day my fridge supports the bitcoin blockchain and my wife stops yelling at me for eating all the food.

Bitcoin > Worthless

In recent months, we’ve started to see large amounts of venture capital being invested in Bitcoin companies, lots of mining equipment being added to the network, and a large growth in the number of wallets and users on the network.  Since people are putting real money into this new technology, it raises the question of how much is it really worth?

Until today, most of the discussion around how to value a bitcoin is based on comparing it to mature companies or assets.  While this is a good way to try and estimate the potential of a new startup entering an existing market, it has some flaws when trying value a technology that is creating its own virtual economy from scratch.  If Bitcoin survives as the leading platform in a crypto currency world, it will be used for so many different uses that we can’t even imagine.  It would be like trying to come up with the value of the Internet in the 1990s by comparing it to FedEx, since sending emails is like sending an overnight letter.

For example, take a look at Bank of America’s report that valued a bitcoin at $1,300. David Woo describes a scenario where Bitcoin gets a 10% market share for all Business to Consumer E-Commerce transactions, obtains a value component worth the market cap of Western Union, and also gets used as a store of value equaling the US American Eagle silver coin.  In this scenario, he adds these values up to a grand total of $15 billion, therefore valuing each bitcoin at $1,300.  Using this method has the benefit of being easily understood, however it does not necessarily seem scientific.


Who Cares?

More importantly, who actually cares what the value of a bitcoin is?  In my opinion, there are three types of people who should care.  First, we’re all too aware of the term “Bitcoin Speculators” used by the media.  These people are looking for an asset that will appreciate in price faster than the existing returns they can get today.  If there was a better model for predicting the value of a bitcoin, they could invest in bitcoins with more certainty and maybe throw off the label of “speculator”.

Second, there are the people who are investing into the Bitcoin eco-system.  This includes miners buying equipment that run the network and venture capitalists who are helping to build the companies that will make the network better in the future.  Currently, if you ask any forum or group whether you will “make money by mining” the answer is almost always a resounding “NO”.  The only explanation for the growth of mining must be that a certain group of people feels the rising value of bitcoins and the Bitcoin network will lead this to be a good investment today.  Additionally, the venture capitalists and entrepreneurs must think that the Bitcoin network will be worth a large amount of money in the future or they wouldn’t be willing to invest money and time to build these companies.  If there was a better method to predict the value of a bitcoin, then these people could more accurately calculate whether it makes sense to put money and time into it.

Finally, there are the normal people in the world who might want to use Bitcoin.  If they are concerned that it is just “Magic Internet Money” without a real value based on economics, it could prevent them from using it.  If a majority of the population thinks that a bitcoin has no real value, then it will prevent the network from gaining popularity and benefiting many people around the world.

What is the Value?

I have no delusions that my approach to valuing Bitcoin will be the end all be all.  It obviously has many flaws and estimates, but I hope that a fresh approach to looking at the Bitcoin network can bring some new ideas and discussion to the table.  Also, I have a very small personal holding in bitcoins, so I am obviously biased to want a higher price.  Please take the following as one person’s opinion and use your own estimates and rates that make sense to you.

If you were to see the following revenue chart for a high tech startup, what would you think about the future prospects of that company?


The chart above is actually showing the mining fees on the Bitcoin network.  Each time someone sends money across the network, they attach a very small fee to the transaction.  The miners on the network package all the transactions into the block chain, and get to keep this fee for doing the work.  Today, this is usually around 0.0002 BTC or roughly $0.15 per transaction.

If we look at the Bitcoin network as a whole, it can be thought of like a Distributed Autonomous Co-op.  When users send money across the network, they pay fees to the Co-op, which can be viewed as revenue.  Since there are no centralized costs for the Co-op, these revenues can be viewed as pure profit.  The Co-op then turns around and pays all earnings out to the workers who are actually the miners running the network.

In my valuation model, I value the Bitcoin network like a series of cash flows.  The earnings of the network are treated like the earnings of a company listed on a stock exchange.  If people are willing to pay a fee for using the Bitcoin, then inherently, they are placing a value on the network itself.  As the number of transactions and fees goes up, the value of the network itself must go up.  The value of these fees can then be projected into the future to come up with a present value of the network as a whole.

This is where it gets tricky though.  Since the network itself is so new and there are no previous technologies to compare it with, we must estimate the future growth rates of the network.  One possible way to do this could be to look at the adoption of the Internet and put Bitcoin on a similar trajectory.  First though, let’s take a look at the historical growth of transaction fees.  These fees are based on info published on  One caveat is that the dollar amounts are based on the current USD price of a bitcoin (at the time of writing the article), so in theory if historical prices were used, these growth rates could look much higher.

image003 image005 image007

With these charts, we see a clear trend of Month-over-Month, Quarter-over-Quarter, and Year-over-Year growth.  The growth rates can be calculated and projected into the future to predict how large it might be in 10 years.  The growth rate from 2012 to 2013 was approximately 3,000%.  However, if we used 3,000% year over year for 10 years, the numbers would be larger than imaginable.  For this valuation, we will round last years growth at 3,000% and assume that every year after now, the growth rate will be cut in half as adoption grows for 10 years.  For example, we will assume that the growth rate in 2014 will be 1,500%, 2015 will be 750%, 2016 will be 375%, etc.  After 10 years, we will also assume that adoption has peaked and growth will continue at 5% year after year.  The following chart shows projected mining fees:


For this projection, it shows the Bitcoin network generating around $18 billion in 2023.  To project the present value of these cash flows, we also must estimate a discount rate.  This is a crucial part of calculating any present value, and for this exercise I will choose a rate of 25%.  Of course, this value should be greater if you a see a higher risk for Bitcoin succeeding to become a global currency.  Admittedly, 25% is an arbitrary value on my part but was chosen in line with investing in emerging markets.  With the discount rate chosen, we can calculate the present value of the first 10 years of the cash flows to be approximately $14 billion.

Also, we must calculate the present value of the cash flows starting in 2024 once the network churns along at an annual rate of 5% growth.  To do this we can calculate a perpetuity starting in 2024 then discount it back to the present.  This leads to a present value for the perpetuity of approximately $3 billion.

If these two calculations are combined, we can value the entire network at approximately $17.5 billion. Since there will only be a total of 21 million bitcoins ever created, we can calculate that each bitcoin should be worth approximately $840 using this method.


I can guarantee with certainty the value of a bitcoin will not settle and stay at $840 in the future.  The choice of predicting the network growth rate and also a proper discount rate are inherently hard, and slight changes result in drastic differences in the outcome calculated.  Additionally, the future of fees is very uncertain, including changes to the Bitcoin network itself where fees for a transaction are calculated differently.  This could lead to dramatically lower fees on the network, although at the same time, a larger volume of transactions might actually increase it.

In writing this article, my hope was to show that there are other methods of trying to predict the value of the Bitcoin network, rather than trying to guess how big it might get by comparing it to existing companies. Most important though, it shows that Bitcoin has a value greater than $0 even if it can’t be precisely calculated.

Back in the Day

Back when I was about 12 years old, my Grandfather gave us our first computer for Christmas.  I was totally excited about it.  I could start it up, play some games, and even connect it the phone line and make it act like an answering machine.  It was great.

My First Computer

As time went by, I figured out how to use the phone line to connect to a friend’s computer and send files back and forth.  And after that I learned how to connect to a BBS and download shareware and games.  The funny thing about this though, is that I was the only one in my house who was playing with it in this manner.  Everyone else used it occasionally to type a letter or a school paper, but doing the cool stuff wasn’t easy or glamorous to do.

Eventually AOL came out and others started using it more frequently to look things up online, send an email, or join a chat session.  It was still a pain at that point since you needed to hog the phone line to use it.  Speeds increased and email became more popular, leading to even more every day use.

Today, my family members probably are connected to the internet more than they could even fathom back then.  Checking email, browsing websites, and shopping are an every day thing.

What reminded me of this time is how Bitcoin is being used today.  Only super techno-geeks are really into it, and the mainstream people haven’t found a use for it in their every day lives.  Many people are just confused about how it could possibly take off and be accepted in mainstream.  I don’t have that problem though, since I remember playing with computers before they were easy.

There are a lot of people saying Bitcoin is like the internet in 1995 and I guess I’m one of them.  It’s a new technology that has some serious promise to change the every day lives of almost everyone, but they are blind to that fact.  Many of them even think it’s a silly idea.

While I can’t say for certain that Bitcoin will be around in 10 years, I can say that there will be some sort of digital currency and that it will be used in ways we can’t even imagine.


Latest Project

Over Christmas, I worked on the first iteration of a site for calculating taxes for Bitcoin:

Right now, the talk is mostly around how hard it is to calculate Bitcoin taxes or how to evade taxes using Bitcoin, but I think that will go away very shortly.  Programmable money is going to change the landscape of taxes for the better.

Today, I have no idea how much taxes I’m going to owe for 2013 even though 2013 is over.  I’m going to have to wait until me (or and accountant) spends hours and hours going over pieces of paper, plugging numbers into forms, and figuring out if things are correct.  This is very inefficient.

In the future, I see a place where we know on Jan 1st what the tax liability is.  Imagine companies using anonymous (but public) Bitcoin addresses to post tax withholdings, insurance payments, 401k Payments, and the rest of the check… you could write a script that calculated taxes on demand for the previous year and could even project in real time what your taxes would be for the next year.

It’s pretty amazing to think about…

See my post on Reddit for more info about the website.

Why Bitcoin?

Right now, I’m basically at a point of almost obsession of Bitcoin.  I’m reading every single article, watching every single video, and even having weird dreams about it.

I only just started to understand why.  I’ve always wanted to do something special so that I don’t look back one day and wonder where my effort towards my job and free time were just feeding “the machine” and not making a difference.  I think I’ve realized that we’re on the cusp of something that could shape the future, and I actually have a chance to participate.  It is not being done behind closed doors or being done in someone’s basement, but it’s being done out in the open of the internet.

I’ve put a little bit of money into it, but I think I’m at the point of caring less about making money in the long term, rather than amazed at the possibilities that it will bring in the future.

I’ll be looking for ways to contribute, whether that be buying mining hardware or building software to make it easier to use…  I feel like a little kid being excited about going to Disney World.  That’s why Bitcoin.

Rails 4 CSRF Protection with Clients using APIs

I was recently trying to work on a new rails site and ran into a problem with CSRF protection.  In every post/put that is submitted in Rails, a CSRF check is performed to make sure the client submitting the request has a secret token.  This is for security to prevent nasty scripts/pages from sending malicious requests from your browser.

Anyways, when you make a request from some other client, like a Java app accessing a REST service, you will get errors by default, since you do not have the secret token.  If you read about this online, many people say to just turn off the check, or to disable it for JSON requests.  This is BAD from a security perspective.

Instead, rails 4 allows you to alter the behavior when the secret isn’t sent in your request.  By default it throws an exception, but you can change it to just set the session to NULL.  This will prevent any other scripts from using your authenticated session to do bad things, and just requires you to always authenticate from your 3rd party apps.

To enable this functionality, set the following in your Application Controller:

protect_from_forgery with: :null_session

After that, just make sure your client sends credentials to authenticate for every request.

Quick Way to Test XSLT Transformation

I am working on a project that has a lot of transformations of raw source XML files to a standard format. For this we ended up using XSLT, so I needed a quick way to test these transformations without having to spin up an IDE or embed a reference the source file or xsl file.

To do this on Windows I just downloaded a tool from Microsoft, called msxsl.exe.

To test it, just run a simple command line and pass it the source and stylesheet:

msxsl.exe source.xml stylesheet.xsl

This will output a the text of the transformation to the command window.  If instead you want to output it to a file, simply redirect the output to a filename, like so:

msxsl.exe source.xml stylesheet.xsl > output.xml

Easy stuff…

LIBSVM TUTORIAL PART 4 – Testing the Model

Part 1
Part 2
Part 3
Part 4

The whole purpose of using a Support Vector Machine is to be able to predict whether new instances of an object belong to a certain group.  This could be detecting whether documents are sensitive, stocks are a “buy”, or whether it will rain.  In our case, we are trying to determine whether emails are SPAM or not.  So to test this, we need to come up with more instances of emails.

For the first test, we will use a sample email:

James, can you pick up the dog?

To translate this to the proper input format to test, we once again need to take each word and map them to our previous vector of words:








Any words with ??? mean that we didn’t see those words during the training phase, so we will essentially ignore them for now.  So to convert that new email to the proper input format, it would look like:

0 16:1 17:1 26:1 29:1

Since we know that this email should not be classified as SPAM, we start it off with a “0”, then include a value for any words we already know about.  We will then save this text in a file named “sample.1.txt” and run the following command line to test it:

c:\Program Files\LibSVM\windows>svm-predict.exe sample.1.txt spam.train.model sample.1.predicted.txt
Accuracy = 100% (1/1) (classification)

The output on the command line tells us that the algorithm predicted the email was HAM and not SPAM since it had an accuracy of 100%.  Also, if you open up the sample.1.predicted.txt, you will see a single entry with “0” indicating that it predicted the first line in the input file belonged to the class “0” or HAM.

Now lets, add some new sample emails to test:

Cheap viagra by mail!

James, you need viagra.

The first email is obviously a SPAM type email, but the second one is a little more interesting.  If that was sent from a stranger, then it might be SPAM, however if my wife sent it, it may not 🙂

So let’s add them to our input file along with the first one, it would look like:

0 16:1 17:1 26:1 29:1
1 2:1 3:1 8:1 9:1
0 2:1 16:1 17:1

And then, lets run the algorithm to see what it thinks:

c:\Program Files\LibSVM\windows>svm-predict.exe sample.1.txt spam.train.model sample.1.predicted.txt
Accuracy = 100% (3/3) (classification)

As you can see, the algorithm did very well.  It thought that the first email was HAM, the second was SPAM, and the third was HAM.  The output file shows 0, 1, 0.

While this was a trivial and made up example, I hope that I met the overall goal, which was to show how to use LIBSVM for classification problems.  By building an input training set, generating a predictive model, and testing it against inputs we showed that Support Vector Machines can be powerful and easy to use tools in Machine Learning.

LIBSVM TUTORIAL PART 3 – Training the Model

Part 1
Part 2
Part 3
Part 4

Now that we have data to feed into the SVM as a training set, there is a couple more tweaks that need to be made.  First, we need to set the training set to have numeric values for the different classes of data ( 1 = SPAM and 0 = HAM) and also we need to make sure the inputs are in ascending order.  So the final input training file should look like:

1 1:1 2:1 3:1
1 3:1 4:1 5:1 6:1 7:1
1 1:1 4:1 8:1 9:1
1 1:1 10:1 11:1 12:1
1 1:1 2:1 4:1 7:1 10:1 12:1 13:1 14:1
0 15:1 16:1 17:1 18:1 19:1
0 16:1 20:1 21:1 22:1 23:1 24:1 25:1 26:1
0 16:1 27:1 28:1 29:1 30:1 31:1
0 22:1 23:1 24:1 26:1 32:1 33:1 34:1
0 16:1 18:1 22:1 28:1 35:1 36:1 37:1 38:1 39:1

As you can see each line represents one of our sample emails.  If the line starts with 1 then it represents a SPAM email and if the line starts with 0 then it represents a HAM email (not spam).  Then, each number:number sequence represents a word found in the email.  For example, any line with “1:1” means that the word “buy” was found in that email.

Now that we have the input file, save it as a file named “Spam.train”.

To create the predictive model, run the following command line (on Windows):

C:\Program Files\LibSVM\windows>svm-train.exe spam.train

optimization finished, #iter = 5
nu = 1.000000
obj = -7.583904, rho = 0.229345
nSV = 10, nBSV = 10
Total nSV = 10

After running this command, there will now be a “Spam.train.model” file that will be used as input when classifying any new emails.  We will see that in the next part.