class Sibit::Earn

Blockchain.info API.

Public Class Methods

new(log: Sibit::Log.new, http: Sibit::Http.new, dry: false) click to toggle source

Constructor.

# File lib/sibit/earn.rb, line 40
def initialize(log: Sibit::Log.new, http: Sibit::Http.new, dry: false)
  @http = http
  @log = log
  @dry = dry
end

Public Instance Methods

balance(_address) click to toggle source

Gets the balance of the address, in satoshi.

# File lib/sibit/earn.rb, line 52
def balance(_address)
  raise Sibit::NotSupportedError, 'balance() doesn\'t work here'
end
block(_hash) click to toggle source

This method should fetch a Blockchain block and return as a hash.

# File lib/sibit/earn.rb, line 98
def block(_hash)
  raise Sibit::NotSupportedError, 'block() doesn\'t work here'
end
fees() click to toggle source

Get recommended fees, in satoshi per byte. The method returns a hash: { S: 12, M: 45, L: 100, XL: 200 }

# File lib/sibit/earn.rb, line 68
    def fees
      json = Sibit::Json.new(http: @http, log: @log).get(
        Iri.new('https://bitcoinfees.earn.com/api/v1/fees/recommended')
      )
      @log.info("Current recommended Bitcoin fees: \
#{json['hourFee']}/#{json['halfHourFee']}/#{json['fastestFee']} sat/byte")
      {
        S: json['hourFee'] / 3,
        M: json['hourFee'],
        L: json['halfHourFee'],
        XL: json['fastestFee']
      }
    end
height(_hash) click to toggle source

The height of the block.

# File lib/sibit/earn.rb, line 62
def height(_hash)
  raise Sibit::NotSupportedError, 'Earn API doesn\'t provide height()'
end
latest() click to toggle source

Gets the hash of the latest block.

# File lib/sibit/earn.rb, line 93
def latest
  raise Sibit::NotSupportedError, 'latest() doesn\'t work here'
end
next_of(_hash) click to toggle source

Get hash of the block after this one.

# File lib/sibit/earn.rb, line 57
def next_of(_hash)
  raise Sibit::NotSupportedError, 'Earn.com API doesn\'t provide next_of()'
end
price(_currency) click to toggle source

Current price of BTC in USD (float returned).

# File lib/sibit/earn.rb, line 47
def price(_currency)
  raise Sibit::NotSupportedError, 'price() doesn\'t work here'
end
push(_hex) click to toggle source

Push this transaction (in hex format) to the network.

# File lib/sibit/earn.rb, line 88
def push(_hex)
  raise Sibit::NotSupportedError, 'Not implemented yet'
end
utxos(_sources) click to toggle source

Fetch all unspent outputs per address.

# File lib/sibit/earn.rb, line 83
def utxos(_sources)
  raise Sibit::NotSupportedError, 'Not implemented yet'
end