Unified Address support #8

Merged
pitmutt merged 61 commits from dev18 into master 2023-10-28 12:24:28 +00:00
Showing only changes of commit fb436f1499 - Show all commits

View file

@ -17,6 +17,7 @@ import GHC.Generics
import Text.Megaparsec hiding (State) import Text.Megaparsec hiding (State)
import Text.Megaparsec.Char import Text.Megaparsec.Char
import ZcashHaskell.Orchard import ZcashHaskell.Orchard
import ZcashHaskell.Sapling (isValidShieldedAddress)
-- | Type to model a ZGo transaction -- | Type to model a ZGo transaction
data ZGoTx = ZGoTx data ZGoTx = ZGoTx
@ -133,9 +134,9 @@ pSaplingAddress :: Parser MemoToken
pSaplingAddress = do pSaplingAddress = do
string "zs" string "zs"
a <- some alphaNumChar a <- some alphaNumChar
if length a /= 76 if isValidShieldedAddress (E.encodeUtf8 $ "zs" <> T.pack a)
then fail "Failed to parse Sapling address" then pure $ Address $ T.pack ("zs" <> a)
else pure $ Address $ T.pack ("zs" <> a) else fail "Failed to parse Sapling address"
pUnifiedAddress :: Parser MemoToken pUnifiedAddress :: Parser MemoToken
pUnifiedAddress = do pUnifiedAddress = do