Class: Laksa::Account::Account
- Inherits:
-
Object
- Object
- Laksa::Account::Account
- Defined in:
- lib/laksa/account/account.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#private_key ⇒ Object
readonly
Returns the value of attribute private_key.
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
Class Method Summary collapse
-
.from_file(file, passphrase) ⇒ Object
Takes a JSON-encoded keystore and passphrase, returning a fully instantiated Account instance.
Instance Method Summary collapse
-
#initialize(private_key) ⇒ Account
constructor
A new instance of Account.
-
#sign_transaction(tx) ⇒ Object
sign the passed in transaction with the account’s private and public key.
-
#to_file(passphrase, type) ⇒ Object
Convert an Account instance to a JSON-encoded keystore.
Constructor Details
#initialize(private_key) ⇒ Account
Returns a new instance of Account.
5 6 7 8 9 |
# File 'lib/laksa/account/account.rb', line 5 def initialize(private_key) @private_key = private_key @public_key = Laksa::Crypto::KeyTool.get_public_key_from_private_key(private_key, true) @address = Laksa::Crypto::KeyTool.get_address_from_public_key(@public_key) end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
4 5 6 |
# File 'lib/laksa/account/account.rb', line 4 def address @address end |
#private_key ⇒ Object (readonly)
Returns the value of attribute private_key.
4 5 6 |
# File 'lib/laksa/account/account.rb', line 4 def private_key @private_key end |
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key.
4 5 6 |
# File 'lib/laksa/account/account.rb', line 4 def public_key @public_key end |
Class Method Details
.from_file(file, passphrase) ⇒ Object
Takes a JSON-encoded keystore and passphrase, returning a fully instantiated Account instance.
13 14 15 16 17 |
# File 'lib/laksa/account/account.rb', line 13 def self.from_file(file, passphrase) key_store = Laksa::Crypto::KeyStore.new private_key = key_store.decrypt_private_key(file, passphrase) Account.new(private_key) end |