Class: Sibit::BestOf
- Inherits:
-
Object
- Object
- Sibit::BestOf
- Defined in:
- lib/sibit/bestof.rb
Overview
Best of API.
Instance Method Summary collapse
-
#balance(address) ⇒ Object
Gets the balance of the address, in satoshi.
-
#block(hash) ⇒ Object
This method should fetch a block and return as a hash.
-
#fees ⇒ Object
Get recommended fees, in satoshi per byte.
-
#height(hash) ⇒ Object
Get the height of the block.
-
#initialize(list, log: Sibit::Log.new) ⇒ BestOf
constructor
Constructor.
-
#latest ⇒ Object
Latest block hash.
-
#next_of(hash) ⇒ Object
Get the hash of the next block.
-
#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(keys) ⇒ Object
Fetch all unspent outputs per address.
Constructor Details
#initialize(list, log: Sibit::Log.new) ⇒ BestOf
Constructor.
35 36 37 38 |
# File 'lib/sibit/bestof.rb', line 35 def initialize(list, log: Sibit::Log.new) @list = list @log = log end |
Instance Method Details
#balance(address) ⇒ Object
Gets the balance of the address, in satoshi.
48 49 50 51 52 |
# File 'lib/sibit/bestof.rb', line 48 def balance(address) best_of('balance') do |api| api.balance(address) end end |
#block(hash) ⇒ Object
This method should fetch a block and return as a hash.
94 95 96 97 98 |
# File 'lib/sibit/bestof.rb', line 94 def block(hash) best_of('block') do |api| api.block(hash) end end |
#fees ⇒ Object
Get recommended fees, in satoshi per byte. The method returns a hash: { S: 12, M: 45, L: 100, XL: 200 }
70 71 72 |
# File 'lib/sibit/bestof.rb', line 70 def fees best_of('fees', &:fees) end |
#height(hash) ⇒ Object
Get the height of the block.
55 56 57 58 59 |
# File 'lib/sibit/bestof.rb', line 55 def height(hash) best_of('height') do |api| api.height(hash) end end |
#latest ⇒ Object
Latest block hash.
82 83 84 |
# File 'lib/sibit/bestof.rb', line 82 def latest best_of('latest', &:latest) end |
#next_of(hash) ⇒ Object
Get the hash of the next block.
62 63 64 65 66 |
# File 'lib/sibit/bestof.rb', line 62 def next_of(hash) best_of('next_of') do |api| api.next_of(hash) end end |
#price(currency = 'USD') ⇒ Object
Current price of BTC in USD (float returned).
41 42 43 44 45 |
# File 'lib/sibit/bestof.rb', line 41 def price(currency = 'USD') best_of('price') do |api| api.price(currency) end end |
#push(hex) ⇒ Object
Push this transaction (in hex format) to the network.
87 88 89 90 91 |
# File 'lib/sibit/bestof.rb', line 87 def push(hex) best_of('push') do |api| api.push(hex) end end |
#utxos(keys) ⇒ Object
Fetch all unspent outputs per address.
75 76 77 78 79 |
# File 'lib/sibit/bestof.rb', line 75 def utxos(keys) best_of('utxos') do |api| api.utxos(keys) end end |