class Bcoin::Client::Wallet

The primary bcoin.io Wallet object.

Public Instance Methods

account() click to toggle source

Access the default account without making another network request. @return [Bcoin::Client::Account]

# File lib/bcoin/client/wallet.rb, line 27
def account
  @account ||= Account.new(self, @attributes[:account])
end
accounts() click to toggle source

Retrieve a list of acounts with details. @return [Bcoin::Client::Accounts]

# File lib/bcoin/client/wallet.rb, line 20
def accounts
  @accounts ||= Accounts.new(self).refresh!
end
balance() click to toggle source

Retrieve balance information for this wallet. @return [Bcoin::Client::Balance]

# File lib/bcoin/client/wallet.rb, line 33
def balance
  @balance ||= Balance.new(self).refresh!
end
base_path() click to toggle source
# File lib/bcoin/client/wallet.rb, line 14
def base_path
  '/wallet/' + id.to_s
end
error?() click to toggle source

Checks for an error returned during a request. @return [true, false]

# File lib/bcoin/client/wallet.rb, line 112
def error?
  @attributes[:error] ? true : false
end
fee(blocks = 1) click to toggle source

Check the current fee for processing a transaction within x number of blocks. @params [Integer] Blocks Number of blocks the transaction

will be processed within if paying the returned rate.

@return [Float] Rate

# File lib/bcoin/client/wallet.rb, line 97
def fee blocks = 1
  client.fee blocks
end
id() click to toggle source
# File lib/bcoin/client/wallet.rb, line 10
def id
  @attributes[:id]
end
lock() click to toggle source

Locks the wallet master key. @return [true, false] True if succesful.

# File lib/bcoin/client/wallet.rb, line 64
def lock
  post '/lock'
  !error?
end
master() click to toggle source

Retrieves the wallet HD Master Key. @return [Bcoin::Client::Master] The wallet master key object.

# File lib/bcoin/client/wallet.rb, line 71
def master
  @master ||= begin
    response = get '/master'
    Master.new self, response
  end
end
passphrase(options = {}) click to toggle source

Reset the wallet passphrase. Useful for locking and unlocking the the master key and wallet coins. @param [Hash] opts The options for resetting

the wallet passphrase.

@option opts [String] :old The old password. @option opts [String] :new The new password. @return [true, false] True if successful.

# File lib/bcoin/client/wallet.rb, line 44
def passphrase options = {}
  post '/passphrase', options
  !error?
end
retoken() click to toggle source

Retrieves a new wallet API token. @return [Hash] opts @option opts :token The new wallet API token.

# File lib/bcoin/client/wallet.rb, line 81
def retoken
  response = post '/retoken'

  if error?
    false
  else
    @attributes[:token] = response['token']
    true
  end
end
send(options = {}) click to toggle source

Create, sign, and send a new transaction. @params [Hash] opts Options for the new transaction. @option opts :rate Rate for the bitcoin network. @option opts :outputs => [{:value => '', :address => ''}]

# File lib/bcoin/client/wallet.rb, line 105
def send options = {}
  response = post '/send', options
  error? ? false : response
end
unlock(options = {}) click to toggle source

Unlock the wallet master key for retrieval of the wallet mnemonic, and key in plain text for 'timeout' number of seconds. @params [Hash] opts The options for unlocking

the wallet master key.

@option opts [String] :passphrase The wallet passphrase. @option opts [Integer] :timeout Seconds to unlock the wallet for. @return [true, false] True if succesful.

# File lib/bcoin/client/wallet.rb, line 57
def unlock options = {}
  post '/unlock', options
  !error?
end