Class: Sibit::Cex

Inherits:
Object
  • Object
show all
Defined in:
lib/sibit/cex.rb

Overview

Btc.com API.

Instance Method Summary collapse

Constructor Details

#initialize(log: Sibit::Log.new, http: Sibit::Http.new, dry: false) ⇒ Cex

Constructor.



39
40
41
42
43
# File 'lib/sibit/cex.rb', line 39

def initialize(log: Sibit::Log.new, http: Sibit::Http.new, dry: false)
  @http = http
  @log = log
  @dry = dry
end

Instance Method Details

#balance(_address) ⇒ Object

Gets the balance of the address, in satoshi.



61
62
63
# File 'lib/sibit/cex.rb', line 61

def balance(_address)
  raise Sibit::NotSupportedError, 'Cex.io doesn\'t implement balance()'
end

#block(_hash) ⇒ Object



90
91
92
# File 'lib/sibit/cex.rb', line 90

def block(_hash)
  raise Sibit::NotSupportedError, 'Cex.io doesn\'t implement block()'
end

#feesObject

Get recommended fees, in satoshi per byte.



71
72
73
# File 'lib/sibit/cex.rb', line 71

def fees
  raise Sibit::NotSupportedError, 'Cex.io doesn\'t implement fees()'
end

#height(_hash) ⇒ Object

The height of the block.



66
67
68
# File 'lib/sibit/cex.rb', line 66

def height(_hash)
  raise Sibit::NotSupportedError, 'Cex.io doesn\'t implement height()'
end

#latestObject

Gets the hash of the latest block.



76
77
78
# File 'lib/sibit/cex.rb', line 76

def latest
  raise Sibit::NotSupportedError, 'Cex.io doesn\'t implement latest()'
end

#next_of(_hash) ⇒ Object

Get hash of the block after this one.



56
57
58
# File 'lib/sibit/cex.rb', line 56

def next_of(_hash)
  raise Sibit::NotSupportedError, 'Cex.io API doesn\'t provide next_of()'
end

#price(currency = 'USD') ⇒ Object

Current price of BTC in USD (float returned).



46
47
48
49
50
51
52
53
# File 'lib/sibit/cex.rb', line 46

def price(currency = 'USD')
  json = Sibit::Json.new(http: @http, log: @log).get(
    Iri.new('https://cex.io/api/last_price/BTC').append(currency)
  )
  p = json['lprice'].to_f
  @log.info("The price of BTC is #{p} #{currency}")
  p
end

#push(_hex) ⇒ Object

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



86
87
88
# File 'lib/sibit/cex.rb', line 86

def push(_hex)
  raise Sibit::NotSupportedError, 'Cex.io doesn\'t implement push()'
end

#utxos(_sources) ⇒ Object

Fetch all unspent outputs per address.



81
82
83
# File 'lib/sibit/cex.rb', line 81

def utxos(_sources)
  raise Sibit::NotSupportedError, 'Cex.io doesn\'t implement utxos()'
end