cardano-node-emulator-1.2.0.0
Safe HaskellNone
LanguageHaskell2010

Cardano.Node.Emulator.Internal.Node.Fee

Contents

Description

Calculating transaction fees in the emulator.

Synopsis

Documentation

makeAutoBalancedTransaction Source #

Arguments

:: Params 
-> UTxO EmulatorEra

Just the transaction inputs, not the entire UTxO.

-> CardanoBuildTx 
-> CardanoAddress

Change address

-> Either CardanoLedgerError (Tx BabbageEra) 

Creates a balanced transaction by calculating the execution units, the fees and the change, which is assigned to the given address. Only balances Ada.

makeAutoBalancedTransactionWithUtxoProvider Source #

Arguments

:: Monad m 
=> Params 
-> UtxoIndex

Just the transaction inputs, not the entire UTxO.

-> CardanoAddress

Change address

-> UtxoProvider m 
-> (forall a. CardanoLedgerError -> m a)

How to handle errors

-> CardanoBuildTx 
-> m (Tx BabbageEra) 

Creates a balanced transaction by calculating the execution units, the fees and then the balance. If the balance is negative the utxo provider is asked to pick extra inputs to make the balance is positive, which is then assigned to the change address. The collateral is similarly balanced. Unlike makeAutoBalancedTransaction this function also balances non-Ada.

utxoProviderFromWalletOutputs Source #

Arguments

:: UtxoIndex

The unspent transaction outputs.

-> CardanoBuildTx

The transaction being balanced, to make sure that we don't reuse any inputs from it.

-> UtxoProvider (Either BalancingError) 

data BalancingError Source #

Constructors

InsufficientFunds

Not enough extra inputs available to balance a transaction.

Fields

CardanoLedgerError CardanoLedgerError 

Instances

Instances details
Eq BalancingError Source # 
Instance details

Defined in Cardano.Node.Emulator.Internal.Node.Fee

Show BalancingError Source # 
Instance details

Defined in Cardano.Node.Emulator.Internal.Node.Fee

Generic BalancingError Source # 
Instance details

Defined in Cardano.Node.Emulator.Internal.Node.Fee

Associated Types

type Rep BalancingError :: Type -> Type Source #

FromJSON BalancingError Source # 
Instance details

Defined in Cardano.Node.Emulator.Internal.Node.Fee

Methods

parseJSON :: Value -> Parser BalancingError

parseJSONList :: Value -> Parser [BalancingError]

ToJSON BalancingError Source # 
Instance details

Defined in Cardano.Node.Emulator.Internal.Node.Fee

Methods

toJSON :: BalancingError -> Value

toEncoding :: BalancingError -> Encoding

toJSONList :: [BalancingError] -> Value

toEncodingList :: [BalancingError] -> Encoding

type Rep BalancingError Source # 
Instance details

Defined in Cardano.Node.Emulator.Internal.Node.Fee

type Rep BalancingError = D1 ('MetaData "BalancingError" "Cardano.Node.Emulator.Internal.Node.Fee" "cardano-node-emulator-1.2.0.0-1RjxyDmnwHSAn2KgGdAUXD" 'False) (C1 ('MetaCons "InsufficientFunds" 'PrefixI 'True) (S1 ('MetaSel ('Just "total") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value) :*: S1 ('MetaSel ('Just "expected") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)) :+: C1 ('MetaCons "CardanoLedgerError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CardanoLedgerError)))

Internals

selectCoin Source #

Arguments

:: Eq a 
=> [(a, Value)]

Possible inputs to choose from

-> Value

The target value

-> Either BalancingError ([a], Value)

The chosen inputs and the change

Given a set of as with coin values, and a target value, select a number of a such that their total value is greater than or equal to the target.