Class: OnChain

Inherits:
Object
  • Object
show all
Defined in:
lib/onchain/block_chain.rb

Overview

We support a number of blockchain API providers, if one goes down we automatically switch over to another.

Each provider has to support the following methods

get_balance(address) get_all_balances([]) send_tx(tx_hex) get_transactions(address)

Defined Under Namespace

Classes: BlockChain, Transaction

Class Method Summary collapse

Class Method Details

.bin_to_hex(bin) ⇒ Object



18
19
20
# File 'lib/onchain/block_chain.rb', line 18

def bin_to_hex(bin)
  return bin.unpack("H*")[0]
end

.hex_to_bin(hex) ⇒ Object



22
23
24
# File 'lib/onchain/block_chain.rb', line 22

def hex_to_bin(hex)
  return hex.scan(/../).map { |x| x.hex }.pack('c*')
end