merge latest code of history.cpp to balance.cpp

this enables balance of multiple addresses, as well as json
format response as requested on:
https://github.com/spesmilo/sx/issues/34

$ sx balance 1EXoDusjGwvnjZUyKkxZ4UHEf77z6A5S4P 182osbPxCo88oaSX4ReJwUr9uAcchmJVaL
Address: 1EXoDusjGwvnjZUyKkxZ4UHEf77z6A5S4P
  Paid balance:    238109137989
  Pending balance: 238109143989
  Total received:  614505313318

Address: 182osbPxCo88oaSX4ReJwUr9uAcchmJVaL
  Paid balance:    103383700
  Pending balance: 103383700
  Total received:  124945670

$ sx balance -j 1EXoDusjGwvnjZUyKkxZ4UHEf77z6A5S4P 182osbPxCo88oaSX4ReJwUr9uAcchmJVaL
[
{
  "address": "1EXoDusjGwvnjZUyKkxZ4UHEf77z6A5S4P",
  "paid":  "238109137989",
  "pending":  "238109143989",
  "received":  "614505313318"
},
{
  "address": "182osbPxCo88oaSX4ReJwUr9uAcchmJVaL",
  "paid":  "103383700",
  "pending":  "103383700",
  "received":  "124945670"
}
]

history.cpp and balance.cpp files are almost identical, and they should
be merged to a single file to avoid code duplication
also functions json_history_fetched and history_fetched should be merged