From 5594fe101946980a9c50e01e7ae4708a5fe27004 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Thu, 12 Nov 2020 08:08:13 +0000 Subject: [PATCH] Improve lovelace parser failure in the cli --- cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs b/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs index ce1fecd7bf6..890b9de354c 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs @@ -2192,7 +2192,11 @@ pProtocolVersion = -- parseLovelace :: Atto.Parser Lovelace -parseLovelace = Lovelace <$> Atto.decimal +parseLovelace = do + i <- Atto.decimal + if i > toInteger (maxBound :: Word64) + then fail $ show i <> " lovelace exceeds the Word64 upper bound" + else return $ Lovelace i parseAddress :: Atto.Parser (Address Shelley) parseAddress = do