class Multichain::CLI

Public Instance Methods

dehexify(hex) click to toggle source
# File lib/multichain/cli.rb, line 18
def dehexify hex
  puts Encoder.dehexify hex
end
hexify(url) click to toggle source
# File lib/multichain/cli.rb, line 12
def hexify url
  puts Encoder.hexify url
end
send_url(recipient, url) click to toggle source
# File lib/multichain/cli.rb, line 40
def send_url recipient, url
  data = Client.new.send_url recipient, url
  out = "You sent '#{url}' to '#{recipient}'\n"
  out << "\n"
  out << "The transaction id is\n"
  out << "  #{data[:id]}\n"
  out << "\n"
  out << "The URL\n"
  out << "  #{url}\n"
  out << "hashed to\n"
  out << "  #{data[:hash]}\n"
  out << "at\n"
  out << "  #{Time.at(data[:timestamp].to_i).to_datetime}\n"
  out << "\n"
  out << "Verify the hash with\n"
  out << "  multichain verify #{data[:hex]}\n"

  puts out
end
verify(hex) click to toggle source
# File lib/multichain/cli.rb, line 24
def verify hex
  url = Encoder.extract(Encoder.dehexify(hex))[:url]
  v = Encoder.verify hex

  case v
    when true
      puts "The URL '#{url}' is verified"
      exit 0 unless ENV['TEST']

    when false
      puts "The URL '#{url}' is not verified"
      exit 1 unless ENV['TEST']
  end
end
version() click to toggle source
# File lib/multichain/cli.rb, line 6
def version
  puts "multichain version #{VERSION}"
end