Sha256: dffb15e629c50c7f9967a4cae36f22fa1a0810769a161a91d9f031267af21041

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

module BitWallet
  class Wallet

    def initialize(config={})
      @config = config
    end

    def accounts
      @accounts ||= Accounts.new(self)
    end

    def recent_transactions(options={})
      count = options.delete(:limit) || 10
      client.listtransactions('*', count).map do |hash|
        Transaction.new self, hash
      end
    end

    def move(from_account,
             to_account,
             amount,
             min_conf=BitWallet.config.min_conf,
             comment=nil)

      from_account_str = if from_account.respond_to?(:name)
                           from_account.name
                         else
                           from_account
                         end
      to_account_str = if to_account.respond_to?(:name)
                           to_account.name
                         else
                           to_account
                         end
      client.move(from_account_str,
                  to_account_str,
                  amount,
                  min_conf,
                  comment)
    end

    private

    def client
      @client ||= InstantiatesBitcoinClient.execute(@config)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bit_wallet-0.6.0 lib/bit_wallet/wallet.rb
bit_wallet-0.5.0 lib/bit_wallet/wallet.rb