Class: Sibit::FirstOf

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

Overview

First of API.

Instance Method Summary collapse

Constructor Details

#initialize(list, log: Loog::NULL, verbose: false) ⇒ FirstOf

Constructor.



19
20
21
22
23
# File 'lib/sibit/firstof.rb', line 19

def initialize(list, log: Loog::NULL, verbose: false)
  @list = list
  @log = log
  @verbose = verbose
end

Instance Method Details

#balance(address) ⇒ Object

Gets the balance of the address, in satoshi.



33
34
35
36
37
# File 'lib/sibit/firstof.rb', line 33

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.



79
80
81
82
83
# File 'lib/sibit/firstof.rb', line 79

def block(hash)
  first_of('block') do |api|
    api.block(hash)
  end
end

#feesObject

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



55
56
57
# File 'lib/sibit/firstof.rb', line 55

def fees
  first_of('fees', &:fees)
end

#height(hash) ⇒ Object

Get the height of the block.



40
41
42
43
44
# File 'lib/sibit/firstof.rb', line 40

def height(hash)
  first_of('height') do |api|
    api.height(hash)
  end
end

#latestObject

Latest block hash.



67
68
69
# File 'lib/sibit/firstof.rb', line 67

def latest
  first_of('latest', &:latest)
end

#next_of(hash) ⇒ Object

Get the hash of the next block.



47
48
49
50
51
# File 'lib/sibit/firstof.rb', line 47

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).



26
27
28
29
30
# File 'lib/sibit/firstof.rb', line 26

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.



72
73
74
75
76
# File 'lib/sibit/firstof.rb', line 72

def push(hex)
  first_of('push') do |api|
    api.push(hex)
  end
end

#utxos(keys) ⇒ Object

Fetch all unspent outputs per address.



60
61
62
63
64
# File 'lib/sibit/firstof.rb', line 60

def utxos(keys)
  first_of('utxos') do |api|
    api.utxos(keys)
  end
end