lib/cardano_wallet/byron.rb in cardano_wallet-0.1.5 vs lib/cardano_wallet/byron.rb in cardano_wallet-0.1.6

- old
+ new

@@ -20,10 +20,16 @@ # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Byron-Addresses def addresses Addresses.new @opt end + # API for CoinSelections + # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Byron-Coin-Selections + def coin_selections + CoinSelections.new @opt + end + # Get API for Byron transactions # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postByronTransactionFee def transactions Transactions.new @opt end @@ -150,9 +156,39 @@ # @param addr_id [String] address id def import(wid, addr_id) self.class.put("/byron-wallets/#{wid}/addresses/#{addr_id}") end + # Import addresses to Byron wallet. + # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/importAddresses + # @param wid [String] wallet id + # @param addresses [Array] array of addresses + def bulk_import(wid, addresses) + self.class.put("/byron-wallets/#{wid}/addresses", + :body => { :addresses => addresses + }.to_json, + :headers => { 'Content-Type' => 'application/json' } ) + end + end + + # API for CoinSelections + # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Byron-Coin-Selections + class CoinSelections < Base + def initialize opt + super + end + + # Show random coin selection for particular payment + # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/byronSelectCoins + # + # @example + # random(wid, {address1: 123, address2: 456}) + def random(wid, payments) + payments_formatted = Utils.format_payments(payments) + self.class.post("/byron-wallets/#{wid}/coin-selections/random", + :body => {:payments => payments_formatted}.to_json, + :headers => { 'Content-Type' => 'application/json' }) + end end # Byron transactions # @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postByronTransactionFee class Transactions < Base