class Bitbank::Account

Attributes

name[R]

Public Class Methods

new(client, name, balance=nil, check=false) click to toggle source
# File lib/bitbank/account.rb, line 5
def initialize(client, name, balance=nil, check=false)
  @client = client
  @name = name
  @balance = balance # currently unused

  # validate the address if a check is requested
  # (bitcoind creates it if it didn't previous exist)
  address if check
end

Public Instance Methods

==(other) click to toggle source
# File lib/bitbank/account.rb, line 63
def ==(other)
  name == other.name
end
address() click to toggle source

Returns the current bitcoin address for receiving payments to this account.

# File lib/bitbank/account.rb, line 17
def address
  @client.request('getaccountaddress', name)
end
balance() click to toggle source

Returns the balance in this account.

# File lib/bitbank/account.rb, line 22
def balance
  @client.balance(name)
end
move(name_or_account, amount) click to toggle source

Move funds from one account in your wallet to another. First parameter can either by an account name or an actual account object.

# File lib/bitbank/account.rb, line 29
def move(name_or_account, amount)
  to_name = if name_or_account.is_a?(Bitbank::Account)
    name_or_account.name
  else
    name_or_account
  end

  @client.request('move', name, to_name, amount)
end
Also aliased as: transfer
new_address() click to toggle source

Returns a new bitcoin address for receiving payments to this account.

# File lib/bitbank/account.rb, line 42
def new_address
  @client.new_address(name)
end
pay(address, amount) click to toggle source

Send funds from this account to the recipient identified by address. Note that amount is a real and is rounded to 8 decimal places. Returns the transaction if successful.

# File lib/bitbank/account.rb, line 49
def pay(address, amount)
  if @client.validate_address(address, true)
    txid = @client.request('sendfrom', name, address, amount)
    Transaction.new(@client, txid)
  else
    false
  end
end
transactions(count = 10) click to toggle source

Returns a list of the most recent transactions for this account.

# File lib/bitbank/account.rb, line 59
def transactions(count = 10)
  @client.transactions(name, count)
end
transfer(name_or_account, amount)
Alias for: move