var bitcoin = require('bitcoin')

module.exports = window.bitcoin = Bitcoin

function Bitcoin(opts) {
  if (!(this instanceof Bitcoin))
    return new Bitcoin(opts)

  this.opts = opts
  console.log('opts ' + JSON.stringify(opts))
  this.client = new bitcoin.Client({
    host: opts.host || '127.0.0.1'
  , port: opts.port || 8999
  , user: opts.rpcuser
  , pass: opts.rpcpassword
  , timeout: 1000 * 60
  })
}

Bitcoin.prototype.getInfo = function getInfo(cb) {
  this.client.getInfo(cb)
}

Bitcoin.prototype.getBalance = function getBalance(cb) {
  this.client.getBalance('*', 0, cb)
}

Bitcoin.prototype.getTransactions = function getTransactions(cb) {
  this.client.listTransactions('*', 1000, cb)
}

@@ -689,16 +689,376 @@
 *', 1000, cb)%0A%7D%0A
+%0ABitcoin.prototype.getAccounts = function getAccounts(cb) %7B%0A  this.client.listAddressGroupings(function(err, out) %7B%0A    if (err) return cb(err)%0A    return cb(null, parseAccounts(out))%0A  %7D)%0A%7D%0A%0Afunction parseAccounts(data) %7B%0A  return data%5B0%5D.map(function(item) %7B%0A    return %7B%0A      address: item%5B0%5D%0A    , balance: item%5B1%5D%0A    , label: item%5B2%5D %7C%7C ''%0A    %7D%0A  %7D)%0A%7D%0A

Add ability to fetch accounts