From 5f32fd1142d7741ca06c10c107b48fe2eae2828c Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 28 Sep 2023 15:17:41 -0500 Subject: [PATCH] Correct the Sapling decoding --- src/ZGoBackend.hs | 11 +++++++++-- stack.yaml.lock | 6 +++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ZGoBackend.hs b/src/ZGoBackend.hs index 887dfff..62eda60 100644 --- a/src/ZGoBackend.hs +++ b/src/ZGoBackend.hs @@ -1824,6 +1824,7 @@ scanTxNative pipe db nodeUser nodePwd = do unless (null keyOwnerList) $ do let ownerList = cast' . Doc <$> keyOwnerList let keyList = map (maybe "" oviewkey) ownerList + print keyList lastBlockData <- access pipe master db findBlock latestBlock <- getBlockInfo nodeUser nodePwd "-1" case latestBlock of @@ -1831,19 +1832,24 @@ scanTxNative pipe db nodeUser nodePwd = do Just lB -> do case cast' . Doc =<< lastBlockData of Nothing -> do + print "Getting blocks" blockList <- mapM (getBlockInfo nodeUser nodePwd . T.pack . show) [2243000 .. (bl_height lB)] + print "filtering blocks..." let filteredBlockList = filter filterBlock blockList + print "extracting txs from blocks..." let txIdList = concatMap extractTxs filteredBlockList + print "getting tx data from node..." txList <- mapM (getTxData nodeUser nodePwd) txIdList + print "filtering txs..." let filteredTxList = map fromJust $ filter filterTx txList + print "checking txs against keys..." mapM_ (checkTx filteredTxList) keyList Just lastBlock -> do let blockList' = [(bl_height lastBlock + 1) .. (bl_height lB)] print blockList' - print keyList where filterBlock :: Maybe BlockResponse -> Bool filterBlock b = maybe 0 bl_confirmations b >= 5 @@ -1872,9 +1878,10 @@ scanTxNative pipe db nodeUser nodePwd = do checkTx txList k = do if isValidSaplingViewingKey (E.encodeUtf8 k) then do + print "decoding Sapling tx" let decodedTxList = map - (decodeSaplingOutput (E.encodeUtf8 k)) + (decodeSaplingOutput (bytes (decodeBech32 $ E.encodeUtf8 k))) (concatMap rt_shieldedOutputs (filter (\x -> rt_shieldedOutputs x /= []) txList)) diff --git a/stack.yaml.lock b/stack.yaml.lock index 22a8d57..7ed10a7 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -16,15 +16,15 @@ packages: commit: 085c16fb21b9f856a435a3faab980e7e0b319341 git: https://github.com/reach-sh/haskell-hexstring.git - completed: - commit: a6a69ae4cc83f18228c20da6c1b34151c6ebd36e + commit: 697ce83f7c3db28e691ae0924c4857511aa96ac7 git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git name: zcash-haskell pantry-tree: - sha256: 73bc6593bfb26f61b63bf51206c8d9b1ecc51b78741df23d4940c9ff69c1aa05 + sha256: 5b3ed1888cf157fa7f0b5a73b60468a767635379b94c1e1a00b04f86b4013208 size: 1229 version: 0.2.0 original: - commit: a6a69ae4cc83f18228c20da6c1b34151c6ebd36e + commit: 697ce83f7c3db28e691ae0924c4857511aa96ac7 git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git - completed: commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05