| Conditions | 2 | 
| Total Lines | 24 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| Bugs | 0 | Features | 1 | 
| 1 | def get_balance  | 
            ||
| 2 | # This method is used to get the balance of the faucet.  | 
            ||
| 3 | # These values are defined in config.json.  | 
            ||
| 4 | wallet_pass = settings.wallet_pass  | 
            ||
| 5 | wallet_id = settings.wallet_id  | 
            ||
| 6 | |||
| 7 |   url = "http://blockchain.info/merchant/#{wallet_id}/balance" | 
            ||
| 8 |   request_object = { :password => wallet_pass } | 
            ||
| 9 | |||
| 10 | # This is in a begin...rescue...end block because if Blockchain.info  | 
            ||
| 11 | # is down, getting the balance will fail.  | 
            ||
| 12 | begin  | 
            ||
| 13 | body = Nestful.get(url, :params => request_object)  | 
            ||
| 14 | rescue  | 
            ||
| 15 | return "ERROR"  | 
            ||
| 16 | end  | 
            ||
| 17 | |||
| 18 | parsed = JSON.parse body  | 
            ||
| 19 | |||
| 20 | # The balance is given in Satoshi, so we convert it into fractional  | 
            ||
| 21 | # bitcoins.  | 
            ||
| 22 | amount = parsed["balance"].to_i * 0.000_000_01  | 
            ||
| 23 | return amount  | 
            ||
| 24 | end  | 
            ||
| 25 | |||
| 26 |