class Zold::Prefixes

Payment prefixes

Public Class Methods

new(wallet) click to toggle source
# File lib/zold/prefixes.rb, line 33
def initialize(wallet)
  @wallet = wallet
end

Public Instance Methods

create(length = 8) click to toggle source
# File lib/zold/prefixes.rb, line 37
def create(length = 8)
  raise "Length #{length} is too small" if length < 8
  raise "Length #{length} is too big" if length > 32
  key = @wallet.key.to_pub
  prefix = ''
  rnd = Random.new
  until prefix =~ /^[a-zA-Z0-9]+$/
    start = rnd.rand(key.length - length)
    prefix = key[start..(start + length - 1)]
  end
  prefix
end