Class: Bcoin::Client::Wallet
Overview
The primary bcoin.io Wallet object.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#account ⇒ Bcoin::Client::Account
Access the default account without making another network request.
-
#accounts ⇒ Bcoin::Client::Accounts
Retrieve a list of acounts with details.
-
#balance ⇒ Bcoin::Client::Balance
Retrieve balance information for this wallet.
- #base_path ⇒ Object
-
#error? ⇒ true, false
Checks for an error returned during a request.
-
#fee(blocks = 1) ⇒ Float
Check the current fee for processing a transaction within x number of blocks.
- #id ⇒ Object
-
#lock ⇒ true, false
Locks the wallet master key.
-
#master ⇒ Bcoin::Client::Master
Retrieves the wallet HD Master Key.
-
#passphrase(options = {}) ⇒ true, false
Reset the wallet passphrase.
-
#retoken ⇒ Hash
Retrieves a new wallet API token.
-
#send(options = {}) ⇒ Object
Create, sign, and send a new transaction.
-
#unlock(options = {}) ⇒ true, false
Unlock the wallet master key for retrieval of the wallet mnemonic, and key in plain text for ‘timeout’ number of seconds.
Methods inherited from Base
#error, #error=, #initialize, #inspect, #refresh!, #respond_to?, #token=, #wallet_token
Methods included from HttpMethods
#delete, #get, #post, #put, #wallet_token
Constructor Details
This class inherits a constructor from Bcoin::Client::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Bcoin::Client::Base
Instance Method Details
#account ⇒ Bcoin::Client::Account
Access the default account without making another network request.
27 28 29 |
# File 'lib/bcoin/client/wallet.rb', line 27 def account @account ||= Account.new(self, @attributes[:account]) end |
#accounts ⇒ Bcoin::Client::Accounts
Retrieve a list of acounts with details.
20 21 22 |
# File 'lib/bcoin/client/wallet.rb', line 20 def accounts @accounts ||= Accounts.new(self).refresh! end |
#balance ⇒ Bcoin::Client::Balance
Retrieve balance information for this wallet.
33 34 35 |
# File 'lib/bcoin/client/wallet.rb', line 33 def balance @balance ||= Balance.new(self).refresh! end |
#base_path ⇒ Object
14 15 16 |
# File 'lib/bcoin/client/wallet.rb', line 14 def base_path '/wallet/' + id.to_s end |
#error? ⇒ true, false
Checks for an error returned during a request.
112 113 114 |
# File 'lib/bcoin/client/wallet.rb', line 112 def error? @attributes[:error] ? true : false end |
#fee(blocks = 1) ⇒ Float
Check the current fee for processing a transaction within x number of blocks.
97 98 99 |
# File 'lib/bcoin/client/wallet.rb', line 97 def fee blocks = 1 client.fee blocks end |
#id ⇒ Object
10 11 12 |
# File 'lib/bcoin/client/wallet.rb', line 10 def id @attributes[:id] end |
#lock ⇒ true, false
Locks the wallet master key.
64 65 66 67 |
# File 'lib/bcoin/client/wallet.rb', line 64 def lock post '/lock' !error? end |
#master ⇒ Bcoin::Client::Master
Retrieves the wallet HD Master Key.
71 72 73 74 75 76 |
# File 'lib/bcoin/client/wallet.rb', line 71 def master @master ||= begin response = get '/master' Master.new self, response end end |
#passphrase(options = {}) ⇒ true, false
Reset the wallet passphrase. Useful for locking and unlocking the the master key and wallet coins.
44 45 46 47 |
# File 'lib/bcoin/client/wallet.rb', line 44 def passphrase = {} post '/passphrase', !error? end |
#retoken ⇒ Hash
Retrieves a new wallet API token.
81 82 83 84 85 86 87 88 89 90 |
# 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 = {}) ⇒ Object
Create, sign, and send a new transaction.
105 106 107 108 |
# File 'lib/bcoin/client/wallet.rb', line 105 def send = {} response = post '/send', error? ? false : response end |
#unlock(options = {}) ⇒ true, false
Unlock the wallet master key for retrieval of the wallet mnemonic, and key in plain text for ‘timeout’ number of seconds.
57 58 59 60 |
# File 'lib/bcoin/client/wallet.rb', line 57 def unlock = {} post '/unlock', !error? end |