Class: Nano::Wallet
- Inherits:
-
Object
- Object
- Nano::Wallet
- Defined in:
- lib/nano/wallet.rb,
lib/nano/wallet/version.rb
Constant Summary collapse
- VERSION =
"0.2.0"
Instance Attribute Summary collapse
-
#accounts ⇒ Object
readonly
Returns the value of attribute accounts.
-
#seed ⇒ Object
readonly
Returns the value of attribute seed.
Class Method Summary collapse
Instance Method Summary collapse
- #account_at_index(index) ⇒ Object
- #add_account! ⇒ Object
- #add_accounts!(count) ⇒ Object
-
#initialize(seed) ⇒ Wallet
constructor
A new instance of Wallet.
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
#accounts ⇒ Object (readonly)
Returns the value of attribute accounts.
11 12 13 |
# File 'lib/nano/wallet.rb', line 11 def accounts @accounts end |
#seed ⇒ Object (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_seed ⇒ Object
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 account_at_index(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! account = Nano::Account.new(@seed, @accounts.size) @accounts << account account end |
#add_accounts!(count) ⇒ Object
22 23 24 |
# File 'lib/nano/wallet.rb', line 22 def add_accounts!(count) count.times { add_account! } end |