Class: Bcoin::Client::Wallets

Inherits:
Collection show all
Defined in:
lib/bcoin/client/wallets.rb

Instance Attribute Summary collapse

Attributes inherited from Collection

#collection, #error

Instance Method Summary collapse

Methods inherited from Collection

#each, #error?, #initialize, #inspect

Methods included from HttpMethods

#delete, #get, #post, #put, #wallet_token

Constructor Details

This class inherits a constructor from Bcoin::Client::Collection

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/bcoin/client/wallets.rb', line 8

def client
  @client
end

Instance Method Details

#base_pathObject

The base path for the wallets collection must be set to ‘/’ since the bcoin API breaks from the RESTful standard for the retrieval of the wallet collection. The list of wallets is located at ‘/wallets/_admin/wallets’. The base path for all other wallet operations is the expected ‘/wallet’.



16
17
18
# File 'lib/bcoin/client/wallets.rb', line 16

def base_path
  '/'
end

#create(options = {}) ⇒ Bcoin::Client::Wallet

Create a new Wallet.

Parameters:

  • opts (Hash)

    a customizable set of options

Returns:



41
42
43
44
45
46
47
48
# File 'lib/bcoin/client/wallets.rb', line 41

def create options = {}
  # The path in this post operation intentionally omits
  # the preceeding slash due to wonkiness with the wallets
  # base path breaking standards. See Wallets#base_path
  # comment above.
  response = post 'wallet/', options
  Wallet.new(client, response)
end

#find(attr) ⇒ Object



30
31
32
# File 'lib/bcoin/client/wallets.rb', line 30

def find attr
  Wallet.new(client, attr).refresh!
end

#refresh!Object



20
21
22
23
24
25
26
27
28
# File 'lib/bcoin/client/wallets.rb', line 20

def refresh!
  # Preceeding slash in the GET operation intentionally omitted
  # due to wonkiness with the wallets base path. See the
  # Wallets#base_path comment above.
  @collection = super('wallet/_admin/wallets').collect { |w|
    Wallet.new(client, id: w).refresh!
  }
  self
end