hydra-plutus-0.19.0: Hydra Plutus Contracts
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Contract.Head

Synopsis

Documentation

headValidator :: State -> Input -> ScriptContext -> Bool Source #

checkAbort :: ScriptContext -> CurrencySymbol -> [Party] -> Bool Source #

On-Chain verification for Abort transition. It verifies that:

  • All PTs have been burnt: The right number of Head tokens with the correct head id are burnt, one PT for each party and a state token ST.
  • All committed funds have been redistributed. This is done via v_commit and it only needs to ensure that we have spent all comitted outputs, which follows from burning all the PTs.

checkCollectCom Source #

Arguments

:: ScriptContext

Script execution context

-> (ContestationPeriod, [Party], CurrencySymbol) 
-> Bool 

On-Chain verification for CollectCom transition. It verifies that:

  • All participants have committed (even empty commits)
  • All commits are properly collected and locked into η as a hash of serialized tx outputs in the same sequence as commit inputs!
  • The transaction is performed (i.e. signed) by one of the head participants
  • State token (ST) is present in the output

commitDatum :: TxOut -> [Commit] Source #

Try to find the commit datum in the input and if it is there return the committed utxo

checkDecrement Source #

Arguments

:: ScriptContext 
-> OpenDatum

Open state before the decrement

-> DecrementRedeemer 
-> Bool 

Verify a decrement transaction.

checkClose Source #

Arguments

:: ScriptContext 
-> OpenDatum

Open state before the close

-> CloseRedeemer

Type of close transition.

-> Bool 

Verify a close transaction.

checkContest Source #

Arguments

:: ScriptContext 
-> ClosedDatum

Closed state before the close

-> ContestRedeemer

Type of contest transition.

-> Bool 

Verify a contest transaction.

checkFanout Source #

Arguments

:: ScriptContext 
-> ClosedDatum

Closed state before the fanout

-> Integer

Number of normal outputs to fanout

-> Integer

Number of delta outputs to fanout

-> Bool 

Verify a fanout transaction.

(&) :: a -> (a -> b) -> b Source #

makeContestationDeadline :: ContestationPeriod -> ScriptContext -> POSIXTime Source #

getHeadInput :: ScriptContext -> TxInInfo Source #

getHeadAddress :: ScriptContext -> Address Source #

mustNotChangeParameters :: ([Party], [Party]) -> (ContestationPeriod, ContestationPeriod) -> (CurrencySymbol, CurrencySymbol) -> Bool Source #

mustBeSignedByParticipant :: ScriptContext -> CurrencySymbol -> Bool Source #

findParticipationTokens :: CurrencySymbol -> Value -> [TokenName] Source #

headOutputDatum :: ScriptContext -> Datum Source #

getTxOutDatum :: TxOut -> Datum Source #

hashPreSerializedCommits :: [Commit] -> BuiltinByteString Source #

Hash a potentially unordered list of commits by sorting them, concatenating their preSerializedOutput bytes and creating a SHA2_256 digest over that.

NOTE: See note from hashTxOuts.

hashTxOuts :: [TxOut] -> BuiltinByteString Source #

Hash a pre-ordered list of transaction outputs by serializing each individual TxOut, concatenating all bytes together and creating a SHA2_256 digest over that.

NOTE: In general, from asserting that `hash(x || y) = hash (x' || y')` it is not safe to conclude that `(x,y) = (x', y')` as the same hash could be obtained by moving one or more bytes from the end of x to the beginning of y, but in the context of Hydra validators it seems impossible to exploit this property without breaking other logic or verification (eg. producing a valid and meaningful TxOut).

hasPT :: CurrencySymbol -> TxOut -> Bool Source #

Check if TxOut contains the PT token.

verifySnapshotSignature :: [Party] -> (CurrencySymbol, SnapshotVersion, SnapshotNumber, Hash, Hash) -> [Signature] -> Bool Source #

Verify the multi-signature of a snapshot using given constituents State, ClosedDatum, number, ClosedDatum and utxoToDecommitHash. See 'SignableRepresentation Snapshot' for more details.

verifyPartySignature :: (CurrencySymbol, SnapshotVersion, SnapshotNumber, Hash, Hash) -> Party -> Signature -> Bool Source #

Verify individual party signature of a snapshot. See 'SignableRepresentation Snapshot' for more details.

compareRef :: TxOutRef -> TxOutRef -> Ordering Source #

compiledValidator :: CompiledCode ValidatorType Source #

validatorScript :: SerialisedScript Source #

validatorHash :: ScriptHash Source #