Sha256: 0502e7fcd9e05699ae1d31a75b5641efdef64c3ca5078b2214d491f31414fca6

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 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

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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bit_wallet-0.6.1 lib/bit_wallet/wallet.rb