cardano-coin-selection-1.0.1: Algorithms for coin selection and fee balancing.
Copyright© 2018-2024 Intersect MBO
LicenseApache-2.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.CoinSelection.Algorithm.Migration

Description

This module contains an algorithm for migrating all funds from one wallet to another.

See selectCoins.

Synopsis

Coin Selection for Migration

selectCoins Source #

Arguments

:: forall i o. (Ord i, Ord o) 
=> FeeOptions i o

The fee options.

-> BatchSize

The maximum number of inputs to include in each selection.

-> CoinMap i

The UTxO set to migrate.

-> [CoinSelection i o] 

Creates a series of coin selections that, when published as transactions, will have the effect of migrating all funds from one wallet to another.

Since UTxO-based blockchains typically impose limits on the sizes of individual transactions, and since individual UTxO sets can contain arbitrarily many entries, migrating all funds from one wallet to another may require the creation of several transactions.

This function therefore partitions the given set of inputs into multiple batches of up to b inputs, where b is specified by the given BatchSize parameter. (See idealBatchSize for an automatic way to calculate a suitable batch size.)

For each batch of inputs, this function creates a separate CoinSelection with the given inputs and a generated change set, where the change set represents the value to be transferred to the target wallet, carefully adjusted to deduct a fee in accordance with the given FeeOptions parameter. The set of outputs for each coin selection is purposefully left empty, as all value is captured in the change set.

Since: 1.0.0

newtype BatchSize Source #

An upper limit for the number of inputs to include in each coin selection generated by selectCoins.

Since: 1.0.0

Constructors

BatchSize Word16 

Instances

Instances details
Generic BatchSize Source # 
Instance details

Defined in Cardano.CoinSelection.Algorithm.Migration

Associated Types

type Rep BatchSize :: Type -> Type Source #

Show BatchSize Source # 
Instance details

Defined in Cardano.CoinSelection.Algorithm.Migration

Eq BatchSize Source # 
Instance details

Defined in Cardano.CoinSelection.Algorithm.Migration

Ord BatchSize Source # 
Instance details

Defined in Cardano.CoinSelection.Algorithm.Migration

type Rep BatchSize Source # 
Instance details

Defined in Cardano.CoinSelection.Algorithm.Migration

type Rep BatchSize = D1 ('MetaData "BatchSize" "Cardano.CoinSelection.Algorithm.Migration" "cardano-coin-selection-1.0.1-inplace" 'True) (C1 ('MetaCons "BatchSize" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word16)))

idealBatchSize :: CoinSelectionLimit -> BatchSize Source #

Calculate an ideal batch size based on the given coin selection limit.

Since: 1.0.0