Skip to content

Commit

Permalink
Try some on-chain debugging, which does not work but almost.
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Jan 18, 2022
1 parent d857425 commit 075992b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion hydra-plutus/src/Hydra/Contract/Head.hs
Expand Up @@ -118,8 +118,20 @@ headValidator _ commitAddress oldState input context =
traceIfFalse "committed value is not preserved in head" $
headOutputValue == collectedValue <> headInputValue

checkOutputDatumError =
"unexpected output datum in collectCom, expected utxo hash: "
`appendByteString` utxoHash
`appendByteString` ", actual utxo hash: "
`appendByteString` actualUtxoHash

actualUtxoHash = fromMaybe "couldn't find actual hash?" $ do
headOutputDatumHash <- txOutDatumHash headOutput
actualDatum <- findDatum headOutputDatumHash txInfo
Open{utxoHash = actual} <- fromBuiltinData (getDatum actualDatum)
pure actual

checkOutputDatum =
traceIfFalse "unexpected output datum in collectCom" $
traceIfFalse (decodeUtf8 checkOutputDatumError) $
fromMaybe False $ do
headOutputDatumHash <- txOutDatumHash headOutput
actualDatum <- findDatum headOutputDatumHash txInfo
Expand Down

0 comments on commit 075992b

Please sign in to comment.