diff --git a/src/ZcashHaskell/Sapling.hs b/src/ZcashHaskell/Sapling.hs index ffec5f8..f5a7c43 100644 --- a/src/ZcashHaskell/Sapling.hs +++ b/src/ZcashHaskell/Sapling.hs @@ -48,12 +48,21 @@ instance FromJSON RawTxResponse where parseJSON = withObject "RawTxResponse" $ \obj -> do i <- obj .: "txid" - o <- obj .: "orchard" + o <- obj .:? "orchard" h <- obj .: "hex" - a <- o .: "actions" - pure $ - RawTxResponse - i - (decodeHexText h) - (getShieldedOutputs (decodeHexText h)) - a + case o of + Nothing -> + pure $ + RawTxResponse + i + (decodeHexText h) + (getShieldedOutputs (decodeHexText h)) + [] + Just o' -> do + a <- o' .: "actions" + pure $ + RawTxResponse + i + (decodeHexText h) + (getShieldedOutputs (decodeHexText h)) + a