Methods
A
C
D
M
N
P
R
W
Constants
DEFAULT_UNIT = :nano
 
UNITS = [:raw, :nano]
 
Class Public methods
new(rpc, wallet, account)
# File lib/nanook/wallet_account.rb, line 7
def initialize(rpc, wallet, account)
  @rpc = rpc
  @wallet = wallet
  @account = account

  # An object to delegate account methods that don't
  # expect a wallet param in the RPC call, to allow this
  # class to support all methods that can be called on Nanook::Account
  @nanook_account_instance = Nanook::Account.new(@rpc, @account)

  # Wallet instance to call contains? on to check account
  # is in wallet
  @nanook_wallet_instance = Nanook::Wallet.new(@rpc, @wallet)

  if @account
    account_must_belong_to_wallet!
  end
end
Instance Public methods
account_id()
# File lib/nanook/wallet_account.rb, line 26
def account_id
  @account
end
create()
# File lib/nanook/wallet_account.rb, line 30
def create
  wallet_required!
  rpc(:account_create)[:account]
end
destroy()
# File lib/nanook/wallet_account.rb, line 35
def destroy
  wallet_required!
  (rpc(:account_remove)[:removed] == 1).tap do |success|
    @known_valid_accounts.delete(@account) if success
  end
end
method_missing(m, *args, &block)

Any method of Nanook::Account can be called on this class too

# File lib/nanook/wallet_account.rb, line 98
def method_missing(m, *args, &block)
  if @nanook_account_instance.respond_to?(m)
    @nanook_account_instance.send(m, *args, &block)
  else
    super(m, *args, &block)
  end
end
pay(to:, amount:, unit: DEFAULT_UNIT, id:)
# File lib/nanook/wallet_account.rb, line 46
def pay(to:, amount:, unit: DEFAULT_UNIT, id:)
  wallet_required!

  unless UNITS.include?(unit)
    raise ArgumentError.new("Unsupported unit: #{unit}")
  end

  # Check that to: account is valid
  unless Nanook::Account.new(@rpc, to).exists?
    raise ArgumentError.new("To account does not exist (#{to})")
  end

  raw = if unit.to_sym.eql?(:nano)
    Nanook::Util.NANO_to_raw(amount)
  else
    amount
  end

  # account is called source, so don't use the normal rpc method
  p = {
    wallet: @wallet,
    source: @account,
    destination: to,
    amount: raw,
    id: id
  }

  response = @rpc.call(:send, p)

  if response.has_key?(:error)
    return response[:error]
  end

  response[:block]
end
receive(block=nil)

Returns false if no block to receive

# File lib/nanook/wallet_account.rb, line 83
def receive(block=nil)
  wallet_required!

  if block.nil?
    _receive_without_block
  else
    _receive_with_block(block)
  end
end
wallet_id()
# File lib/nanook/wallet_account.rb, line 93
def wallet_id
  @wallet
end