Sha256: 6572888ee19faf6a41ca944c8bf238518c88aeb97edcd451c88ea77bc55e760f

Contents?: true

Size: 640 Bytes

Versions: 1

Compression:

Stored size: 640 Bytes

Contents

# frozen_string_literal: true

module OpenAssets
  module Util
    class << self
      OA_VERSION_BYTE = '17' # 0x23
      OA_VERSION_BYTE_TESTNET = '73' # 0x115

      def script_to_asset_id(script)
        hash_to_asset_id(Tapyrus.hash160(script))
      end

      private

      def hash_to_asset_id(hash)
        hash = oa_version_byte + hash
        Tapyrus::Base58.encode(hash + Tapyrus.calc_checksum(hash))
      end

      def oa_version_byte
        case Tapyrus.chain_params.network
        when 'mainnet' then OA_VERSION_BYTE
        when 'testnet', 'regtest' then OA_VERSION_BYTE_TESTNET
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tapyrus-0.1.0 lib/openassets/util.rb