Class: Stellar::Account
- Inherits:
-
Object
- Object
- Stellar::Account
- Defined in:
- lib/stellar/account.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#keypair ⇒ Object
readonly
Returns the value of attribute keypair.
Class Method Summary collapse
Instance Method Summary collapse
- #address(force_account_id: true) ⇒ Object
- #base_account ⇒ Object
-
#initialize(keypair, id = nil) ⇒ Account
constructor
A new instance of Account.
- #muxed_account ⇒ Object
- #to_keypair ⇒ Object
Constructor Details
#initialize(keypair, id = nil) ⇒ Account
Returns a new instance of Account.
35 36 37 38 |
# File 'lib/stellar/account.rb', line 35 def initialize(keypair, id = nil) @keypair = keypair @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
31 32 33 |
# File 'lib/stellar/account.rb', line 31 def id @id end |
#keypair ⇒ Object (readonly)
Returns the value of attribute keypair.
31 32 33 |
# File 'lib/stellar/account.rb', line 31 def keypair @keypair end |
Class Method Details
.from_address(address) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/stellar/account.rb', line 15 def self.from_address(address) muxed_xdr = Util::StrKey.decode_muxed_account(address) if muxed_xdr.ed25519 new(KeyPair.from_public_key(muxed_xdr.ed25519)) else muxed_xdr = muxed_xdr.med25519! new(KeyPair.from_public_key(muxed_xdr.ed25519), muxed_xdr.id) end end |
.from_seed(seed) ⇒ Object
10 11 12 13 |
# File 'lib/stellar/account.rb', line 10 def self.from_seed(seed) keypair = Stellar::KeyPair.from_seed(seed) new(keypair) end |
.master ⇒ Object
26 27 28 29 |
# File 'lib/stellar/account.rb', line 26 def self.master keypair = Stellar::KeyPair.from_raw_seed("allmylifemyhearthasbeensearching") new(keypair) end |
Instance Method Details
#address(force_account_id: true) ⇒ Object
49 50 51 52 53 |
# File 'lib/stellar/account.rb', line 49 def address(force_account_id: true) return keypair.address if force_account_id Util::StrKey.check_encode(:muxed, keypair.raw_public_key + [id].pack("Q>")) end |
#base_account ⇒ Object
40 41 42 |
# File 'lib/stellar/account.rb', line 40 def base_account Stellar::MuxedAccount.ed25519(keypair.raw_public_key) end |
#muxed_account ⇒ Object
44 45 46 47 |
# File 'lib/stellar/account.rb', line 44 def muxed_account return base_account unless id Stellar::MuxedAccount.med25519(ed25519: keypair.raw_public_key, id: id) end |
#to_keypair ⇒ Object
55 56 57 |
# File 'lib/stellar/account.rb', line 55 def to_keypair keypair end |