Publish Zenith beta version #80
5 changed files with 69 additions and 4 deletions
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -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/),
|
||||
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]
|
||||
|
||||
### Added
|
||||
|
|
|
@ -169,4 +169,13 @@ syncWallet walletDb w = do
|
|||
addrs <- concat <$> mapM (getAddresses walletDb . entityKey) accs
|
||||
lastBlock <- getMaxWalletBlock walletDb
|
||||
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"
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
module Zenith.DB where
|
||||
|
||||
import Control.Monad (when)
|
||||
import Data.Bifunctor
|
||||
import qualified Data.ByteString as BS
|
||||
import Data.HexString
|
||||
import Data.Maybe (fromJust, isJust)
|
||||
|
@ -35,8 +36,10 @@ import Haskoin.Transaction.Common
|
|||
, txHashToHex
|
||||
)
|
||||
import ZcashHaskell.Orchard (isValidUnifiedAddress)
|
||||
import ZcashHaskell.Sapling (decodeSaplingOutputEsk)
|
||||
import ZcashHaskell.Types
|
||||
( OrchardAction(..)
|
||||
( DecodedNote(..)
|
||||
, OrchardAction(..)
|
||||
, OrchardBundle(..)
|
||||
, SaplingBundle(..)
|
||||
, Scope(..)
|
||||
|
@ -474,6 +477,48 @@ saveWalletTrNote dbPath (zt, tn) wa = do
|
|||
(entityKey tn)
|
||||
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
|
||||
readUnifiedAddressDB :: WalletAddress -> Maybe UnifiedAddress
|
||||
readUnifiedAddressDB =
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2709d422667080527ccc180e97352693a4c6c2c7
|
||||
Subproject commit 817c52dacf37b95c81c5ad8c59b6b6783e9c498d
|
|
@ -1,6 +1,6 @@
|
|||
cabal-version: 3.0
|
||||
name: zenith
|
||||
version: 0.4.4.3
|
||||
version: 0.4.5.0
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Rene Vergara
|
||||
|
|
Loading…
Reference in a new issue