Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This is a module that contains functionality that is not necessary for ledger operation, but is useful for testing as well as for downstream users of ledger
Synopsis
- setMinFeeTx ∷ EraTx era ⇒ PParams era → Tx era → Int → Tx era
- setMinFeeTxUtxo ∷ EraUTxO era ⇒ PParams era → Tx era → UTxO era → Tx era
- calcMinFeeTx ∷ ∀ era. EraUTxO era ⇒ UTxO era → PParams era → Tx era → Int → Coin
- calcMinFeeTxNativeScriptWits ∷ ∀ era. EraUTxO era ⇒ UTxO era → PParams era → Tx era → Set (KeyHash 'Witness (EraCrypto era)) → Coin
- estimateMinFeeTx ∷ ∀ era. EraTx era ⇒ PParams era → Tx era → Int → Int → Int → Coin
- addDummyWitsTx ∷ ∀ era. EraTx era ⇒ PParams era → Tx era → Int → [Attributes AddrAttributes] → Tx era
- setMinCoinTxOut ∷ EraTxOut era ⇒ PParams era → TxOut era → TxOut era
- ensureMinCoinTxOut ∷ EraTxOut era ⇒ PParams era → TxOut era → TxOut era
- setMinCoinTxOutWith ∷ EraTxOut era ⇒ (Coin → Coin → Bool) → PParams era → TxOut era → TxOut era
- boom ∷ HasCallStack ⇒ a
- integralToByteStringN ∷ (Integral i, Bits i) ⇒ Int → i → ByteString
- byteStringToNum ∷ (Bits i, Num i) ⇒ ByteString → i
Tx
∷ EraTx era | |
⇒ PParams era | |
→ Tx era | |
→ Int | Size in bytes of reference scripts present in this transaction |
→ Tx era |
Calculate and update the fee in the transaction until it has the smallest possible value according to the settings in the protocol parameters.
This function potentially changes the feeTxBodyL
field of the TxBody
, as such it
affects the hash of the body, which consequently invalidates all of the signature in
the attached witnesses.
∷ ∀ era. EraUTxO era | |
⇒ UTxO era | All TxOuts available for this transaction. In other words |
→ PParams era | The current protocol parameters. |
→ Tx era | The transaction. |
→ Int | Number of extra KeyHash witnesses that will be supplied for satisfying native scripts. It is impossible to know how many of these is required without knowing the actual witnesses supplied and the time when the transaction will be submitted. Therefore we put this burden on the user. This number can also be used to specify all of the redundant extra key witnesses that will be supplied. |
→ Coin | The required minimum fee. |
This is a more accurate version estimateMinFeeTx
that looks into transaction and
figures out how many and what kind of key witnesses this transaction needs. It requires
access to the portion of the UTxO
that is relevant for this transaction. The only
type of witnesses that it cannot figure out reliably is the witnesses needed for
satisfying native scripts included in the transaction. For this reason number of
witnesses needed for native scripts must be supplied as an extra argument.
Example
>>>
let relevantUtxo = txInsFilter utxo (tx ^. bodyTxL . allInputsTxBodyF)
>>>
calcMinFeeTx relevantUtxo pp tx 5
calcMinFeeTxNativeScriptWits Source #
∷ ∀ era. EraUTxO era | |
⇒ UTxO era | All TxOuts available for this transaction. In other words |
→ PParams era | The current protocol parameters. |
→ Tx era | The transaction. |
→ Set (KeyHash 'Witness (EraCrypto era)) | KeyHash witnesses that will be supplied for satisfying native scripts. It is impossible to know how many of these is required without knowing the actual witnesses supplied and the time when the transaction will be submitted. Therefore we put this burden on the user. |
→ Coin | The required minimum fee. |
Same as calcMinFeeTx
, except this function allows to specify hashes of key witnesses
that will be supplied, instead of their count. That is only useful whenever there is a
chance of some of the required witnesses being the same as the witnesses that will be
supplied for native scripts.
∷ ∀ era. EraTx era | |
⇒ PParams era | The current protocol parameters. |
→ Tx era | The transaction. |
→ Int | The number of key witnesses still to be added to the transaction. |
→ Int | The number of Byron key witnesses still to be added to the transaction. |
→ Int | The total size in bytes of reference scripts |
→ Coin | The required minimum fee. |
Estimate a minimum transaction fee for a transaction that does not yet have all of
the VKey
witnesses. This calculation is not very accurate in estimating Byron
witnesses, but it should work for the most part. If you have access to UTxO necessary
for the transaction that it is better and easier to use calcMinFeeTx
instead.
Since: 1.8.0
∷ ∀ era. EraTx era | |
⇒ PParams era | The current protocol parameters. |
→ Tx era | The transaction. |
→ Int | The number of key witnesses still to be added to the transaction. |
→ [Attributes AddrAttributes] | List of attributes from TxOuts with Byron addresses that are being spent |
→ Tx era | The required minimum fee. |
Create dummy witnesses and add them to the transaction
TxOut
setMinCoinTxOut ∷ EraTxOut era ⇒ PParams era → TxOut era → TxOut era Source #
Same as setMinCoinSizedTxOut
, except it doesn't require the size of the
TxOut and will recompute it if needed. Initial amount is not important.
ensureMinCoinTxOut ∷ EraTxOut era ⇒ PParams era → TxOut era → TxOut era Source #
Similar to setMinCoinTxOut
it will guarantee that the minimum requirement for the
output amount is satisified, however it makes it possible to set a higher amount than
the minimaly required.
> ensureMinCoinTxOut pp (txOut & coinTxOutL .~ zero) == setMinCoinTxOut pp (txOut & coinTxOutL .~ zero) > (ensureMinCoinTxOut pp txOut ^. coinTxOutL) >= (setMinCoinTxOut pp txOut ^. coinTxOutL)
setMinCoinTxOutWith ∷ EraTxOut era ⇒ (Coin → Coin → Bool) → PParams era → TxOut era → TxOut era Source #
General tools
boom ∷ HasCallStack ⇒ a Source #
Warning: BOOM!
A helpful placeholder to use during development.
integralToByteStringN ∷ (Integral i, Bits i) ⇒ Int → i → ByteString Source #
byteStringToNum ∷ (Bits i, Num i) ⇒ ByteString → i Source #