rvv040 - decodeExchangeAddress modified to return an ExcahngeAddress object

This commit is contained in:
Rene V. Vergara A. 2024-04-18 08:30:14 -04:00
parent 1b2c6dce24
commit ebfac8438f
2 changed files with 6 additions and 6 deletions

View File

@ -159,8 +159,8 @@ encodeExchangeAddress net tr = do
Just vhash Just vhash
_ -> Nothing _ -> Nothing
-- | Decode an Exchange Address into a TransparentAddress -- | Decode an Exchange Address into a ExchangeAddress
decodeExchangeAddress:: T.Text-> Maybe TransparentAddress decodeExchangeAddress:: T.Text-> Maybe ExchangeAddress
decodeExchangeAddress ex = do decodeExchangeAddress ex = do
if (T.length ex ) > 1 if (T.length ex ) > 1
then do then do
@ -174,12 +174,12 @@ decodeExchangeAddress ex = do
let transparentReceiver = bytes rawd let transparentReceiver = bytes rawd
if hr == tMain if hr == tMain
then Just $ then Just $
TransparentAddress MainNet $ ExchangeAddress MainNet $
TransparentReceiver P2PKH (fromRawBytes transparentReceiver) TransparentReceiver P2PKH (fromRawBytes transparentReceiver)
else do else do
if hr == tTest if hr == tTest
then Just $ then Just $
TransparentAddress TestNet $ ExchangeAddress TestNet $
TransparentReceiver P2PKH (fromRawBytes transparentReceiver) TransparentReceiver P2PKH (fromRawBytes transparentReceiver)
else Nothing else Nothing
else Nothing else Nothing

View File

@ -1081,8 +1081,8 @@ main = do
case exch of case exch of
Nothing -> assertFailure "Failed to encode Exchange address" Nothing -> assertFailure "Failed to encode Exchange address"
Just addr -> do Just addr -> do
let tadr = decodeExchangeAddress addr let eadr = decodeExchangeAddress addr
tadr `shouldNotBe` Nothing eadr `shouldNotBe` Nothing
-- | Properties -- | Properties
prop_PhraseLength :: Property prop_PhraseLength :: Property