convex-coin-selection-0.2.0.0: Coin selection algorithm for Cardano transactions
Safe HaskellSafe-Inferred
LanguageHaskell2010

Convex.CoinSelection

Description

Building cardano transactions from tx bodies

Synopsis

Data types

data CoinSelectionError Source #

Instances

Instances details
FromJSON CoinSelectionError Source # 
Instance details

Defined in Convex.CoinSelection

ToJSON CoinSelectionError Source # 
Instance details

Defined in Convex.CoinSelection

Generic CoinSelectionError Source # 
Instance details

Defined in Convex.CoinSelection

Associated Types

type Rep CoinSelectionErrorTypeType Source #

Show CoinSelectionError Source # 
Instance details

Defined in Convex.CoinSelection

type Rep CoinSelectionError Source # 
Instance details

Defined in Convex.CoinSelection

type Rep CoinSelectionError = D1 ('MetaData "CoinSelectionError" "Convex.CoinSelection" "convex-coin-selection-0.2.0.0-inplace" 'False) ((C1 ('MetaCons "UnsupportedBalance" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxOutValue ERA))) :+: C1 ('MetaCons "BodyError" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) :+: (C1 ('MetaCons "NotEnoughAdaOnlyOutputsFor" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Lovelace)) :+: C1 ('MetaCons "NotEnoughMixedOutputsFor" 'PrefixI 'True) (S1 ('MetaSel ('Just "valuesNeeded") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(PolicyId, AssetName, Quantity)]) :*: (S1 ('MetaSel ('Just "valueProvided") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value) :*: S1 ('MetaSel ('Just "txBalance") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)))))

data CSInputs Source #

Inputs needed for coin selection

Constructors

CSInputs 

Fields

Balancing

data BalancingError Source #

Instances

Instances details
FromJSON BalancingError Source # 
Instance details

Defined in Convex.CoinSelection

ToJSON BalancingError Source # 
Instance details

Defined in Convex.CoinSelection

Generic BalancingError Source # 
Instance details

Defined in Convex.CoinSelection

Associated Types

type Rep BalancingErrorTypeType Source #

Show BalancingError Source # 
Instance details

Defined in Convex.CoinSelection

type Rep BalancingError Source # 
Instance details

Defined in Convex.CoinSelection

type Rep BalancingError = D1 ('MetaData "BalancingError" "Convex.CoinSelection" "convex-coin-selection-0.2.0.0-inplace" 'False) ((C1 ('MetaCons "BalancingError" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "CheckMinUtxoValueError" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxOut CtxTx BabbageEra)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Lovelace))) :+: (C1 ('MetaCons "BalanceCheckError" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BalancingError)) :+: C1 ('MetaCons "ComputeBalanceChangeError" 'PrefixI 'False) (U1TypeType)))

balanceForWallet ∷ (MonadBlockchain m, MonadFail m) ⇒ WalletUtxoSet CtxUTxO a → TxBodyContent BuildTx ERA → m (Tx ERA, BalanceChanges) Source #

Balance the transaction using the wallet's funds, then sign it.

balanceForWalletReturn ∷ (MonadBlockchain m, MonadFail m) ⇒ WalletUtxoSet CtxUTxO a → TxOut CtxTx BabbageEraTxBodyContent BuildTx ERA → m (Tx ERA, BalanceChanges) Source #

Balance the transaction using the wallet's funds and the provided return output, then sign it.

balanceTx Source #

Arguments

∷ (MonadBlockchain m, MonadFail m) 
TxOut CtxTx BabbageEra

Return output used for leftover funds. This output will be used for balancing, and it will be added to the transaction IF the funds locked in it (after balancing) are non zero.

UtxoSet CtxUTxO a

Set of UTxOs that can be used to supply missing funds

TxBodyContent BuildTx ERA

The unbalanced transaction body

→ m (BalancedTxBody ERA, BalanceChanges)

The balanced transaction body and the balance changes (per address)

Balance the transaction using the given UTXOs and return address. This calls balanceTransactionBody after preparing all the required inputs.

signForWalletWalletBalancedTxBody ERATx ERA Source #

Sign a transaction with the wallet's key

Balance changes

balanceChangesUTxO ERATxBodyContent BuildTx ERAMaybe BalanceChanges Source #

Get the BalanceChanges for a tx body. Returns Nothing if a UTXO couldnt be found

Etc.

prepCSInputs Source #

Arguments

MonadBlockchain m 
TxOut CtxTx BabbageEra

Change address

UTxO ERA

UTxOs that may be used for balancing

TxBodyContent BuildTx BabbageEra

Unbalanced transaction body

→ m CSInputs

Inputs for coin balancing

Take the tx body and produce a CSInputs value for coin selection, using the MonadBlockchain effect to query any missing UTxO information.