Sha256: 712240c15ac9c4a96909c211a1985b84e28b34d95621e665578bf1c488d5db54

Contents?: true

Size: 595 Bytes

Versions: 24

Compression:

Stored size: 595 Bytes

Contents

module BTC

  # Transaction ID <-> Transaction Hash conversion
  # Block ID <-> Block Hash conversion

  # Converts string transaction or block ID into binary hash.
  def self.hash_from_id(identifier)
    return nil if !identifier # so we can convert optional ID into optional hash without extra headache
    BTC.from_hex(identifier).reverse
  end

  # Converts binary hash to hex identifier (as a big-endian 256-bit integer).
  def self.id_from_hash(hash)
    return nil if !hash  # so we can convert optional hash into optional ID without extra headache
    BTC.to_hex(hash.reverse)
  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
btcruby-1.8 lib/btcruby/hash_id.rb
btcruby-1.7 lib/btcruby/hash_id.rb
btcruby-1.6 lib/btcruby/hash_id.rb
btcruby-1.5.1 lib/btcruby/hash_id.rb
btcruby-1.5 lib/btcruby/hash_id.rb
btcruby-1.4 lib/btcruby/hash_id.rb
btcruby-1.3 lib/btcruby/hash_id.rb
btcruby-1.2.2 lib/btcruby/hash_id.rb
btcruby-1.2.1 lib/btcruby/hash_id.rb
btcruby-1.2 lib/btcruby/hash_id.rb
btcruby-1.1.6 lib/btcruby/hash_id.rb
btcruby-1.1.5 lib/btcruby/hash_id.rb
btcruby-1.1.4 lib/btcruby/hash_id.rb
btcruby-1.1.3 lib/btcruby/hash_id.rb
btcruby-1.1.2 lib/btcruby/hash_id.rb
btcruby-1.1.1 lib/btcruby/hash_id.rb
btcruby-1.1 lib/btcruby/hash_id.rb
btcruby-1.0.9 lib/btcruby/hash_id.rb
btcruby-1.0.8 lib/btcruby/hash_id.rb
btcruby-1.0.7 lib/btcruby/hash_id.rb