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 CoinSelectionError ∷ Type → Type 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 ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxOutValue ERA))) :+: C1 ('MetaCons "BodyError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) :+: (C1 ('MetaCons "NotEnoughAdaOnlyOutputsFor" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe 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 BalancingError ∷ Type → Type 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 ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "CheckMinUtxoValueError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxOut CtxTx BabbageEra)) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Lovelace))) :+: (C1 ('MetaCons "BalanceCheckError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BalancingError)) :+: C1 ('MetaCons "ComputeBalanceChangeError" 'PrefixI 'False) (U1 ∷ Type → Type)))

balanceForWallet ∷ (MonadBlockchain m, MonadFail m) ⇒ Wallet → UtxoSet 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) ⇒ Wallet → UtxoSet CtxUTxO a → TxOut CtxTx BabbageEra → TxBodyContent 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.

signForWallet ∷ Wallet → BalancedTxBody ERA → Tx ERA Source #

Sign a transaction with the wallet's key

Balance changes

balanceChanges ∷ UTxO ERA → TxBodyContent BuildTx ERA → Maybe 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.