Improve decoding of Txs

This commit is contained in:
Rene Vergara 2023-10-03 11:07:01 -05:00
parent bf740857b3
commit 493d17abfd
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2

View file

@ -1881,8 +1881,8 @@ scanTxNative pipe db nodeUser nodePwd = do
if isValidSaplingViewingKey (E.encodeUtf8 k) if isValidSaplingViewingKey (E.encodeUtf8 k)
then do then do
print "decoding Sapling tx" print "decoding Sapling tx"
let decodedSapList' = map (decodeSaplingTx k) txList' let decodedSapList' = concatMap (decodeSaplingTx k) txList'
print decodedSapList' print $ filter isJust decodedSapList'
else do else do
let vk = decodeUfvk $ E.encodeUtf8 k let vk = decodeUfvk $ E.encodeUtf8 k
case vk of case vk of
@ -1895,26 +1895,18 @@ scanTxNative pipe db nodeUser nodePwd = do
(decryptOrchardAction v) (decryptOrchardAction v)
(concatMap rt_orchardActions txList') (concatMap rt_orchardActions txList')
print decodedOrchList print decodedOrchList
decodeSaplingTx :: T.Text -> RawTxResponse -> [ZcashTx] decodeSaplingTx :: T.Text -> RawTxResponse -> [Maybe ZcashTx]
decodeSaplingTx k t = decodeSaplingTx k t =
map map
(buildZcashTx t . (buildZcashTx t .
decodeSaplingOutput (bytes (decodeBech32 $ E.encodeUtf8 k))) decodeSaplingOutput (bytes (decodeBech32 $ E.encodeUtf8 k)))
(rt_shieldedOutputs t) (rt_shieldedOutputs t)
buildZcashTx :: RawTxResponse -> Maybe DecodedNote -> ZcashTx buildZcashTx :: RawTxResponse -> Maybe DecodedNote -> Maybe ZcashTx
buildZcashTx t n = buildZcashTx t n =
case n of case n of
Nothing -> Nothing -> Nothing
ZcashTx
(rt_id t)
0.0
0
(rt_blockheight t)
(rt_blocktime t)
True
(rt_confirmations t)
""
Just n -> Just n ->
Just $
ZcashTx ZcashTx
(rt_id t) (rt_id t)
(fromIntegral (a_value n) * 0.00000001) (fromIntegral (a_value n) * 0.00000001)