Copyright | © 2018-2024 Intersect MBO |
---|---|
License | Apache-2.0 |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module contains an algorithm for migrating all funds from one wallet to another.
See selectCoins
.
Synopsis
- selectCoins :: forall i o. (Ord i, Ord o) => FeeOptions i o -> BatchSize -> CoinMap i -> [CoinSelection i o]
- newtype BatchSize = BatchSize Word16
- idealBatchSize :: CoinSelectionLimit -> BatchSize
Coin Selection for Migration
:: 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
An upper limit for the number of inputs
to include in each coin selection
generated by selectCoins
.
Since: 1.0.0
Instances
Generic BatchSize Source # | |
Show BatchSize Source # | |
Eq BatchSize Source # | |
Ord BatchSize Source # | |
Defined in Cardano.CoinSelection.Algorithm.Migration | |
type Rep BatchSize Source # | |
Defined in Cardano.CoinSelection.Algorithm.Migration |
idealBatchSize :: CoinSelectionLimit -> BatchSize Source #
Calculate an ideal batch size based on the given coin selection limit.
Since: 1.0.0