Class: CardanoWallet::Shelley::CoinSelections

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

Overview

API for CoinSelections

Examples:

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

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

#random(wid, payments, withdrawal = nil, metadata = nil) ⇒ Object

Show random coin selection for particular payment

Examples:

random(wid, [{addr1: 1000000}, {addr2: 1000000}])
random(wid, [{ "address": "addr1..",
               "amount": { "quantity": 42000000, "unit": "lovelace" },
               "assets": [{"policy_id": "pid", "asset_name": "name", "quantity": 0 } ] } ])

See Also:



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/cardano_wallet/shelley.rb', line 266

def random(wid, payments, withdrawal = nil,  = nil)
  Utils.verify_param_is_array!(payments)
  payments_formatted = if payments.any? { |p| p.key?(:address) || p.key?('address') }
                         payments
                       else
                         Utils.format_payments(payments)
                       end
  payload = { payments: payments_formatted }
  payload[:withdrawal] = withdrawal if withdrawal
  payload[:metadata] =  if 

  self.class.post("/wallets/#{wid}/coin-selections/random",
                  debug_output: $stdout,
                  body: payload.to_json,
                  headers: { 'Content-Type' => 'application/json' })
end

#random_deleg(wid, deleg_action) ⇒ Object

Coin selection -> Delegation action

Examples:

random(wid, {action: "join", pool: "poolid"})
random(wid, {action: "quit"})

See Also:



289
290
291
292
293
294
# File 'lib/cardano_wallet/shelley.rb', line 289

def random_deleg(wid, deleg_action)
  Utils.verify_param_is_hash!(deleg_action)
  self.class.post("/wallets/#{wid}/coin-selections/random",
                  body: { delegation_action: deleg_action }.to_json,
                  headers: { 'Content-Type' => 'application/json' })
end