Skip to content

Commit

Permalink
Lookup head datum hash instead of hashing it on-chain
Browse files Browse the repository at this point in the history
  We actually can't hash it. Requires serialization + format translations.
  • Loading branch information
KtorZ committed Jan 18, 2022
1 parent 360f6dc commit dd72b36
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions hydra-plutus/src/Hydra/Contract/Head.hs
Expand Up @@ -118,11 +118,12 @@ headValidator _ commitAddress oldState input context =
traceIfFalse "committed value is not preserved in head" $
headOutputValue == collectedValue <> headInputValue

headOutputDatumHash = txOutDatumHash headOutput

checkOutputDatum =
traceIfFalse "unexpected output datum in collectCom" $
headOutputDatumHash == Just (datumHash $ Datum $ toBuiltinData expectedDatum)
fromMaybe False $ do
headOutputDatumHash <- txOutDatumHash headOutput
actualDatum <- findDatum headOutputDatumHash txInfo
pure (actualDatum == Datum (toBuiltinData expectedDatum))
in checkOutputValue && checkOutputDatum
[] -> traceIfFalse "No continuing head output" False
_ -> traceIfFalse "More than one continuing head output" False
Expand Down

0 comments on commit dd72b36

Please sign in to comment.