Safe Haskell | None |
---|---|
Language | Haskell98 |
Shelley.Spec.Ledger.UTxO
Contents
Description
This module defines the types and functions for a simple UTxO Ledger as specified in A Simplified Formal Specification of a UTxO Ledger.
Synopsis
- newtype UTxO era = UTxO {}
- txid :: forall era. TxBodyConstraints era => TxBody era -> TxId (Crypto era)
- txins :: HasField "inputs" (TxBody era) (Set (TxIn (Crypto era))) => TxBody era -> Set (TxIn (Crypto era))
- txinLookup :: TxIn (Crypto era) -> UTxO era -> Maybe (TxOut era)
- txouts :: (ShelleyBased era, HasField "outputs" (TxBody era) (StrictSeq (TxOut era))) => TxBody era -> UTxO era
- txup :: (ShelleyBased era, HasField "update" (TxBody era) (StrictMaybe (Update era))) => Tx era -> Maybe (Update era)
- balance :: ShelleyBased era => UTxO era -> Value era
- totalDeposits :: PParams era -> Map (KeyHash 'StakePool (Crypto era)) (PoolParams (Crypto era)) -> [DCert (Crypto era)] -> Coin
- makeWitnessVKey :: forall crypto kr. (Crypto crypto, DSignable crypto (Hash crypto EraIndependentTxBody)) => Hash crypto EraIndependentTxBody -> KeyPair kr crypto -> WitVKey 'Witness crypto
- makeWitnessesVKey :: forall crypto kr. (Crypto crypto, DSignable crypto (Hash crypto EraIndependentTxBody)) => Hash crypto EraIndependentTxBody -> [KeyPair kr crypto] -> Set (WitVKey 'Witness crypto)
- makeWitnessesFromScriptKeys :: (Crypto crypto, DSignable crypto (Hash crypto EraIndependentTxBody)) => Hash crypto EraIndependentTxBody -> Map (KeyHash kr crypto) (KeyPair kr crypto) -> Set (KeyHash kr crypto) -> Set (WitVKey 'Witness crypto)
- verifyWitVKey :: (Typeable kr, Crypto crypto, DSignable crypto (Hash crypto EraIndependentTxBody)) => Hash crypto EraIndependentTxBody -> WitVKey kr crypto -> Bool
- getScriptHash :: Addr crypto -> Maybe (ScriptHash crypto)
- scriptsNeeded :: (ShelleyBased era, HasField "certs" (TxBody era) (StrictSeq (DCert (Crypto era))), HasField "wdrls" (TxBody era) (Wdrl (Crypto era)), HasField "inputs" (TxBody era) (Set (TxIn (Crypto era)))) => UTxO era -> Tx era -> Set (ScriptHash (Crypto era))
- scriptCred :: Credential kr crypto -> Maybe (ScriptHash crypto)
- scriptStakeCred :: DCert crypto -> Maybe (ScriptHash crypto)
- txinsScript :: ShelleyBased era => Set (TxIn (Crypto era)) -> UTxO era -> Set (TxIn (Crypto era))
Primitives
The unspent transaction outputs.
Instances
Functions
txid :: forall era. TxBodyConstraints era => TxBody era -> TxId (Crypto era) Source #
Compute the id of a transaction.
txins :: HasField "inputs" (TxBody era) (Set (TxIn (Crypto era))) => TxBody era -> Set (TxIn (Crypto era)) Source #
Compute the UTxO inputs of a transaction.
txinLookup :: TxIn (Crypto era) -> UTxO era -> Maybe (TxOut era) Source #
Lookup a txin for a given UTxO collection
txouts :: (ShelleyBased era, HasField "outputs" (TxBody era) (StrictSeq (TxOut era))) => TxBody era -> UTxO era Source #
Compute the transaction outputs of a transaction.
txup :: (ShelleyBased era, HasField "update" (TxBody era) (StrictMaybe (Update era))) => Tx era -> Maybe (Update era) Source #
balance :: ShelleyBased era => UTxO era -> Value era Source #
Determine the total balance contained in the UTxO.
totalDeposits :: PParams era -> Map (KeyHash 'StakePool (Crypto era)) (PoolParams (Crypto era)) -> [DCert (Crypto era)] -> Coin Source #
Determine the total deposit amount needed. The block may (legitimately) contain multiple registration certificates for the same pool, where the first will be treated as a registration and any subsequent ones as re-registration. As such, we must only take a deposit for the first such registration.
Note that this is not an issue for key registrations since subsequent registration certificates would be invalid.
makeWitnessVKey :: forall crypto kr. (Crypto crypto, DSignable crypto (Hash crypto EraIndependentTxBody)) => Hash crypto EraIndependentTxBody -> KeyPair kr crypto -> WitVKey 'Witness crypto Source #
Create a witness for transaction
makeWitnessesVKey :: forall crypto kr. (Crypto crypto, DSignable crypto (Hash crypto EraIndependentTxBody)) => Hash crypto EraIndependentTxBody -> [KeyPair kr crypto] -> Set (WitVKey 'Witness crypto) Source #
Create witnesses for transaction
makeWitnessesFromScriptKeys :: (Crypto crypto, DSignable crypto (Hash crypto EraIndependentTxBody)) => Hash crypto EraIndependentTxBody -> Map (KeyHash kr crypto) (KeyPair kr crypto) -> Set (KeyHash kr crypto) -> Set (WitVKey 'Witness crypto) Source #
From a list of key pairs and a set of key hashes required for a multi-sig scripts, return the set of required keys.
verifyWitVKey :: (Typeable kr, Crypto crypto, DSignable crypto (Hash crypto EraIndependentTxBody)) => Hash crypto EraIndependentTxBody -> WitVKey kr crypto -> Bool Source #
Verify a transaction body witness
getScriptHash :: Addr crypto -> Maybe (ScriptHash crypto) Source #
Extract script hash from value address with script.
scriptsNeeded :: (ShelleyBased era, HasField "certs" (TxBody era) (StrictSeq (DCert (Crypto era))), HasField "wdrls" (TxBody era) (Wdrl (Crypto era)), HasField "inputs" (TxBody era) (Set (TxIn (Crypto era)))) => UTxO era -> Tx era -> Set (ScriptHash (Crypto era)) Source #
Computes the set of script hashes required to unlock the transcation inputs and the withdrawals.
scriptCred :: Credential kr crypto -> Maybe (ScriptHash crypto) Source #
scriptStakeCred :: DCert crypto -> Maybe (ScriptHash crypto) Source #