fix(gui): creation of change addresses

Fixes #111
This commit is contained in:
Rene Vergara 2025-01-08 08:12:53 -06:00
parent 6d6ef37668
commit 7accde3463
Signed by: pitmutt
SSH key fingerprint: SHA256:vNa8FIqbBZjV9hOCkXyOzd7gqWCMCfkcfiPH2zaGfQ0
8 changed files with 38 additions and 13 deletions

View file

@ -5,6 +5,12 @@ 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.7.2.0-beta]
### Fixed
- Creation of change addresses during account creation in GUI ([#111](https://code.vergara.tech/Vergara_Tech/zenith/issues/111))
## [0.7.1.0-beta]
### Changed

View file

@ -67,7 +67,7 @@ main = do
zebraPort
(zgb_net chainInfo)
threadDelay 90000000
putStrLn "Zenith RPC Server 0.7.0.0-beta"
putStrLn "Zenith RPC Server 0.7.2.0-beta"
putStrLn "------------------------------"
putStrLn $
"Connected to " ++

View file

@ -6,10 +6,10 @@ with-compiler: ghc-9.6.5
source-repository-package
type: git
location: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git
location: https://code.vergara.tech/Vergara_Tech/haskell-hexstring.git
tag: 39d8da7b11a80269454c2f134a5c834e0f3cb9a7
source-repository-package
type: git
location: https://git.vergara.tech/Vergara_Tech/haskell-foreign-rust.git
location: https://code.vergara.tech/Vergara_Tech/haskell-foreign-rust.git
tag: 335e804454cd30da2c526457be37e477f71e4665

View file

@ -528,7 +528,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
(str
" _____ _ _ _ \n|__ /___ _ __ (_) |_| |__\n / // _ \\ '_ \\| | __| '_ \\\n / /| __/ | | | | |_| | | |\n/____\\___|_| |_|_|\\__|_| |_|") <=>
C.hCenter
(withAttr titleAttr (str "Zcash Wallet v0.7.1.0-beta")) <=>
(withAttr titleAttr (str "Zcash Wallet v0.7.2.0-beta")) <=>
C.hCenter (withAttr blinkAttr $ str "Press any key..."))
else emptyWidget
capCommand3 :: String -> String -> String -> Widget Name

View file

@ -787,7 +787,7 @@ shieldTransparentNotes pool zebraHost zebraPort znet za bh = do
prepTSpends
(getTranSK $ zcashAccountTPrivateKey $ entityVal acc)
trNotes
chgAddr <- getInternalAddresses pool $ entityKey acc
chgAddr <- liftIO $ getInternalAddresses pool $ entityKey acc
let internalUA =
getUA $ walletAddressUAddress $ entityVal $ head chgAddr
let oRcvr =
@ -1076,7 +1076,7 @@ prepareTxV2 pool zebraHost zebraPort zn za bh pnotes policy = do
makeOutgoing acc recvs chg pol = do
let k = map (\(x, _, _, _) -> x) recvs
let j = map (\(_, _, x, _) -> x) recvs
chgAddr <- runNoLoggingT $ getInternalAddresses pool $ entityKey acc
chgAddr <- getInternalAddresses pool $ entityKey acc
let internalUA = getUA $ walletAddressUAddress $ entityVal $ head chgAddr
case pol of
Full ->
@ -1298,8 +1298,7 @@ syncWallet config w = do
mapM (liftIO . runNoLoggingT . getAddresses pool . entityKey) accs
logDebugN $ "addrs: " <> T.pack (show addrs)
intAddrs <-
concat <$>
mapM (liftIO . runNoLoggingT . getInternalAddresses pool . entityKey) accs
concat <$> mapM (liftIO . getInternalAddresses pool . entityKey) accs
chainTip <- liftIO $ getMaxBlock pool znet
logDebugN $ "chain tip: " <> T.pack (show chainTip)
lastBlock <- liftIO $ getLastSyncBlock pool $ entityKey w

View file

@ -647,8 +647,9 @@ getAddressById pool a = do
getInternalAddresses ::
ConnectionPool -- ^ The database path
-> ZcashAccountId -- ^ The account ID to check
-> NoLoggingT IO [Entity WalletAddress]
-> IO [Entity WalletAddress]
getInternalAddresses pool a =
runNoLoggingT $
PS.retryOnBusy $
flip PS.runSqlPool pool $ do
select $ do
@ -1436,7 +1437,8 @@ getWalletTransactions ::
-> NoLoggingT IO ()
getWalletTransactions pool w = do
let w' = entityVal w
chgAddr <- getInternalAddresses pool $ walletAddressAccId $ entityVal w
chgAddr <-
liftIO $ getInternalAddresses pool $ walletAddressAccId $ entityVal w
let ctReceiver = t_rec =<< readUnifiedAddressDB (entityVal $ head chgAddr)
let csReceiver = s_rec =<< readUnifiedAddressDB (entityVal $ head chgAddr)
let coReceiver = o_rec =<< readUnifiedAddressDB (entityVal $ head chgAddr)

View file

@ -88,6 +88,7 @@ data AppEvent
| MenuClicked
| NewClicked
| NewAddress !(Maybe (Entity ZcashAccount))
| NewInternalAddress !(Maybe (Entity ZcashAccount))
| NewAccount !(Maybe (Entity ZcashWallet))
| NewWallet
| SetPool !ZcashPool
@ -101,6 +102,7 @@ data AppEvent
| LoadAddrs ![Entity WalletAddress]
| LoadAccs ![Entity ZcashAccount]
| LoadWallets ![Entity ZcashWallet]
| CheckChange
| ConfirmCancel
| SaveAddress !(Maybe (Entity ZcashAccount))
| SaveAccount !(Maybe (Entity ZcashWallet))
@ -1199,6 +1201,7 @@ handleEvent wenv node model evt =
AccountClicked -> [Model $ model & accPopup .~ True]
MenuClicked -> [Model $ model & menuPopup .~ True]
NewClicked -> [Model $ model & newPopup .~ not (model ^. newPopup)]
NewInternalAddress acc -> [Task $ addNewAddress "Change" Internal acc]
NewAddress acc ->
[ Model $
model & confirmTitle ?~ "New Address" & confirmAccept .~ "Create" &
@ -1365,13 +1368,28 @@ handleEvent wenv node model evt =
, Event $ ShowMsg "Copied transaction ID!"
]
LoadTxs t -> [Model $ model & transactions .~ t]
CheckChange ->
[ Task $ do
case currentAccount of
Nothing -> return $ ShowError "No account available"
Just acc -> do
pool <-
runNoLoggingT $ initPool $ c_dbPath $ model ^. configuration
chgAddr <- getInternalAddresses pool $ entityKey acc
if not (null chgAddr)
then return $ SetPool OrchardPool
else return $ NewInternalAddress currentAccount
]
LoadAddrs a ->
if not (null a)
then [ Model $ model & addresses .~ a
, Event CheckChange
, Event $ SwitchAddr $ model ^. selAddr
, Event $ SetPool OrchardPool
]
else [Event $ NewAddress currentAccount]
else [ Event $ NewAddress currentAccount
, Event $ NewInternalAddress currentAccount
]
LoadAccs a ->
if not (null a)
then [Model $ model & accounts .~ a, Event $ SwitchAcc 0]
@ -2010,7 +2028,7 @@ runZenithGUI config = do
Left _e -> print "Zebra not available"
where
params hd =
[ appWindowTitle "Zenith - Zcash Full Node Wallet - 0.7.1.0-beta"
[ appWindowTitle "Zenith - Zcash Full Node Wallet - 0.7.2.0-beta"
, appWindowState $ MainWindowNormal (1000, 700)
, appTheme zenithTheme
, appFontDef

View file

@ -1,6 +1,6 @@
cabal-version: 3.0
name: zenith
version: 0.7.1.0-beta
version: 0.7.2.0-beta
license: MIT
license-file: LICENSE
author: Rene Vergara