From 22f889bf8667eb9de23b9505dc952bd0258dd9ca Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Tue, 19 Mar 2024 15:09:37 -0500 Subject: [PATCH] Add new raw tx table --- src/Zenith/Core.hs | 2 +- src/Zenith/DB.hs | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Zenith/Core.hs b/src/Zenith/Core.hs index 4e1d2c6..ffad5fa 100644 --- a/src/Zenith/Core.hs +++ b/src/Zenith/Core.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} --- Core wallet functionality for Zenith +-- | Core wallet functionality for Zenith module Zenith.Core where import Control.Exception (throwIO) diff --git a/src/Zenith/DB.hs b/src/Zenith/DB.hs index 8345aef..67daeb6 100644 --- a/src/Zenith/DB.hs +++ b/src/Zenith/DB.hs @@ -19,13 +19,15 @@ module Zenith.DB where import Control.Monad.IO.Class (liftIO) import qualified Data.ByteString as BS +import Data.HexString import qualified Data.Text as T import Database.Persist import Database.Persist.Sqlite import Database.Persist.TH import ZcashHaskell.Types (Scope(..), ZcashNet) import Zenith.Types - ( OrchardSpendingKeyDB(..) + ( HexStringDB(..) + , OrchardSpendingKeyDB(..) , PhraseDB(..) , SaplingSpendingKeyDB(..) , ScopeDB(..) @@ -65,6 +67,18 @@ share deriving Show Eq |] +share + [mkPersist sqlSettings, mkMigrate "rawStorage"] + [persistLowerCase| + WalletTransaction + block Int + txId HexStringDB + conf Int + time Int + hex HexStringDB + deriving Show Eq + |] + -- * Database functions -- | Initializes the database initDb :: @@ -73,6 +87,12 @@ initDb :: initDb dbName = do runSqlite dbName $ do runMigration migrateAll +-- | Initializes the raw data storage +initRawStore :: + T.Text -- ^ the database path + -> IO () +initRawStore dbFilePath = runSqlite dbFilePath $ runMigration rawStorage + -- | Get existing wallets from database getWallets :: T.Text -> ZcashNet -> IO [Entity ZcashWallet] getWallets dbFp n =