Correct the Sapling decoding

This commit is contained in:
Rene Vergara 2023-09-28 15:17:41 -05:00
parent ae5606f4be
commit 5f32fd1142
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2
2 changed files with 12 additions and 5 deletions

View file

@ -1824,6 +1824,7 @@ scanTxNative pipe db nodeUser nodePwd = do
unless (null keyOwnerList) $ do unless (null keyOwnerList) $ do
let ownerList = cast' . Doc <$> keyOwnerList let ownerList = cast' . Doc <$> keyOwnerList
let keyList = map (maybe "" oviewkey) ownerList let keyList = map (maybe "" oviewkey) ownerList
print keyList
lastBlockData <- access pipe master db findBlock lastBlockData <- access pipe master db findBlock
latestBlock <- getBlockInfo nodeUser nodePwd "-1" latestBlock <- getBlockInfo nodeUser nodePwd "-1"
case latestBlock of case latestBlock of
@ -1831,19 +1832,24 @@ scanTxNative pipe db nodeUser nodePwd = do
Just lB -> do Just lB -> do
case cast' . Doc =<< lastBlockData of case cast' . Doc =<< lastBlockData of
Nothing -> do Nothing -> do
print "Getting blocks"
blockList <- blockList <-
mapM mapM
(getBlockInfo nodeUser nodePwd . T.pack . show) (getBlockInfo nodeUser nodePwd . T.pack . show)
[2243000 .. (bl_height lB)] [2243000 .. (bl_height lB)]
print "filtering blocks..."
let filteredBlockList = filter filterBlock blockList let filteredBlockList = filter filterBlock blockList
print "extracting txs from blocks..."
let txIdList = concatMap extractTxs filteredBlockList let txIdList = concatMap extractTxs filteredBlockList
print "getting tx data from node..."
txList <- mapM (getTxData nodeUser nodePwd) txIdList txList <- mapM (getTxData nodeUser nodePwd) txIdList
print "filtering txs..."
let filteredTxList = map fromJust $ filter filterTx txList let filteredTxList = map fromJust $ filter filterTx txList
print "checking txs against keys..."
mapM_ (checkTx filteredTxList) keyList mapM_ (checkTx filteredTxList) keyList
Just lastBlock -> do Just lastBlock -> do
let blockList' = [(bl_height lastBlock + 1) .. (bl_height lB)] let blockList' = [(bl_height lastBlock + 1) .. (bl_height lB)]
print blockList' print blockList'
print keyList
where where
filterBlock :: Maybe BlockResponse -> Bool filterBlock :: Maybe BlockResponse -> Bool
filterBlock b = maybe 0 bl_confirmations b >= 5 filterBlock b = maybe 0 bl_confirmations b >= 5
@ -1872,9 +1878,10 @@ scanTxNative pipe db nodeUser nodePwd = do
checkTx txList k = do checkTx txList k = do
if isValidSaplingViewingKey (E.encodeUtf8 k) if isValidSaplingViewingKey (E.encodeUtf8 k)
then do then do
print "decoding Sapling tx"
let decodedTxList = let decodedTxList =
map map
(decodeSaplingOutput (E.encodeUtf8 k)) (decodeSaplingOutput (bytes (decodeBech32 $ E.encodeUtf8 k)))
(concatMap (concatMap
rt_shieldedOutputs rt_shieldedOutputs
(filter (\x -> rt_shieldedOutputs x /= []) txList)) (filter (\x -> rt_shieldedOutputs x /= []) txList))

View file

@ -16,15 +16,15 @@ packages:
commit: 085c16fb21b9f856a435a3faab980e7e0b319341 commit: 085c16fb21b9f856a435a3faab980e7e0b319341
git: https://github.com/reach-sh/haskell-hexstring.git git: https://github.com/reach-sh/haskell-hexstring.git
- completed: - completed:
commit: a6a69ae4cc83f18228c20da6c1b34151c6ebd36e commit: 697ce83f7c3db28e691ae0924c4857511aa96ac7
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
name: zcash-haskell name: zcash-haskell
pantry-tree: pantry-tree:
sha256: 73bc6593bfb26f61b63bf51206c8d9b1ecc51b78741df23d4940c9ff69c1aa05 sha256: 5b3ed1888cf157fa7f0b5a73b60468a767635379b94c1e1a00b04f86b4013208
size: 1229 size: 1229
version: 0.2.0 version: 0.2.0
original: original:
commit: a6a69ae4cc83f18228c20da6c1b34151c6ebd36e commit: 697ce83f7c3db28e691ae0924c4857511aa96ac7
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
- completed: - completed:
commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05 commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05