Class: Nano::Wallet

Inherits:
Object
  • Object
show all
Defined in:
lib/nano/wallet.rb,
lib/nano/wallet/version.rb

Constant Summary collapse

VERSION =
"0.2.0"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seed) ⇒ Wallet

Returns a new instance of Wallet.



13
14
15
16
# File 'lib/nano/wallet.rb', line 13

def initialize(seed)
  @seed = seed
  @accounts = []
end

Instance Attribute Details

#accountsObject (readonly)

Returns the value of attribute accounts.



11
12
13
# File 'lib/nano/wallet.rb', line 11

def accounts
  @accounts
end

#seedObject (readonly)

Returns the value of attribute seed.



11
12
13
# File 'lib/nano/wallet.rb', line 11

def seed
  @seed
end

Class Method Details

.with_random_seedObject



7
8
9
# File 'lib/nano/wallet.rb', line 7

def self.with_random_seed
  self.new(SecureRandom.hex(32))
end

Instance Method Details

#account_at_index(index) ⇒ Object



18
19
20
# File 'lib/nano/wallet.rb', line 18

def (index)
  Nano::Account.new(@seed, index)
end

#add_account!Object



26
27
28
29
30
# File 'lib/nano/wallet.rb', line 26

def add_account!
   = Nano::Account.new(@seed, @accounts.size)
  @accounts << 
  
end

#add_accounts!(count) ⇒ Object



22
23
24
# File 'lib/nano/wallet.rb', line 22

def add_accounts!(count)
  count.times { add_account! }
end