Safe Haskell | None |
---|---|
Language | Haskell98 |
Hydra.Contract.Head
Synopsis
- type DatumType = State
- type RedeemerType = Input
- headValidator :: State -> Input -> ScriptContext -> Bool
- checkAbort :: ScriptContext -> CurrencySymbol -> [Party] -> Bool
- checkCollectCom :: ScriptContext -> (ContestationPeriod, [Party], CurrencySymbol) -> Bool
- commitDatum :: TxInfo -> TxOut -> Maybe Commit
- checkClose :: ScriptContext -> [Party] -> BuiltinByteString -> [Signature] -> ContestationPeriod -> CurrencySymbol -> Bool
- checkContest :: ScriptContext -> POSIXTime -> ContestationPeriod -> [Party] -> SnapshotNumber -> [Signature] -> [PubKeyHash] -> CurrencySymbol -> Bool
- checkFanout :: BuiltinByteString -> POSIXTime -> Integer -> ScriptContext -> Bool
- (&) :: a -> (a -> b) -> b
- txOutAdaValue :: TxOut -> Integer
- txInfoAdaFee :: TxInfo -> Integer
- makeContestationDeadline :: ContestationPeriod -> ScriptContext -> POSIXTime
- getHeadAddress :: ScriptContext -> Address
- mustBeSignedByParticipant :: ScriptContext -> CurrencySymbol -> Bool
- findParticipationTokens :: CurrencySymbol -> Value -> [TokenName]
- headOutputDatum :: ScriptContext -> Datum
- findTxOutDatum :: TxInfo -> TxOut -> Datum
- hashPreSerializedCommits :: [Commit] -> BuiltinByteString
- hashTxOuts :: [TxOut] -> BuiltinByteString
- hasPT :: CurrencySymbol -> TxOut -> Bool
- verifySnapshotSignature :: [Party] -> SnapshotNumber -> BuiltinByteString -> [Signature] -> Bool
- verifyPartySignature :: SnapshotNumber -> BuiltinByteString -> Party -> Signature -> Bool
- compareRef :: TxOutRef -> TxOutRef -> Ordering
- compiledValidator :: CompiledCode ValidatorType
- validatorScript :: SerialisedScript
- validatorHash :: ScriptHash
Documentation
type RedeemerType = Input #
headValidator :: State -> Input -> ScriptContext -> Bool #
checkAbort :: ScriptContext -> CurrencySymbol -> [Party] -> Bool #
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.
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 :: TxInfo -> TxOut -> Maybe Commit #
Try to find the commit datum in the input and if it is there return the commited utxo
checkClose :: ScriptContext -> [Party] -> BuiltinByteString -> [Signature] -> ContestationPeriod -> CurrencySymbol -> Bool #
The close validator must verify that:
- Check that the closing tx validity is bounded by contestation period
- Check that the deadline corresponds with tx validity and contestation period.
- The resulting utxo hash is correctly signed or the initial utxo hash, depending on snapshot number
- The transaction is performed (i.e. signed) by one of the head participants
- State token (ST) is present in the output
- Contesters must be initialize as empty
- Value in v_head is preserved
Arguments
:: ScriptContext | |
-> POSIXTime | |
-> ContestationPeriod | |
-> [Party] | |
-> SnapshotNumber | Snapshot number of the closed state. |
-> [Signature] | |
-> [PubKeyHash] | Keys of party member which already contested. |
-> CurrencySymbol | Head id |
-> Bool |
The contest validator must verify that:
- The transaction does not mint or burn tokens.
- The contest snapshot number is strictly greater than the closed snapshot number.
- The contest snapshot is correctly signed.
- The transaction is performed (i.e. signed) by one of the head participants
- Party can contest only once.
- The transaction is performed before the deadline.
- Add signer to list of contesters.
- State token (ST) is present in the output
- Push deadline if signer is not the last one to contest.
- No other parameters have changed.
- Value in v_head is preserved
checkFanout :: BuiltinByteString -> POSIXTime -> Integer -> ScriptContext -> Bool #
txOutAdaValue :: TxOut -> Integer #
txInfoAdaFee :: TxInfo -> Integer #
makeContestationDeadline :: ContestationPeriod -> ScriptContext -> POSIXTime #
getHeadAddress :: ScriptContext -> Address #
mustBeSignedByParticipant :: ScriptContext -> CurrencySymbol -> Bool #
findParticipationTokens :: CurrencySymbol -> Value -> [TokenName] #
headOutputDatum :: ScriptContext -> Datum #
findTxOutDatum :: TxInfo -> TxOut -> Datum #
hashPreSerializedCommits :: [Commit] -> BuiltinByteString #
Hash a potentially unordered list of commits by sorting them, concatenating
their preSerializedOutput
bytes and creating a SHA2_256 digest over that.
hashTxOuts :: [TxOut] -> BuiltinByteString #
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.
verifySnapshotSignature :: [Party] -> SnapshotNumber -> BuiltinByteString -> [Signature] -> Bool #
verifyPartySignature :: SnapshotNumber -> BuiltinByteString -> Party -> Signature -> Bool #
compareRef :: TxOutRef -> TxOutRef -> Ordering #
compiledValidator :: CompiledCode ValidatorType #
validatorScript :: SerialisedScript #
validatorHash :: ScriptHash #