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 =