Class: CardanoWallet::Shelley::Wallets

Inherits:
Base
  • Object
show all
Defined in:
lib/cardano_wallet/shelley.rb

Overview

API for Wallets

Examples:

@cw = CardanoWallet.new
@cw.shelley.wallets # API for Shelley wallets

See Also:

Instance Attribute Summary

Attributes inherited from Base

#opt

Instance Method Summary collapse

Methods inherited from Base

#byron, #initialize, #misc, #shared, #shelley, #utils

Constructor Details

This class inherits a constructor from CardanoWallet::Base

Instance Method Details

#create(params) ⇒ Object

Create a wallet based on the params.

Examples:

Create wallet from mnemonic sentence

@cw.shelley.wallets.create({name: "Wallet from mnemonic_sentence",
        passphrase: "Secure Passphrase",
        mnemonic_sentence: %w[story egg fun ... ],
       })

Create wallet from pub key

@cw.shelley.wallets.create({name: "Wallet from pub key",
        account_public_key: "b47546e...",
        address_pool_gap: 20,
       })

See Also:



185
186
187
188
189
190
# File 'lib/cardano_wallet/shelley.rb', line 185

def create(params)
  Utils.verify_param_is_hash!(params)
  self.class.post('/wallets',
                  body: params.to_json,
                  headers: { 'Content-Type' => 'application/json' })
end

#delete(wid) ⇒ Object

Delete wallet



194
195
196
# File 'lib/cardano_wallet/shelley.rb', line 194

def delete(wid)
  self.class.delete("/wallets/#{wid}")
end

#get(wid) ⇒ Object

Get wallet details



168
169
170
# File 'lib/cardano_wallet/shelley.rb', line 168

def get(wid)
  self.class.get("/wallets/#{wid}")
end

#listObject

List all wallets



162
163
164
# File 'lib/cardano_wallet/shelley.rb', line 162

def list
  self.class.get('/wallets')
end

#update_metadata(wid, params) ⇒ Object

Update wallet’s metadata

Examples:

@cw.shelley.wallets.(wid, {name: "New wallet name"})

See Also:



203
204
205
206
207
208
# File 'lib/cardano_wallet/shelley.rb', line 203

def (wid, params)
  Utils.verify_param_is_hash!(params)
  self.class.put("/wallets/#{wid}",
                 body: params.to_json,
                 headers: { 'Content-Type' => 'application/json' })
end

#update_passphrase(wid, params) ⇒ Object

Update wallet’s passphrase

Examples:

@cw.shelley.wallets.update_passphrase(wid, {old_passphrase: "Secure Passphrase",
                                            new_passphrase: "Securer Passphrase"})

See Also:



227
228
229
230
231
232
# File 'lib/cardano_wallet/shelley.rb', line 227

def update_passphrase(wid, params)
  Utils.verify_param_is_hash!(params)
  self.class.put("/wallets/#{wid}/passphrase",
                 body: params.to_json,
                 headers: { 'Content-Type' => 'application/json' })
end

#utxo(wid) ⇒ Object

See wallet’s utxo distribution



212
213
214
# File 'lib/cardano_wallet/shelley.rb', line 212

def utxo(wid)
  self.class.get("/wallets/#{wid}/statistics/utxos")
end

#utxo_snapshot(wid) ⇒ Object



217
218
219
# File 'lib/cardano_wallet/shelley.rb', line 217

def utxo_snapshot(wid)
  self.class.get("/wallets/#{wid}/utxo")
end