Class: ItsyBtc::Commands::InitCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/itsy-btc/commands/init_command.rb

Instance Attribute Summary

Attributes inherited from Command

#wallet

Instance Method Summary collapse

Methods inherited from Command

args, name, summary

Instance Method Details

#runObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/itsy-btc/commands/init_command.rb', line 7

def run
  path = ItsyBtc::DEFAULT_WALLET_FILENAME
  if File.exists?(path)
    puts "A '#{path}' file already exists in this directory!"
  else
    passphrase1 = ask("Choose wallet passphrase: ") { |q| q.echo = false }
    passphrase2 = ask("Verify your passphrase: ") { |q| q.echo = false }
    if passphrase1 != passphrase2
      puts "You typed different passphrases! Aborting..."
    else
      Wallet.new(path).create(passphrase1)
      puts "'#{path}' created."
    end
  end
end