diff --git a/src/ZGoBackend.hs b/src/ZGoBackend.hs index 31c51b8..113cd48 100644 --- a/src/ZGoBackend.hs +++ b/src/ZGoBackend.hs @@ -69,6 +69,7 @@ import ZcashHaskell.Orchard import ZcashHaskell.Sapling import ZcashHaskell.Types ( BlockResponse(..) + , DecodedNote(..) , RawData(..) , RawTxResponse(..) , RpcCall(..) @@ -1880,10 +1881,7 @@ scanTxNative pipe db nodeUser nodePwd = do if isValidSaplingViewingKey (E.encodeUtf8 k) then do print "decoding Sapling tx" - let decodedSapList' = - map - (decodeSaplingOutput (bytes (decodeBech32 $ E.encodeUtf8 k))) - sOutList + let decodedSapList' = map (decodeSaplingTx k) txList' print decodedSapList' else do let vk = decodeUfvk $ E.encodeUtf8 k @@ -1897,6 +1895,35 @@ scanTxNative pipe db nodeUser nodePwd = do (decryptOrchardAction v) (concatMap rt_orchardActions txList') print decodedOrchList + decodeSaplingTx :: T.Text -> RawTxResponse -> [ZcashTx] + decodeSaplingTx k t = + map + (buildZcashTx t . + decodeSaplingOutput (bytes (decodeBech32 $ E.encodeUtf8 k))) + (rt_shieldedOutputs t) + buildZcashTx :: RawTxResponse -> Maybe DecodedNote -> ZcashTx + buildZcashTx t n = + case n of + Nothing -> + ZcashTx + (rt_id t) + 0.0 + 0 + (rt_blockheight t) + (rt_blocktime t) + True + (rt_confirmations t) + "" + Just n -> + ZcashTx + (rt_id t) + (fromIntegral (a_value n) * 0.00000001) + (toInteger $ a_value n) + (rt_blockheight t) + (rt_blocktime t) + False + (rt_confirmations t) + (E.decodeUtf8Lenient $ a_memo n) debug = flip trace diff --git a/stack.yaml.lock b/stack.yaml.lock index a782c3f..ffc2283 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: 00090dbfcd511895c2d6b9cced6d55545c4d4db7 + commit: 7992e5bfbe4e747d702f5bc6e27d85a7a9041ba4 git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git name: zcash-haskell pantry-tree: - sha256: 911ef15253ed951762f45154f45adb97df926fade2e94d758af3032481591d53 + sha256: d84e098e80f7c9b682ef798702fcbfcd884947abc7661b18882d70fd1ad92c7a size: 1229 version: 0.2.0 original: - commit: 00090dbfcd511895c2d6b9cced6d55545c4d4db7 + commit: 7992e5bfbe4e747d702f5bc6e27d85a7a9041ba4 git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git - completed: commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05