lib/sibit/btc.rb in sibit-0.16.1 vs lib/sibit/btc.rb in sibit-0.17.0
- old
+ new
@@ -61,9 +61,19 @@
balance = txns.map { |tx| tx['value'] }.inject(&:+) || 0
@log.info("The balance of #{address} is #{balance}, total txns: #{txns.count}")
balance
end
+ # The height of the block.
+ def height(hash)
+ json = Sibit::Json.new(http: @http, log: @log).get(
+ URI("https://chain.api.btc.com/v3/block/#{hash}")
+ )
+ h = json['data']['height']
+ @log.info("The height of #{hash} is #{h}")
+ h
+ end
+
# Get recommended fees, in satoshi per byte.
def fees
raise Sibit::Error, 'Btc.com doesn\'t provide recommended fees'
end