Class: Sibit::FirstOf
- Inherits:
-
Object
- Object
- Sibit::FirstOf
- Defined in:
- lib/sibit/firstof.rb
Overview
First 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, verbose: false) ⇒ FirstOf
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
Instance Method Details
#balance(address) ⇒ Object
Gets the balance of the address, in satoshi.
50 51 52 53 54 |
# File 'lib/sibit/firstof.rb', line 50 def balance(address) first_of('balance') do |api| api.balance(address) end end |
#block(hash) ⇒ Object
This method should fetch a block and return as a hash.
96 97 98 99 100 |
# File 'lib/sibit/firstof.rb', line 96 def block(hash) first_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 }
72 73 74 |
# File 'lib/sibit/firstof.rb', line 72 def fees first_of('fees', &:fees) end |
#height(hash) ⇒ Object
Get the height of the block.
57 58 59 60 61 |
# File 'lib/sibit/firstof.rb', line 57 def height(hash) first_of('height') do |api| api.height(hash) end end |
#latest ⇒ Object
Latest block hash.
84 85 86 |
# File 'lib/sibit/firstof.rb', line 84 def latest first_of('latest', &:latest) end |
#next_of(hash) ⇒ Object
Get the hash of the next block.
64 65 66 67 68 |
# File 'lib/sibit/firstof.rb', line 64 def next_of(hash) first_of('next_of') do |api| api.next_of(hash) end end |
#price(currency = 'USD') ⇒ Object
Current price of BTC in USD (float returned).
43 44 45 46 47 |
# File 'lib/sibit/firstof.rb', line 43 def price(currency = 'USD') first_of('price') do |api| api.price(currency) end end |
#push(hex) ⇒ Object
Push this transaction (in hex format) to the network.
89 90 91 92 93 |
# File 'lib/sibit/firstof.rb', line 89 def push(hex) first_of('push') do |api| api.push(hex) end end |
#utxos(keys) ⇒ Object
Fetch all unspent outputs per address.
77 78 79 80 81 |
# File 'lib/sibit/firstof.rb', line 77 def utxos(keys) first_of('utxos') do |api| api.utxos(keys) end end |