From c69d4f9974d84502efeb456613716185dc594eda Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Wed, 10 Jul 2024 13:39:02 -0500 Subject: [PATCH] Add functions for shielded balance and transparent balance --- src/Zenith/DB.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Zenith/DB.hs b/src/Zenith/DB.hs index 6a7909a..384f3bb 100644 --- a/src/Zenith/DB.hs +++ b/src/Zenith/DB.hs @@ -1390,6 +1390,22 @@ getBalance pool za = do let oBal = sum oAmts return . fromIntegral $ tBal + sBal + oBal +getTransparentBalance :: ConnectionPool -> ZcashAccountId -> IO Integer +getTransparentBalance pool za = do + trNotes <- getWalletUnspentTrNotes pool za + let tAmts = map (walletTrNoteValue . entityVal) trNotes + return . fromIntegral $ sum tAmts + +getShieldedBalance :: ConnectionPool -> ZcashAccountId -> IO Integer +getShieldedBalance pool za = do + sapNotes <- getWalletUnspentSapNotes pool za + let sAmts = map (walletSapNoteValue . entityVal) sapNotes + let sBal = sum sAmts + orchNotes <- getWalletUnspentOrchNotes pool za + let oAmts = map (walletOrchNoteValue . entityVal) orchNotes + let oBal = sum oAmts + return . fromIntegral $ sBal + oBal + getUnconfirmedBalance :: ConnectionPool -> ZcashAccountId -> IO Integer getUnconfirmedBalance pool za = do trNotes <- getWalletUnspentUnconfirmedTrNotes pool za