Class: Sibit::Cex
- Inherits:
-
Object
- Object
- Sibit::Cex
- Defined in:
- lib/sibit/cex.rb
Overview
Cex.io API.
- Author
Yegor Bugayenko (yegor256@gmail.com)
- Copyright
Copyright (c) 2019-2026 Yegor Bugayenko
- License
MIT
Instance Method Summary collapse
-
#balance(_address) ⇒ Object
Gets the balance of the address, in satoshi.
-
#block(_hash) ⇒ Object
This method should fetch a Blockchain block and return as a hash.
-
#fees ⇒ Object
Get recommended fees, in satoshi per byte.
-
#height(_hash) ⇒ Object
The height of the block.
-
#initialize(log: Loog::NULL, http: Sibit::Http.new) ⇒ Cex
constructor
Constructor.
-
#latest ⇒ Object
Gets the hash of the latest block.
-
#next_of(_hash) ⇒ Object
Get hash of the block after this one.
-
#price(currency = 'USD') ⇒ Object
Current price of BTC in USD (float returned).
-
#push(_hex) ⇒ Object
Push this transaction (in hex format) to the network.
-
#utxos(_sources) ⇒ Object
Fetch all unspent outputs per address.
Constructor Details
Instance Method Details
#balance(_address) ⇒ Object
Gets the balance of the address, in satoshi.
43 44 45 |
# File 'lib/sibit/cex.rb', line 43 def balance(_address) raise(Sibit::NotSupportedError, 'Cex.io doesn\'t implement balance()') end |
#block(_hash) ⇒ Object
This method should fetch a Blockchain block and return as a hash.
73 74 75 |
# File 'lib/sibit/cex.rb', line 73 def block(_hash) raise(Sibit::NotSupportedError, 'Cex.io doesn\'t implement block()') end |
#fees ⇒ Object
Get recommended fees, in satoshi per byte.
53 54 55 |
# File 'lib/sibit/cex.rb', line 53 def fees raise(Sibit::NotSupportedError, 'Cex.io doesn\'t implement fees()') end |
#height(_hash) ⇒ Object
The height of the block.
48 49 50 |
# File 'lib/sibit/cex.rb', line 48 def height(_hash) raise(Sibit::NotSupportedError, 'Cex.io doesn\'t implement height()') end |
#latest ⇒ Object
Gets the hash of the latest block.
58 59 60 |
# File 'lib/sibit/cex.rb', line 58 def latest raise(Sibit::NotSupportedError, 'Cex.io doesn\'t implement latest()') end |
#next_of(_hash) ⇒ Object
Get hash of the block after this one.
38 39 40 |
# File 'lib/sibit/cex.rb', line 38 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).
27 28 29 30 31 32 33 34 35 |
# File 'lib/sibit/cex.rb', line 27 def price(currency = 'USD') p = Float( Sibit::Json.new(http: @http, log: @log).get( Iri.new('https://cex.io/api/last_price/BTC').append(currency) )['lprice'] ) @log.debug("The price of BTC is #{p} #{currency}") p end |
#push(_hex) ⇒ Object
Push this transaction (in hex format) to the network.
68 69 70 |
# File 'lib/sibit/cex.rb', line 68 def push(_hex) raise(Sibit::NotSupportedError, 'Cex.io doesn\'t implement push()') end |
#utxos(_sources) ⇒ Object
Fetch all unspent outputs per address.
63 64 65 |
# File 'lib/sibit/cex.rb', line 63 def utxos(_sources) raise(Sibit::NotSupportedError, 'Cex.io doesn\'t implement utxos()') end |