diff --git a/CHANGELOG.md b/CHANGELOG.md index cf7b6d7..24814be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ 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.1] + +### Changed + +- Modified the parsing of raw transactions for shielded outputs +- Upgraded to GHC 9.6.5 + +## [0.6.2.0] + +### Changed + +- Performance enhancement for transaction creation + ## [0.6.1.1] ### Added diff --git a/cabal.project b/cabal.project index 989ae5a..1f0bf49 100644 --- a/cabal.project +++ b/cabal.project @@ -1,6 +1,6 @@ packages: ./*.cabal -with-compiler: ghc-9.4.8 +with-compiler: ghc-9.6.5 source-repository-package type: git diff --git a/cabal.project.freeze b/cabal.project.freeze index 5cf3ed7..b5bd80f 100644 --- a/cabal.project.freeze +++ b/cabal.project.freeze @@ -1,40 +1,40 @@ active-repositories: hackage.haskell.org:merge -constraints: any.Cabal ==3.8.1.0, - any.Cabal-syntax ==3.8.1.0, +constraints: any.Cabal ==3.10.3.0, + any.Cabal-syntax ==3.10.3.0, any.HUnit ==1.6.2.0, - any.OneTuple ==0.4.1.1, + any.OneTuple ==0.4.2, any.QuickCheck ==2.14.3, QuickCheck -old-random +templatehaskell, any.StateVar ==1.2.2, - any.aeson ==2.2.1.0, + any.aeson ==2.2.3.0, aeson +ordered-keymap, any.alex ==3.5.1.0, - any.ansi-terminal ==1.1, + any.ansi-terminal ==1.1.1, ansi-terminal -example, any.ansi-terminal-types ==1.1, any.appar ==0.1.8, - any.array ==0.5.4.0, + any.array ==0.5.6.0, any.asn1-encoding ==0.9.6, any.asn1-parse ==0.9.5, any.asn1-types ==0.3.4, - any.assoc ==1.1, - assoc +tagged, + any.assoc ==1.1.1, + assoc -tagged, any.async ==2.2.5, async -bench, any.attoparsec ==0.14.4, attoparsec -developer, - any.attoparsec-aeson ==2.2.0.1, - any.base ==4.17.2.1, - any.base-orphans ==0.9.1, + any.attoparsec-aeson ==2.2.2.0, + any.base ==4.18.2.1, + any.base-orphans ==0.9.2, any.base16 ==1.0, any.base16-bytestring ==1.0.2.0, any.base58-bytestring ==0.1.0, any.base64-bytestring ==1.2.1.0, any.basement ==0.0.16, - any.bifunctors ==5.6.1, + any.bifunctors ==5.6.2, bifunctors +tagged, any.binary ==0.8.9.1, - any.binary-orphans ==1.0.4.1, + any.binary-orphans ==1.0.5, any.bitvec ==1.1.5.0, bitvec +simd, any.blaze-builder ==0.4.2.3, @@ -50,6 +50,7 @@ constraints: any.Cabal ==3.8.1.0, cborg +optimize-gmp, any.cereal ==0.5.8.3, cereal -bytestring-builder, + any.character-ps ==0.1, any.colour ==2.3.6, any.comonad ==5.0.8, comonad +containers +distributive +indexed-traversable, @@ -59,10 +60,10 @@ constraints: any.Cabal ==3.8.1.0, any.contravariant ==1.5.5, contravariant +semigroups +statevar +tagged, any.cookie ==0.5.0, - any.crypton ==0.34, + any.crypton ==1.0.0, crypton -check_alignment +integer-gmp -old_toolchain_inliner +support_aesni +support_deepseq +support_pclmuldq +support_rdrand -support_sse +use_target_attributes, - any.crypton-connection ==0.3.2, - any.crypton-x509 ==1.7.6, + any.crypton-connection ==0.4.1, + any.crypton-x509 ==1.7.7, any.crypton-x509-store ==1.6.9, any.crypton-x509-system ==1.6.7, any.crypton-x509-validation ==1.6.12, @@ -73,49 +74,47 @@ constraints: any.Cabal ==3.8.1.0, any.data-default-instances-containers ==0.0.1, any.data-default-instances-dlist ==0.0.1, any.data-default-instances-old-locale ==0.0.1, - any.data-fix ==0.3.2, - any.deepseq ==1.4.8.0, - any.directory ==1.3.7.1, + any.data-fix ==0.3.3, + any.deepseq ==1.4.8.1, + any.directory ==1.3.8.4, any.distributive ==0.6.2.1, distributive +semigroups +tagged, any.dlist ==1.0, dlist -werror, any.entropy ==0.4.1.10, entropy -donotgetentropy, - any.envy ==2.1.2.0, - any.exceptions ==0.10.5, - any.filepath ==1.4.2.2, - any.foldable1-classes-compat ==0.1, - foldable1-classes-compat +tagged, + any.envy ==2.1.3.0, + any.exceptions ==0.10.7, + any.filepath ==1.4.300.1, any.foreign-rust ==0.1.0, any.generically ==0.1.1, any.generics-sop ==0.5.1.4, any.ghc-bignum ==1.3, - any.ghc-boot-th ==9.4.8, - any.ghc-prim ==0.9.1, + any.ghc-boot-th ==9.6.5, + any.ghc-prim ==0.10.0, any.half ==0.3.1, any.happy ==1.20.1.1, - any.hashable ==1.4.3.0, - hashable +integer-gmp -random-initial-seed, + any.hashable ==1.4.7.0, + hashable -arch-native +integer-gmp -random-initial-seed, any.haskell-lexer ==1.1.1, - any.haskoin-core ==1.0.4, + any.haskoin-core ==1.1.0, any.hexstring ==0.12.1.0, any.hourglass ==0.2.12, any.hsc2hs ==0.68.10, hsc2hs -in-ghc-tree, - any.hspec ==2.11.7, - any.hspec-core ==2.11.7, - any.hspec-discover ==2.11.7, + any.hspec ==2.11.9, + any.hspec-core ==2.11.9, + any.hspec-discover ==2.11.9, any.hspec-expectations ==0.8.4, - any.http-client ==0.7.16, + any.http-client ==0.7.17, http-client +network-uri, any.http-client-tls ==0.3.6.3, any.http-conduit ==2.3.8.3, http-conduit +aeson, any.http-types ==0.12.4, - any.indexed-traversable ==0.1.3, - any.indexed-traversable-instances ==0.1.1.2, - any.integer-conversion ==0.1.0.1, + any.indexed-traversable ==0.1.4, + any.indexed-traversable-instances ==0.1.2, + any.integer-conversion ==0.1.1, any.integer-gmp ==1.1, any.integer-logarithms ==1.0.3.1, integer-logarithms -check-bounds +integer-gmp, @@ -126,19 +125,21 @@ constraints: any.Cabal ==3.8.1.0, memory +support_bytestring +support_deepseq, any.mime-types ==0.1.2.0, any.mono-traversable ==1.0.17.0, - any.mtl ==2.2.2, + any.mtl ==2.3.1, any.murmur3 ==1.0.5, - any.network ==3.1.4.0, + any.network ==3.2.1.0, network -devel, any.network-uri ==2.6.4.2, any.old-locale ==1.0.0.7, any.old-time ==1.1.0.4, + any.os-string ==2.0.6, any.parsec ==3.1.16.1, any.pem ==0.2.4, any.pretty ==1.1.3.6, any.primitive ==0.9.0.0, - any.process ==1.6.18.0, + any.process ==1.6.19.0, any.quickcheck-io ==0.2.0, + any.quickcheck-transformer ==0.3.1.2, any.random ==1.2.1.2, any.regex-base ==0.94.0.2, any.regex-compat ==0.95.2.1, @@ -147,12 +148,12 @@ constraints: any.Cabal ==3.8.1.0, any.resourcet ==1.3.0, any.rts ==1.0.2, any.safe ==0.3.21, - any.scientific ==0.3.7.0, - scientific -bytestring-builder -integer-simple, - any.secp256k1-haskell ==1.1.0, - any.semialign ==1.3, + any.scientific ==0.3.8.0, + scientific -integer-simple, + any.secp256k1-haskell ==1.2.0, + any.semialign ==1.3.1, semialign +semigroupoids, - any.semigroupoids ==6.0.0.1, + any.semigroupoids ==6.0.1, semigroupoids +comonad +containers +contravariant +distributive +tagged +unordered-containers, any.serialise ==0.2.6.1, serialise +newtime15, @@ -168,40 +169,39 @@ constraints: any.Cabal ==3.8.1.0, any.string-conversions ==0.4.0.1, any.tagged ==0.8.8, tagged +deepseq +transformers, - any.template-haskell ==2.19.0.0, + any.template-haskell ==2.20.0.0, any.text ==2.0.2, - any.text-iso8601 ==0.1, - any.text-short ==0.1.5, + any.text-iso8601 ==0.1.1, + any.text-short ==0.1.6, text-short -asserts, any.tf-random ==0.5, - any.th-abstraction ==0.6.0.0, - any.th-compat ==0.1.4, - any.these ==1.2, + any.th-abstraction ==0.7.0.0, + any.th-compat ==0.1.5, + any.these ==1.2.1, any.time ==1.12.2, - any.time-compat ==1.9.6.1, - time-compat -old-locale, - any.tls ==2.0.1, + any.time-compat ==1.9.7, + any.tls ==2.1.0, tls -devel, - any.transformers ==0.5.6.2, + any.transformers ==0.6.1.0, any.transformers-compat ==0.7.2, transformers-compat -five +five-three -four +generic-deriving +mtl -three -two, any.typed-process ==0.2.11.1, - any.unix ==2.7.3, - any.unix-time ==0.4.12, + any.unix ==2.8.4.0, + any.unix-time ==0.4.15, any.unliftio-core ==0.2.1.0, any.unordered-containers ==0.2.20, unordered-containers -debug, any.utf8-string ==1.0.2, - any.uuid-types ==1.0.5.1, + any.uuid-types ==1.0.6, any.vector ==0.13.1.0, vector +boundschecks -internalchecks -unsafechecks -wall, - any.vector-algorithms ==0.9.0.1, + any.vector-algorithms ==0.9.0.2, vector-algorithms +bench +boundschecks -internalchecks -llvm +properties -unsafechecks, any.vector-stream ==0.1.0.1, any.void ==0.7.3, void -safe, any.wide-word ==0.1.6.0, - any.witherable ==0.4.2, - any.zlib ==0.7.0.0, + any.witherable ==0.5, + any.zlib ==0.7.1.0, zlib -bundled-c-zlib +non-blocking-ffi +pkg-config -index-state: hackage.haskell.org 2024-03-06T20:26:39Z +index-state: hackage.haskell.org 2024-07-01T20:28:56Z diff --git a/src/ZcashHaskell/Sapling.hs b/src/ZcashHaskell/Sapling.hs index 5ba501e..ad7cd01 100644 --- a/src/ZcashHaskell/Sapling.hs +++ b/src/ZcashHaskell/Sapling.hs @@ -95,12 +95,35 @@ instance FromJSON RawTxResponse where c <- obj .: "confirmations" b <- obj .: "blocktime" sSpend <- obj .: "vShieldedSpend" + sOut <- obj .: "vShieldedOutput" case o of Nothing -> - pure $ RawTxResponse i h sSpend (getShieldedOutputs h) [] ht c b + pure $ + RawTxResponse + i + h + sSpend + (if not (null (sOut :: [Object])) + then getShieldedOutputs h + else []) + [] + ht + c + b Just o' -> do a <- o' .: "actions" - pure $ RawTxResponse i h sSpend (getShieldedOutputs h) a ht c b + pure $ + RawTxResponse + i + h + sSpend + (if not (null sOut) + then getShieldedOutputs h + else []) + a + ht + c + b -- | Attempt to decode the given raw tx with the given Sapling spending key decodeSaplingOutputEsk :: diff --git a/src/ZcashHaskell/Utils.hs b/src/ZcashHaskell/Utils.hs index 59b38ed..0f67ed7 100644 --- a/src/ZcashHaskell/Utils.hs +++ b/src/ZcashHaskell/Utils.hs @@ -136,22 +136,25 @@ createTransaction :: -> Bool -- ^ True to build, False to estimate fee -> Either TxError HexString createTransaction sapAnchor orchAnchor tSpend sSpend oSpend outgoing sParams oParams znet bh build = - if BS.length (hexBytes txResult) > 1 - then Right txResult - else case head (BS.unpack $ hexBytes txResult) of - 0 -> Left InsufficientFunds - 1 -> Left ChangeRequired - 2 -> Left Fee - 3 -> Left Balance - 4 -> Left TransparentBuild - 5 -> Left SaplingBuild - 6 -> Left OrchardBuild - 7 -> Left OrchardSpend - 8 -> Left OrchardRecipient - 9 -> Left SaplingBuilderNotAvailable - 10 -> Left OrchardBuilderNotAvailable - _ -> Left ZHError + processResult $! txResult where + processResult :: HexString -> Either TxError HexString + processResult input = + if BS.length (hexBytes input) > 1 + then Right input + else case head (BS.unpack $ hexBytes input) of + 0 -> Left InsufficientFunds + 1 -> Left ChangeRequired + 2 -> Left Fee + 3 -> Left Balance + 4 -> Left TransparentBuild + 5 -> Left SaplingBuild + 6 -> Left OrchardBuild + 7 -> Left OrchardSpend + 8 -> Left OrchardRecipient + 9 -> Left SaplingBuilderNotAvailable + 10 -> Left OrchardBuilderNotAvailable + _ -> Left ZHError txResult = withPureBorshVarBuffer $ rustWrapperCreateTx diff --git a/zcash-haskell.cabal b/zcash-haskell.cabal index 361d33e..27924ee 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.1.1 +version: 0.6.2.1 synopsis: Utilities to interact with the Zcash blockchain description: Please see the README on the repo at category: Blockchain @@ -58,7 +58,7 @@ library , binary , text , haskoin-core - , secp256k1-haskell + , secp256k1-haskell >= 1.1 , utf8-string build-tool-depends: c2hs:c2hs