class Bcoin::Client::Wallet
The primary bcoin.io Wallet
object.
Public Instance Methods
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
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
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
# File lib/bcoin/client/wallet.rb, line 14 def base_path '/wallet/' + id.to_s end
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
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
# File lib/bcoin/client/wallet.rb, line 10 def id @attributes[:id] end
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
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
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
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
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 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