lib/sibit/btc.rb in sibit-0.19.2 vs lib/sibit/btc.rb in sibit-0.19.3

- old
+ new

@@ -56,10 +56,15 @@ json = Sibit::Json.new(http: @http, log: @log).get(uri) if json['err_no'] == 1 @log.info("The balance of #{address} is zero (not found)") return 0 end - txns = json['data']['list'] + data = json['data'] + if data.nil? + @log.info("The balance of #{address} is probably zero (not found)") + return 0 + end + txns = data['list'] balance = txns.map { |tx| tx['value'] }.inject(&:+) || 0 @log.info("The balance of #{address} is #{balance}, total txns: #{txns.count}") balance end