cardano-ledger-alonzo-1.10.0.1: Cardano ledger introducing Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Ledger.Alonzo.UTxO

Synopsis

Documentation

class EraUTxO era ⇒ AlonzoEraUTxO era where Source #

Methods

getSupplementalDataHashesUTxO era → TxBody era → Set (DataHash (EraCrypto era)) Source #

Get data hashes for a transaction that are not required. Such datums are optional, but they can be added to the witness set. In a broaded terms datums corresponding to the inputs that might be spent are the required datums and the datums corresponding to the outputs and reference inputs are the supplemental datums.

getSpendingDatumUTxO era → Tx era → PlutusPurpose AsItem era → Maybe (Data era) Source #

Lookup the TxIn from the Spending ScriptPurpose and find the datum needed for spending that input. This function will return Nothing for all script purposes, except spending, because only spending scripts require an extra datum.

This is similar to getDatum function as in the spec:

  getDatum :: Tx era -> UTxO era -> ScriptPurpose era -> [Data era]

Instances

Instances details
Crypto c ⇒ AlonzoEraUTxO (AlonzoEra c) Source # 
Instance details

Defined in Cardano.Ledger.Alonzo.UTxO

getAlonzoSpendingDatum ∷ (AlonzoEraTxWits era, AlonzoEraTxOut era, EraTx era) ⇒ UTxO era → Tx era → PlutusPurpose AsItem era → Maybe (Data era) Source #

Get the Data associated with a ScriptPurpose. Only the Spending ScriptPurpose contains Data. Nothing is returned for the other kinds.

getAlonzoSpendingTxInAlonzoPlutusPurpose AsItem era → Maybe (TxIn (EraCrypto era)) Source #

Deprecated: In favor of more general toSpendingPurpose

Only the Spending ScriptPurpose contains TxIn

Scripts needed

newtype AlonzoScriptsNeeded era Source #

Alonzo era style ScriptsNeeded require also a PlutusPurpose, not only the ScriptHash

getAlonzoScriptsNeeded ∷ (MaryEraTxBody era, AlonzoEraScript era) ⇒ UTxO era → TxBody era → AlonzoScriptsNeeded era Source #

Uses of inputs in ‘txscripts’ and ‘neededScripts’ There are currently 3 sets of inputs (spending, collateral, reference). A particular TxInput can appear in more than one of the sets. Even in all three at the same, but that may not be a really useful case. Inputs are where you find scripts with the Spending purpose.

1) Collateral inputs are only spent if phase two fails. Their corresponding TxOut can only have Key (not Script) Pay credentials, so ‘neededScripts’ does not look there. 2) Reference inputs are not spent in the current Tx, unless that same input also appears in one of the other sets. If that is not the case, their credentials are never needed, so anyone can access the inline datums and scripts in their corresponding TxOut, without needing any authorizing credentials. So ‘neededScripts’ does not look there. 3) Spending inputs are always spent. So their Pay credentials are always needed.

Collect information (purpose and ScriptHash) about all the Credentials that refer to scripts that will be needed to run in a TxBody in the Utxow rule. Note there may be credentials that cannot be run, so are not collected. In Babbage, reference inputs, fit that description. Purposes include 1) Spending (payment script credentials, but NOT staking scripts) in the Addr of a TxOut, pointed to by some input that needs authorization. Be sure (txBody ^. inputsTxBodyL) gets all such inputs. In some Eras there may be multiple sets of inputs, which ones should be included? Currently that is only the spending inputs. Because collateral inputs can only have key-locked credentials, and reference inputs are never authorized. That might not always be the case. 2) Rewarding (Withdrawals), 3) Minting (minted field), and 4) Certifying (Delegating) scripts.

getAlonzoScriptsNeeded is an aggregation of the needed Credentials referring to Scripts used in Utxow rule. The flip side of getAlonzoScriptsNeeded (which collects script hashes) is txscripts which finds the actual scripts. We maintain an invariant that every script credential refers to some actual script. This is tested in the test function validateMissingScripts in the Utxow rule.

zipAsIxItemFoldable f ⇒ f it → (AsIxItem Word32 it → c) → [c] Source #

Datums needed

getInputDataHashesTxBody ∷ (EraTxBody era, AlonzoEraTxOut era, AlonzoEraScript era) ⇒ UTxO era → TxBody era → ScriptsProvided era → (Set (DataHash (EraCrypto era)), Set (TxIn (EraCrypto era))) Source #

Compute two sets for all TwoPhase scripts in a Tx.

1) DataHashes for each Two phase Script in a TxIn that has a DataHash 2) TxIns that are TwoPhase scripts, and should have a DataHash but don't.

{ h | (_ → (a,_,h)) ∈ txins tx ◁ utxo, isNonNativeScriptAddress tx a}

WitsVKey needed

getAlonzoWitsVKeyNeeded ∷ ∀ era. (EraTx era, AlonzoEraTxBody era, ShelleyEraTxBody era) ⇒ CertState era → UTxO era → TxBody era → Set (KeyHash 'Witness (EraCrypto era)) Source #

Just like getShelleyWitsVKeyNeeded, but also requires reqSignerHashesTxBodyL.

Orphan instances