Class: Bitcoin2Graphdb::Bitcoin::BlockchainProvider
- Inherits:
-
Object
- Object
- Bitcoin2Graphdb::Bitcoin::BlockchainProvider
- Defined in:
- lib/bitcoin2graphdb/bitcoin/blockchain_provider.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Instance Method Summary collapse
- #block(block_hash) ⇒ Object
- #block_hash(block_height) ⇒ Object
-
#initialize(config) ⇒ BlockchainProvider
constructor
A new instance of BlockchainProvider.
- #tx(txid) ⇒ Object
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 |
#tx(txid) ⇒ Object
34 35 36 |
# File 'lib/bitcoin2graphdb/bitcoin/blockchain_provider.rb', line 34 def tx(txid) api.provider.getrawtransaction(txid, 1) end |