rvv001 - Issue 0122 - Generate Viewing Keys

The Viewing Keys deriving functions are now
                          integrated to the CLI.hs module (TUI).
This commit is contained in:
Rene V. Vergara 2025-01-07 16:25:45 -05:00
parent d8457eceb6
commit e4b6b36a7d

View file

@ -96,7 +96,7 @@ import Text.Wrap
, defaultWrapSettings
, wrapTextToLines
)
import ZcashHaskell.Keys (generateWalletSeedPhrase)
import ZcashHaskell.Keys (generateWalletSeedPhrase, deriveUfvk, deriveUivk)
import ZcashHaskell.Orchard
( getSaplingFromUA
, isValidUnifiedAddress
@ -122,6 +122,9 @@ import Zenith.Types
, ValidAddressAPI(..)
, ZcashNetDB(..)
, ZenithStatus(..)
, OrchardSpendingKeyDB(..)
, SaplingSpendingKeyDB(..)
, TransparentSpendingKeyDB(..)
)
import Zenith.Utils
( displayTaz
@ -1761,24 +1764,52 @@ appEvent (BT.VtyEvent e) = do
BT.modify $ set dialogBox ViewingKeyMenu
ev -> return ()
--
-- Open viewing key display form
--
ViewingKeyMenu -> do
case e of
--
-- Full viewing key display
--
V.EvKey (V.KChar 'f') [] -> do
BT.modify $ set vkName "Full"
BT.modify $
set
vkData
"VKFull->ztestsapling1tgjr4zppwk4ne8xy6gdq4z2gwq7dmf5jq8z2ctpn8nlmtse0a74fa5z0m8z383gmpgqz6q6duu4"
BT.modify $ set dialogBox ViewingKeyShow
selAccount <-
do case L.listSelectedElement $ s ^. accounts of
Nothing -> do
let fAcc =
L.listSelectedElement $ L.listMoveToBeginning $ s ^. accounts
case fAcc of
Nothing -> throw $ userError "Failed to select account"
Just (_j, w1) -> return w1
Just (_k, w) -> return w
let osk = getOrchSK $ zcashAccountOrchSpendKey $ entityVal selAccount
let ssk = getSapSK $ zcashAccountSapSpendKey $ entityVal selAccount
let tsk = getTranSK $ zcashAccountTPrivateKey $ entityVal selAccount
fvk <- liftIO $ deriveUfvk (s ^. network) osk ssk tsk
BT.modify $ set vkName "Full"
BT.modify $ set vkData fvk
BT.modify $ set dialogBox ViewingKeyShow
--
-- Incoming viewing key display
--
V.EvKey (V.KChar 'i') [] -> do
BT.modify $ set vkName "Incomming"
BT.modify $
set
vkData
"VKIncoming->ztestsapling1tgjr4zppwk4ne8xy6gdq4z2gwq7dmf5jq8z2ctpn8nlmtse0a74fa5z0m8z383gmpgqz6q6duu4"
BT.modify $ set dialogBox ViewingKeyShow
selAccount <-
do case L.listSelectedElement $ s ^. accounts of
Nothing -> do
let fAcc =
L.listSelectedElement $ L.listMoveToBeginning $ s ^. accounts
case fAcc of
Nothing -> throw $ userError "Failed to select account"
Just (_j, w1) -> return w1
Just (_k, w) -> return w
let osk = getOrchSK $ zcashAccountOrchSpendKey $ entityVal selAccount
let ssk = getSapSK $ zcashAccountSapSpendKey $ entityVal selAccount
let tsk = getTranSK $ zcashAccountTPrivateKey $ entityVal selAccount
ivk <- liftIO $ deriveUivk (s ^. network) osk ssk tsk
BT.modify $ set vkName "Incomming"
BT.modify $ set vkData ivk
BT.modify $ set dialogBox ViewingKeyShow
V.EvKey (V.KChar 'e') [] ->
BT.modify $ set dialogBox Blank
BT.modify $ set dialogBox Blank
ev -> return ()
--
-- Payment URI Form Events