From 85a4741dcb32999a265f879327c1b56c31e307c8 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Fri, 30 Aug 2024 11:02:52 -0500 Subject: [PATCH] fix: decode unified addresses with no transparent receivers ensures that a unified address that does not contain a transparent receiver is properly represented in the type --- CHANGELOG.md | 6 ++++++ src/ZcashHaskell/Orchard.hs | 4 ++-- test/Spec.hs | 2 +- zcash-haskell.cabal | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d7630c..6a1a508 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.6.2.3] + +### Fixed + +- Decoding of unified addresses with no transparent receivers + ## [0.6.2.2] - Added JSON instances for `ZcashNet` diff --git a/src/ZcashHaskell/Orchard.hs b/src/ZcashHaskell/Orchard.hs index 145c503..6bfe0c4 100644 --- a/src/ZcashHaskell/Orchard.hs +++ b/src/ZcashHaskell/Orchard.hs @@ -103,9 +103,9 @@ isValidUnifiedAddress str = (if BS.length (raw_s x) == 43 then Just $ SaplingReceiver (raw_s x) else Nothing) - (if not (BS.null (raw_t x)) + (if BS.length (raw_t x) > 1 then Just $ TransparentReceiver P2PKH (fromRawBytes $ raw_t x) - else if not (BS.null (raw_to x)) + else if BS.length (raw_to x) > 1 then Just $ TransparentReceiver P2SH (fromRawBytes $ raw_to x) else Nothing) diff --git a/test/Spec.hs b/test/Spec.hs index 7b0aac0..67ca3ce 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1143,7 +1143,7 @@ main = do case exch of Nothing -> assertFailure "Failed to encode Exchange address" Just addr -> do - let eadr = decodeExchangeAddress addr + let eadr = decodeExchangeAddress (E.encodeUtf8 addr) eadr `shouldNotBe` Nothing describe "Witness updates" $ do it "Sapling" $ do diff --git a/zcash-haskell.cabal b/zcash-haskell.cabal index 33c6140..b521e58 100644 --- a/zcash-haskell.cabal +++ b/zcash-haskell.cabal @@ -5,7 +5,7 @@ cabal-version: 3.0 -- see: https://github.com/sol/hpack name: zcash-haskell -version: 0.6.2.2 +version: 0.6.2.3 synopsis: Utilities to interact with the Zcash blockchain description: Please see the README on the repo at category: Blockchain