Sha256: 4eefc7a7334c5db7ccb2b61481a6054dff79dd669f13411c1fb042e36cb6c084

Contents?: true

Size: 941 Bytes

Versions: 4

Compression:

Stored size: 941 Bytes

Contents

module Bitshares

  class Wallet

    attr_reader :name, :account

    def initialize(name)
      @name = name
      @account = nil
      @password = Bitshares.config[:wallets][@name.to_sym]
    end

    def account(name)
      @account = Bitshares::Account.new(self, name)
    end

    def open
      Bitshares::Client::rpc.request('wallet_open', [@name])
    end

    def lock
      open # must be opened first
      Bitshares::Client::rpc.request 'wallet_lock'
    end

    def unlock(timeout = 1776)
      open # must be opened first
      Bitshares::Client::rpc.request('wallet_unlock', [timeout, @password])
    end

    def open?
      self.get_info['open']
    end

    def closed?
      !open?
    end

    def unlocked?
      open
      get_info['unlocked']
    end

    def locked?
      !unlocked?
    end

    def method_missing(name, *args)
      Bitshares::Client::rpc.request('wallet_' + name.to_s, args)
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bitshares-0.1.3.pre lib/bitshares/wallet.rb
bitshares-0.1.2.pre lib/bitshares/wallet.rb
bitshares-0.1.1.pre lib/bitshares/wallet.rb
bitshares-0.1.0.pre lib/bitshares/wallet.rb