class Stellar::Account
Attributes
id[R]
keypair[R]
Public Class Methods
from_address(address)
click to toggle source
# 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)
click to toggle source
# File lib/stellar/account.rb, line 10 def self.from_seed(seed) keypair = Stellar::KeyPair.from_seed(seed) new(keypair) end
master()
click to toggle source
# File lib/stellar/account.rb, line 26 def self.master keypair = Stellar::KeyPair.from_raw_seed("allmylifemyhearthasbeensearching") new(keypair) end
new(keypair, id = nil)
click to toggle source
@param [Stellar::KeyPair] keypair @param [Integer] id
# File lib/stellar/account.rb, line 35 def initialize(keypair, id = nil) @keypair = keypair @id = id end
random()
click to toggle source
# File lib/stellar/account.rb, line 5 def self.random keypair = Stellar::KeyPair.random new(keypair) end
Public Instance Methods
address(force_account_id: true)
click to toggle source
# 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()
click to toggle source
# File lib/stellar/account.rb, line 40 def base_account Stellar::MuxedAccount.ed25519(keypair.raw_public_key) end
muxed_account()
click to toggle source
# 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()
click to toggle source
# File lib/stellar/account.rb, line 55 def to_keypair keypair end