Class: Bitcoin2Graphdb::Bitcoin::BlockchainProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/bitcoin2graphdb/bitcoin/blockchain_provider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ BlockchainProvider

Returns a new instance of BlockchainProvider.



16
17
18
19
20
21
22
23
24
# File 'lib/bitcoin2graphdb/bitcoin/blockchain_provider.rb', line 16

def initialize(config)
  @api = OpenAssets::Api.new(config)
  if @api.is_testnet?
    ::Bitcoin.network = :testnet3
  else
    ::Bitcoin.network = :bitcoin
  end
  @api
end

Instance Attribute Details

#api ⇒ Object (readonly)

Returns the value of attribute api.



14
15
16
# File 'lib/bitcoin2graphdb/bitcoin/blockchain_provider.rb', line 14

def api
  @api
end

Instance Method Details

#block(block_hash) ⇒ Object



26
27
28
# File 'lib/bitcoin2graphdb/bitcoin/blockchain_provider.rb', line 26

def block(block_hash)
  api.provider.getblock(block_hash)
end

#block_hash(block_height) ⇒ Object



30
31
32
# File 'lib/bitcoin2graphdb/bitcoin/blockchain_provider.rb', line 30

def block_hash(block_height)
  api.provider.getblockhash(block_height)
end

#oa_outputs(txid) ⇒ Object



38
39
40
# File 'lib/bitcoin2graphdb/bitcoin/blockchain_provider.rb', line 38

def oa_outputs(txid)
  api.get_outputs_from_txid(txid, true)
end

#tx(txid) ⇒ Object



34
35
36
# File 'lib/bitcoin2graphdb/bitcoin/blockchain_provider.rb', line 34

def tx(txid)
  api.provider.getrawtransaction(txid, 1)
end