class Glueby::Wallet
Attributes
internal_wallet[R]
Public Class Methods
configure(config)
click to toggle source
@deprecated - Use Glueby.configure
instead
# File lib/glueby/wallet.rb, line 17 def configure(config) case config[:adapter] when 'core' Glueby::Internal::RPC.configure(config) Glueby::Internal::Wallet.wallet_adapter = Glueby::Internal::Wallet::TapyrusCoreWalletAdapter.new when 'activerecord' Glueby::Internal::RPC.configure(config) Glueby::Internal::Wallet.wallet_adapter = Glueby::Internal::Wallet::ActiveRecordWalletAdapter.new else raise 'Not implemented' end end
create()
click to toggle source
# File lib/glueby/wallet.rb, line 8 def create new(Glueby::Internal::Wallet.create) end
load(wallet_id)
click to toggle source
# File lib/glueby/wallet.rb, line 12 def load(wallet_id) new(Glueby::Internal::Wallet.load(wallet_id)) end
new(internal_wallet)
click to toggle source
# File lib/glueby/wallet.rb, line 48 def initialize(internal_wallet) @internal_wallet = internal_wallet end
Public Instance Methods
balances(only_finalized = true)
click to toggle source
@return [HashMap] hash of balances which key is color_id or empty string, and value is amount
# File lib/glueby/wallet.rb, line 36 def balances(only_finalized = true) utxos = @internal_wallet.list_unspent(only_finalized) utxos.inject({}) do |balances, output| key = output[:color_id] || '' balances[key] ||= 0 balances[key] += output[:amount] balances end end
id()
click to toggle source
# File lib/glueby/wallet.rb, line 31 def id @internal_wallet.id end