Class: CardanoWallet::Byron::CoinSelections

Inherits:
CardanoWallet::Base show all
Defined in:
lib/cardano_wallet/byron.rb

Overview

API for CoinSelections

Examples:

@cw = CardanoWallet.new
@cw.byron.coin_selections # API for Byron coin_selections

See Also:

Instance Attribute Summary

Attributes inherited from CardanoWallet::Base

#opt

Instance Method Summary collapse

Methods inherited from CardanoWallet::Base

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

Constructor Details

This class inherits a constructor from CardanoWallet::Base

Instance Method Details

#random(wid, payments) ⇒ Object

Show random coin selection for particular payment

Examples:

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

See Also:



233
234
235
236
237
238
239
240
241
242
243
# File 'lib/cardano_wallet/byron.rb', line 233

def random(wid, payments)
  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
  self.class.post("/byron-wallets/#{wid}/coin-selections/random",
                  body: { payments: payments_formatted }.to_json,
                  headers: { 'Content-Type' => 'application/json' })
end