From 774e135aabc0f5cddae76d93d7a80f8786e46f4e Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Wed, 14 Aug 2024 12:32:48 -0500 Subject: [PATCH] Fix data type --- src/ZcashHaskell/Transparent.hs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/ZcashHaskell/Transparent.hs b/src/ZcashHaskell/Transparent.hs index 878a7d8..287fe99 100644 --- a/src/ZcashHaskell/Transparent.hs +++ b/src/ZcashHaskell/Transparent.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE OverloadedStrings #-} + -- Copyright 2022-2024 Vergara Technologies LLC -- -- This file is part of Zcash-Haskell. @@ -172,27 +174,27 @@ decodeTransparentAddress taddress = do -- | Encode an Exchange Addresss into HRF from TransparentReceiver encodeExchangeAddress :: ZcashNet -> TransparentReceiver -> Maybe T.Text encodeExchangeAddress net tr = do - case (tr_type tr) of + case tr_type tr of P2PKH -> do case net of MainNet -> do - let vhash = encodeBech32m (BC.pack "tex") (toBytes (tr_bytes tr)) + let vhash = encodeBech32m "tex" (toBytes (tr_bytes tr)) Just vhash TestNet -> do - let vhash = encodeBech32m (BC.pack "textest") (toBytes (tr_bytes tr)) + let vhash = encodeBech32m "textest" (toBytes (tr_bytes tr)) Just vhash - _ -> Nothing + _any -> Nothing -- | Decode an Exchange Address into a ExchangeAddress -decodeExchangeAddress :: T.Text -> Maybe ExchangeAddress +decodeExchangeAddress :: BS.ByteString -> Maybe ExchangeAddress decodeExchangeAddress ex = do - if (T.length ex) > 1 + if BS.length ex > 1 then do - let rawd = decodeBech32 (E.encodeUtf8 ex) - let tMain = BS.unpack (BC.pack "tex") - let tTest = BS.unpack (BC.pack "textest") - let tFail = BS.unpack (BC.pack "fail") - let hr = BS.unpack (hrp rawd) + let rawd = decodeBech32 ex + let tMain = "tex" + let tTest = "textest" + let tFail = "fail" + let hr = hrp rawd if hr /= tFail then do let transparentReceiver = bytes rawd