Publish Zenith beta version #80

Merged
pitmutt merged 90 commits from dev041 into master 2024-05-09 19:15:41 +00:00
5 changed files with 69 additions and 4 deletions
Showing only changes of commit 0543c1141c - Show all commits

View file

@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.4.5.0]
### Added
- Functions to scan relevant transparent notes
- Functions to scan relevant Sapling notes
### Changed
- Update `zcash-haskell`
## [0.4.4.3] ## [0.4.4.3]
### Added ### Added

View file

@ -169,4 +169,13 @@ syncWallet walletDb w = do
addrs <- concat <$> mapM (getAddresses walletDb . entityKey) accs addrs <- concat <$> mapM (getAddresses walletDb . entityKey) accs
lastBlock <- getMaxWalletBlock walletDb lastBlock <- getMaxWalletBlock walletDb
trNotes <- mapM (findTransparentNotes walletDb lastBlock . entityVal) addrs trNotes <- mapM (findTransparentNotes walletDb lastBlock . entityVal) addrs
return $ show trNotes sapNotes <-
mapM
(findSaplingOutputs walletDb lastBlock (zcashWalletNetwork $ entityVal w) .
zcashAccountSapSpendKey . entityVal)
accs
print "Transparent Notes: "
print trNotes
print "Sapling notes: "
print sapNotes
return "Testing"

View file

@ -19,6 +19,7 @@
module Zenith.DB where module Zenith.DB where
import Control.Monad (when) import Control.Monad (when)
import Data.Bifunctor
import qualified Data.ByteString as BS import qualified Data.ByteString as BS
import Data.HexString import Data.HexString
import Data.Maybe (fromJust, isJust) import Data.Maybe (fromJust, isJust)
@ -35,8 +36,10 @@ import Haskoin.Transaction.Common
, txHashToHex , txHashToHex
) )
import ZcashHaskell.Orchard (isValidUnifiedAddress) import ZcashHaskell.Orchard (isValidUnifiedAddress)
import ZcashHaskell.Sapling (decodeSaplingOutputEsk)
import ZcashHaskell.Types import ZcashHaskell.Types
( OrchardAction(..) ( DecodedNote(..)
, OrchardAction(..)
, OrchardBundle(..) , OrchardBundle(..)
, SaplingBundle(..) , SaplingBundle(..)
, Scope(..) , Scope(..)
@ -474,6 +477,48 @@ saveWalletTrNote dbPath (zt, tn) wa = do
(entityKey tn) (entityKey tn)
False False
-- | Find the Sapling notes that match the given spending key
findSaplingOutputs ::
T.Text -- ^ the database path
-> Int -- ^ the starting block
-> ZcashNetDB -- ^ The network
-> SaplingSpendingKeyDB -- ^ The spending key to trial decrypt
-> IO [(Entity ZcashTransaction, DecodedNote)]
findSaplingOutputs dbPath b znet sk = do
r <-
PS.runSqlite dbPath $ do
select $ do
(txs :& sOutputs) <-
from $ table @ZcashTransaction `innerJoin` table @ShieldOutput `on`
(\(txs :& sOutputs) ->
txs ^. ZcashTransactionId ==. sOutputs ^. ShieldOutputTx)
where_ (txs ^. ZcashTransactionBlock >. val b)
pure (txs, sOutputs)
let decryptedList =
map (saplingTrialDecrypt External (getNet znet)) r <>
map (saplingTrialDecrypt Internal (getNet znet)) r
return $ map (second fromJust) $ filter (\(z, n) -> isJust n) decryptedList
where
saplingTrialDecrypt ::
Scope
-> ZcashNet
-> (Entity ZcashTransaction, Entity ShieldOutput)
-> (Entity ZcashTransaction, Maybe DecodedNote)
saplingTrialDecrypt sc n (zt, so) = (zt, decodeShOut sc n so)
decodeShOut :: Scope -> ZcashNet -> Entity ShieldOutput -> Maybe DecodedNote
decodeShOut scope n s =
decodeSaplingOutputEsk
(getSapSK sk)
(ShieldedOutput
(getHex $ shieldOutputCv $ entityVal s)
(getHex $ shieldOutputCmu $ entityVal s)
(getHex $ shieldOutputEphKey $ entityVal s)
(getHex $ shieldOutputEncCipher $ entityVal s)
(getHex $ shieldOutputOutCipher $ entityVal s)
(getHex $ shieldOutputProof $ entityVal s))
n
scope
-- | Helper function to extract a Unified Address from the database -- | Helper function to extract a Unified Address from the database
readUnifiedAddressDB :: WalletAddress -> Maybe UnifiedAddress readUnifiedAddressDB :: WalletAddress -> Maybe UnifiedAddress
readUnifiedAddressDB = readUnifiedAddressDB =

@ -1 +1 @@
Subproject commit 2709d422667080527ccc180e97352693a4c6c2c7 Subproject commit 817c52dacf37b95c81c5ad8c59b6b6783e9c498d

View file

@ -1,6 +1,6 @@
cabal-version: 3.0 cabal-version: 3.0
name: zenith name: zenith
version: 0.4.4.3 version: 0.4.5.0
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Rene Vergara author: Rene Vergara