Class: Neb::Account
- Inherits:
-
Object
- Object
- Neb::Account
- Defined in:
- lib/neb/account.rb
Instance Attribute Summary collapse
-
#address_obj ⇒ Object
readonly
Returns the value of attribute address_obj.
-
#password ⇒ Object
Returns the value of attribute password.
-
#private_key_obj ⇒ Object
readonly
Returns the value of attribute private_key_obj.
-
#public_key_obj ⇒ Object
readonly
Returns the value of attribute public_key_obj.
Class Method Summary collapse
- .create(password: nil) ⇒ Object
- .from_key(key:, password:) ⇒ Object
- .from_key_file(key_file:, password:) ⇒ Object
Instance Method Summary collapse
- #address ⇒ Object
-
#initialize(private_key:, password: nil) ⇒ Account
constructor
A new instance of Account.
- #private_key ⇒ Object
- #public_key ⇒ Object
- #to_key ⇒ Object
- #to_key_file(file_path: nil) ⇒ Object
Constructor Details
#initialize(private_key:, password: nil) ⇒ Account
Returns a new instance of Account.
11 12 13 14 15 16 |
# File 'lib/neb/account.rb', line 11 def initialize(private_key:, password: nil) @private_key_obj = PrivateKey.new(private_key) @public_key_obj = @private_key_obj.to_pubkey_obj @address_obj = @public_key_obj.to_address_obj @password = password end |
Instance Attribute Details
#address_obj ⇒ Object (readonly)
Returns the value of attribute address_obj.
6 7 8 |
# File 'lib/neb/account.rb', line 6 def address_obj @address_obj end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/neb/account.rb', line 7 def password @password end |
#private_key_obj ⇒ Object (readonly)
Returns the value of attribute private_key_obj.
6 7 8 |
# File 'lib/neb/account.rb', line 6 def private_key_obj @private_key_obj end |
#public_key_obj ⇒ Object (readonly)
Returns the value of attribute public_key_obj.
6 7 8 |
# File 'lib/neb/account.rb', line 6 def public_key_obj @public_key_obj end |
Class Method Details
.create(password: nil) ⇒ Object
19 20 21 |
# File 'lib/neb/account.rb', line 19 def create(password: nil) new(private_key: PrivateKey.random.to_s, password: password) end |
.from_key(key:, password:) ⇒ Object
23 24 25 |
# File 'lib/neb/account.rb', line 23 def from_key(key:, password:) new(private_key: Key.decrypt(key, password), password: password) end |
.from_key_file(key_file:, password:) ⇒ Object
27 28 29 |
# File 'lib/neb/account.rb', line 27 def from_key_file(key_file:, password:) from_key(key: File.read(key_file), password: password) end |
Instance Method Details
#address ⇒ Object
40 41 42 |
# File 'lib/neb/account.rb', line 40 def address @address_obj.to_s end |
#private_key ⇒ Object
32 33 34 |
# File 'lib/neb/account.rb', line 32 def private_key @private_key_obj.to_s end |
#public_key ⇒ Object
36 37 38 |
# File 'lib/neb/account.rb', line 36 def public_key @public_key_obj.to_s end |