Compare commits

...

173 commits

Author SHA1 Message Date
0a1f35eefc
feat(rpc): implement getincomingvk 2025-01-14 13:05:17 -06:00
620fca5827
docs(rpc): finalize getincomingvk 2025-01-14 12:37:29 -06:00
9e62a54e59
feat(rpc): implement getfullvk method 2025-01-14 10:53:57 -06:00
876fe3a5d3
docs(rpc): finalize getfullvk 2025-01-14 10:53:28 -06:00
eda70396ba
docs(rpc): correct description for getfullvk 2025-01-13 12:57:08 -06:00
4d8fb534f4
docs(rpc): add placeholder for getincomingvk 2025-01-13 12:29:02 -06:00
e3797f2494
docs(rpc): correct RPC doc 2025-01-12 16:08:20 -06:00
a4966d0f5a
docs(rpc): start getfullvk 2025-01-12 15:54:43 -06:00
60576016bf
Merge branch 'master' into rav001 2025-01-11 08:30:26 -06:00
a303ca9fed
feat(rpc): implement deshieldfunds 2024-12-26 12:27:27 -06:00
9226dea598
docs(rpc): update the deshieldfunds method 2024-12-20 09:11:09 -06:00
b1cc8a4116
docs(rpc): fix delimiters 2024-12-20 08:41:05 -06:00
ddff671676
docs(rpc): fix typo 2024-12-20 08:32:39 -06:00
6079245af7
docs(rpc): update OpenRPC for sendmany 2024-12-20 08:19:20 -06:00
d53bb092d1
docs(rpc): update OpenRPC spec for deshieldfunds 2024-12-19 14:11:37 -06:00
9546613e0f
feat(rpc): implement shieldnotes method 2024-12-18 13:31:13 -06:00
b88e32f701
Merge branch 'master' into rav001 2024-12-17 10:11:44 -06:00
d737680a01
feat(rpc): implement shieldnotes 2024-12-13 08:04:31 -06:00
e91fe22473
docs(rpc): add params and result to shieldnotes 2024-12-09 08:47:32 -06:00
9e3eeee78e
docs: add new RPC methods to spec 2024-12-09 08:39:15 -06:00
34dfbb3be2
Merge branch 'milestone4' into rav001 2024-11-25 10:36:52 -06:00
34e8b18f59
docs: clean up of obsolete files 2024-11-25 10:34:45 -06:00
47743ddd5a
Release preparation 2024-11-21 09:26:00 -06:00
de21a4e4b3
fix(rpc): correct config parameters 2024-11-21 07:25:36 -06:00
9c2d0aaf20
feat: finalize RPC 2024-11-20 16:12:27 -06:00
d2c52508d1
feat: batch append commitments 2024-11-19 15:05:33 -06:00
45b9651641
feat: enable shielding in GUI 2024-11-19 07:27:31 -06:00
5fbb5c865b
feat: implement commitment trees 2024-11-19 07:27:08 -06:00
42f6b6becb
fix: tree truncation function 2024-11-19 07:26:27 -06:00
f23c222edc
feat(tui): implement new commitment trees 2024-11-15 12:54:51 -06:00
8986847679
feat(core): commitment tree management functions 2024-11-08 14:47:43 -06:00
b4a2e5e984
feat(db): add tree store 2024-11-08 13:38:04 -06:00
f2f18b5b0c
Merge branch 'trees' into rav001 2024-11-05 12:57:28 -06:00
5979d92286
Update to zcash-haskell 0.7.4.0 2024-11-05 12:55:51 -06:00
a7cf3a75c6
feat: implement merkle path calculator 2024-11-04 18:56:16 -06:00
1898770bf5
feat: implement Borsh serialization 2024-11-04 10:17:54 -06:00
e52664fa8b
Merge branch 'rav001' into trees 2024-10-30 13:48:29 -05:00
78437987bf
feat(core): use new createTransaction function 2024-10-30 12:55:09 -05:00
13b55ad266
feat: add function to fill tree to depth 2024-10-29 07:01:13 -05:00
723d1b4e1c
docs: update changelog 2024-10-27 06:37:07 -05:00
0e5f476e28
fix: correct fee calculation for shielding 2024-10-27 06:27:59 -05:00
28a75895f4
fix: correct commitment tree function 2024-10-25 12:36:24 -05:00
183b4adf91
fix: use network for distinguishing blocks 2024-10-25 09:59:01 -05:00
b0ca5b7d4b
feat: structure for a balanced monoidal tree 2024-10-25 09:09:21 -05:00
5f2859194b
fix: correct rewind for brand new wallets 2024-10-23 16:26:18 -05:00
70ef4d85f4
feat: update cabal 2024-10-23 15:51:30 -05:00
9d1416dd9d
feat: implement Scientific 2024-10-23 15:51:05 -05:00
d445ba3324
feat: draft commitment tree tracker 2024-10-23 15:49:24 -05:00
d72f355981
feat: update amount reading to Scientific 2024-10-22 07:21:12 -05:00
c0031e91fd
feat: enable debugging 2024-10-18 14:50:56 -05:00
f309864671
fix: chain rewind on data store 2024-10-16 16:01:45 -05:00
13c24ca528
feat(tui): implement shielding command 2024-10-16 08:48:54 -05:00
6be3630fbc
fix: chain re-org detection 2024-10-16 08:48:22 -05:00
cd4054e052
Merge branch 'rvv001' into rav001 2024-10-15 14:45:58 -05:00
57ab57554b
libs: update zcash-haskell 2024-10-15 10:36:36 -05:00
53eac75aa5 rvv001 - Shield / Deshield Forms
-  Shield form created
	 -  Deshield form created
	 Both forms have the 'Process' button de-activated. Must be linked
	 to the appropiate funciton
2024-10-14 19:42:09 -04:00
324ed663c3 rvv001 - Shield - Deshield process
DeShield form  -  Cancel button moved  to the right of process button
2024-10-11 21:01:50 -04:00
9acf18c503 rvv001 - Shield Zec form updated 2024-10-11 20:12:15 -04:00
f1daf576cc
feat: shield notes by address 2024-10-10 09:56:04 -05:00
2f3362e900
feat: remove debug logging 2024-10-10 09:05:10 -05:00
935ad1d691
fix: correct sorting of user transactions 2024-10-10 09:03:26 -05:00
54d9f20fdd rvv001 - Shield / De-Shield
GUI - Forms for Shielding and De-shielding created
	 TUI - Form to deshield  is not implemented
2024-10-09 21:02:35 -04:00
c4a879b09b
Merge branch 'rvv001' into rav001 2024-10-08 10:07:22 -05:00
213afdadd9
feat(core): shielding and deshielding 2024-10-08 10:01:55 -05:00
c75316ddd7
feat(rpc): background wallet sync 2024-10-08 08:20:52 -05:00
e02551c9ff rvv001 - Shield / Deshield form
Fields to display Total transparent funts and total Shielded Funds
	 added.
	 A funtion to update the latest total values has to be included
2024-10-07 19:47:28 -04:00
7410eed991
docs(rpc): add new error type 2024-10-07 14:26:49 -05:00
e487a67e36
docs: remote draft tag from sendmany 2024-10-06 08:27:53 -05:00
f75faa33c6
docs: update sendmany RPC spec 2024-10-06 08:23:08 -05:00
acba134de2
feat(rpc): add sendmany method 2024-10-06 08:19:21 -05:00
cf2f77e510 rvv001 -TUI - Form to process Shielding and De-Shielding zec has been implemented
The functionality to do the process is pending.
2024-10-04 21:01:13 -04:00
a0b9d4178a
feat(core): support for multiple outputs per transaction 2024-10-04 12:46:44 -05:00
25b6a097c7 rvv001 - Address Validation for PrivacyPolicy = Low
Transparent, Sapling, Orchard -> Accepted
	    Exchange -> rejected
2024-10-02 20:29:51 -04:00
398f4f1dcf rvv001 - Privacy Policy control addedin TUI's send transaction form
This feature is similar to GUI's implementation.
2024-10-01 20:47:45 -04:00
86b881e752
docs: correct typo in RPC spec 2024-10-01 13:24:41 -05:00
12a707e4cb
docs: update sendmany RPC spec 2024-10-01 13:11:04 -05:00
b6b586f9bf
feat: add QR code table upgrade 2024-10-01 12:42:38 -05:00
adfaed6753
Merge branch 'rav001' into rvv001 2024-10-01 08:26:53 -05:00
28c05a66fe
feat: implement new PrivacyPolicy 2024-10-01 08:13:26 -05:00
0d5161cdb2 rvv001 - Privacy Policy check added to Send transaction window
Files affected: Zenith/GUI.hs
			, Zenith/CLI.hs
			, Zenith/Utils.hs
2024-09-30 20:16:09 -04:00
165977eecf rvv001 - Saving work in progress.... 2024-09-29 20:57:32 -04:00
5c8a611dfc rvv001 - Saving Work in progress... 2024-09-29 20:43:12 -04:00
6255ea3142 rvv001 - Merge with rav001 branch 2024-09-29 20:22:29 -04:00
01cdf9eb14 rvv001 - temporary commit 2024-09-29 18:18:46 -04:00
b95213ae5c
feat: refactor ZcashPool type 2024-09-29 17:11:06 -05:00
302cfb0b76
Add Logging to sync 2024-09-29 12:32:12 -05:00
6a4bbb587c
feat: set Orchard anchor depth to 5 blocks 2024-09-26 07:31:50 -05:00
95b89e28ed
tests: Add transaction preparation tests 2024-09-25 13:01:48 -05:00
93240325df
feat!: add re-org detection and rewind 2024-09-24 14:34:19 -05:00
abe30db2fe rvv001 - Zenith GUI - Privacy level radio buttons added to Send transaction form 2024-09-24 11:09:58 -04:00
d050c0c040 rvv001 - docker folder removed 2024-09-23 21:46:00 -04:00
212c1f2867 rvv001 - Add Privacy Policy to TUI 2024-09-23 21:30:05 -04:00
0e14228a0e
feat!: add block tracking to data model
Adds new `ZcashBlock` table to database to track block information and
creates a relationship between `ZcashTransaction` records and the block
they belong to.
Database getters and setters are updated to use the block record for
confirmations, height, time data.
2024-09-23 13:55:14 -05:00
7189ddcb2a
feat: update to use new createTransaction 2024-09-17 14:23:35 -05:00
4a874897cf
feat: draft new prepareTxV2 function 2024-09-16 11:52:57 -05:00
befc3e46cc
feat: add PrivacyPolicy type 2024-09-14 15:30:02 -05:00
eaa596fdac
docs: fix spec error 2024-09-14 09:10:01 -05:00
a2be940648
docs: correct sendmany parameters 2024-09-14 08:59:31 -05:00
f4f149d6a2
docs: fix typo in sendmany spec 2024-09-14 08:56:15 -05:00
4aad9cb57f
docs: update the sendmany spec 2024-09-14 08:54:12 -05:00
c9a42572d3
docs: correct sendmany schemas in OpenRPC 2024-09-14 06:54:00 -05:00
932d79ad57
docs: add examples for sendmany OpenRPC 2024-09-14 06:47:18 -05:00
a2743842dd
docs: update OpenRPC spec for sendmany 2024-09-13 17:20:31 -05:00
e46cd01f41
Add address book 2024-09-13 07:09:31 -05:00
322f2b8959
Merge branch 'milestone3' into rav001 2024-09-13 07:08:58 -05:00
bf4118b09d
Merge pull request 'Add base addressbook to GUI' (#102) from rvv041 into milestone3
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zenith/pulls/102
2024-09-13 11:39:57 +00:00
59d3ee4d37
Merge branch 'milestone3' into rvv041 2024-09-13 06:37:11 -05:00
a3a8bb1eaa rvv041 - AddressBook - empty Address book database case 2024-09-11 21:34:15 -04:00
06b2cd9222 rvv041 - Address Book - Edit Address Book Description working
- Delete Address Book Entry working
2024-09-08 17:21:17 -04:00
185738eccc rvv041 - Address Book - Edit Address Book entry description in progress
- "Delete entry" button added (functionality not implemented yet)
2024-09-07 17:09:33 -04:00
87feab284e rvv041 - Address Book - Copy ZEC Address to clipboard implemented
- Edit Adress Book entry in progress.
2024-09-06 19:50:50 -04:00
5ce0b5fa0f rvv0041 - Address Book - Show Address Book entry on mouse click completed 2024-09-06 17:16:22 -04:00
538216944d
feat: Update addressbook list after save 2024-09-06 08:42:17 -05:00
dee0a7e8e8 rvv041 - Address Book - New entry form working correctly
- Show entry zec address on row click
2024-09-05 22:19:41 -04:00
b3df16f217 rvv041 - Address Book - Entry form working partially 2024-09-05 13:50:52 -04:00
0142ea90ae rvv041 - Address Book - in progress.... 2024-09-05 11:31:51 -04:00
1931098ee9 rvv041 - AddressBook - reloading AddressBook List in progress... 2024-09-05 10:13:32 -04:00
35dce186fd
feat: getoperationstatus RPC method 2024-09-04 13:10:09 -05:00
bd3d9e8067
docs: fixed typo in OpenRPC 2024-09-04 11:11:01 -05:00
f780e996e0
docs: info for getoperationstatus 2024-09-04 11:08:00 -05:00
dcdf2e8304
Update to OpenRPC spec 2024-09-04 09:17:12 -05:00
f8fa5a005a rvv041 - AddressBook - Save new address book entry problem 2024-09-02 09:40:57 -04:00
70123a7261
Add examples to OpenRPC spec 2024-08-30 15:25:25 -05:00
1caa4efdb4
Implement getnewaddress RPC method 2024-08-30 15:14:48 -05:00
73ad2f0eb3 rvv041 - AddressBook - Record ID added to address book entries. 2024-08-29 14:42:58 -04:00
6503af6a98
Update spec for getnewaddress 2024-08-29 09:19:10 -05:00
67d334a60b rvv041 - AddressBook main window - address description list ready
New Address Entry form - Description and Address fields ready
2024-08-28 21:21:05 -04:00
fae0def6a8
Implement getnewaccount 2024-08-26 15:25:31 -05:00
35ab075703
Update getnewaccount on RPC 2024-08-26 13:49:00 -05:00
0b7bf1db99
Draft getnewaccount RPC 2024-08-24 08:59:26 -05:00
40fb9228a2
Add example to OpenRPC 2024-08-24 07:51:07 -05:00
4ee09238d8
Implement getnewwallet RPC method 2024-08-24 07:45:42 -05:00
6875917ec7
Fix button style 2024-08-20 16:46:01 -05:00
cdd28d2184 rvv041 - New AddressBook entry form - Check for valid address added. 2024-08-19 18:12:57 -04:00
934bff1454
Implement getbalance 2024-08-16 13:31:25 -05:00
9c7e808794
Add example for getbalance 2024-08-16 13:28:44 -05:00
9917356b40
Add result to OpenRPC 2024-08-15 14:41:10 -05:00
e1dfb66fae
Start work on getbalance 2024-08-15 11:46:05 -05:00
a3df217992
Remove tags for listreceived in OpenRPC 2024-08-15 11:41:03 -05:00
e94ca5e8c4
Add example to OpenRPC 2024-08-15 11:38:57 -05:00
66767da36a
Implement listreceived 2024-08-15 11:17:24 -05:00
b75ed16a3e
Implement note search by address ID 2024-08-12 15:35:00 -05:00
14cf97d473
Add schema change detection 2024-08-10 08:17:35 -05:00
c68c504b53
Refactor for new schema for ZcashTransaction 2024-08-10 07:52:45 -05:00
46b4969da5
Implement database migration 2024-08-10 07:04:40 -05:00
c9dea01644
Fix typos in OpenRPC 2024-08-08 10:11:10 -05:00
d4fd7c5044
Add placeholders for OpenRPC 2024-08-08 09:31:34 -05:00
473192e34b
Create type for Zcash note 2024-08-08 09:24:44 -05:00
d1789b634e
Fix typo in OpenRPC 2024-08-08 09:22:37 -05:00
2dfb11dc0f
Start work on listreceived 2024-08-08 09:20:35 -05:00
9cbeb5fbb0
Add getoperationstatus to OpenRPC spec 2024-08-07 12:10:44 -05:00
2cfaf5959d
Add placeholders to OpenRPC spec 2024-08-07 11:57:10 -05:00
b8980bd219
Implement listaddresses 2024-08-07 11:28:40 -05:00
339c93905f
Use TemplateHaskell for JSON instances 2024-08-06 16:08:51 -05:00
675ca9d5e3
Add draft of listaddresses 2024-08-06 16:08:26 -05:00
4553f964f3
Implement listaccounts 2024-08-06 13:38:00 -05:00
dbe352acac
Add method descriptions to RPC 2024-08-05 15:44:11 -05:00
606c25c2c3
Update RPC docs 2024-08-05 15:16:03 -05:00
a0b92ba468
Add example to OpenRPC for listwallets 2024-08-05 13:04:57 -05:00
f7efa85cdd
Implement listwallets 2024-08-05 12:54:02 -05:00
0d5ff79b96
Add Zenith server executable 2024-08-03 07:01:11 -05:00
abf02cf90d
Add OpenRPC spec 2024-08-03 07:00:12 -05:00
e3de5c7624 rvv041 - AddressBook GUI - version with display order problem 2024-07-31 17:23:49 -04:00
8ba1dfa7c7
Make RPC port configurable 2024-07-24 16:13:13 -05:00
cbcf7c9c8c
Implement basic auth on server 2024-07-24 16:03:49 -05:00
b66d0d9563
Add fields to config 2024-07-24 16:03:23 -05:00
a60534a5c2
Merge branch 'milestone3' into rav001 2024-07-23 13:59:49 -05:00
94bfca95ca
Start RPC server 2024-07-23 13:47:07 -05:00
662f9cd5ed rvv041 - Added "gui" option to usage message 2024-07-22 21:48:36 -04:00
d37269bf44 rvv041 - Zenith Utils -> GetZenithPaht added 2024-07-22 20:58:46 -04:00
c89d5a46d4 rvv041 - Zenith dbFilePath changed for dbFileName 2024-07-22 20:50:49 -04:00
01459544a5 rvv041 - Merge with Milestone2 2024-07-22 18:29:58 -04:00
3a5e593a65
Merge branch 'milestone2' into rav001 2024-07-16 09:11:48 -05:00
16 changed files with 849 additions and 192 deletions

View file

@ -5,6 +5,16 @@ 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.8.0.0-beta]
### Added
- RPC methods:
- `shieldnotes`
- `deshieldfunds`
- `getfullvk`
- `getincomingvk`
## [0.7.2.0-beta]
### Fixed

View file

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

Binary file not shown.

Binary file not shown.

View file

@ -79,6 +79,7 @@ import Data.Scientific (Scientific, scientific)
import qualified Data.Text as T
import qualified Data.Text.Encoding as E
import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
import qualified Data.UUID as U
import qualified Data.Vector as Vec
import Database.Persist
import Database.Persist.Sqlite
@ -116,6 +117,7 @@ import Zenith.Types
, ValidAddressAPI(..)
, ZcashNetDB(..)
, ZenithStatus(..)
, ZenithUuid(..)
)
import Zenith.Utils
( displayTaz
@ -1283,28 +1285,9 @@ appEvent (BT.VtyEvent e) = do
Just (_j, w1) -> return w1
Just (_k, w) -> return w
fs1 <- BT.zoom deshieldForm $ BT.gets formState
let tAddrMaybe =
Transparent <$>
((decodeTransparentAddress .
E.encodeUtf8 .
encodeTransparentReceiver (s ^. network)) =<<
(t_rec =<<
(isValidUnifiedAddress .
E.encodeUtf8 .
getUA . walletAddressUAddress)
(entityVal selAddr)))
bl <-
liftIO $
getChainTip (s ^. zebraHost) (s ^. zebraPort)
case tAddrMaybe of
Nothing -> do
BT.modify $
set
msg
"Failed to obtain transparent address"
BT.modify $ set displayBox MsgDisplay
BT.modify $ set dialogBox Blank
Just tAddr -> do
_ <-
liftIO $
forkIO $
@ -1316,10 +1299,7 @@ appEvent (BT.VtyEvent e) = do
(s ^. network)
(entityKey selAcc)
bl
(ProposedNote
(ValidAddressAPI tAddr)
(fs1 ^. shAmt)
Nothing)
BT.modify $ set displayBox SendDisplay
BT.modify $ set dialogBox Blank
else do
@ -2050,19 +2030,20 @@ shieldTransaction ::
shieldTransaction pool chan zHost zPort znet accId bl = do
BC.writeBChan chan $ TickMsg "Preparing shielding transaction..."
res <- runNoLoggingT $ shieldTransparentNotes pool zHost zPort znet accId bl
forM_ res $ \case
Left e -> BC.writeBChan chan $ TickMsg $ show e
Right rawTx -> do
BC.writeBChan chan $ TickMsg "Transaction ready, sending to Zebra..."
resp <-
makeZebraCall
zHost
zPort
"sendrawtransaction"
[Data.Aeson.String $ toText rawTx]
case resp of
Left e1 -> BC.writeBChan chan $ TickMsg $ "Zebra error: " ++ show e1
Right txId -> BC.writeBChan chan $ TickTx txId
ops <-
mapM
(\case
Left e -> return $ T.pack $ show e
Right x -> do
thisOp <- getOperation pool x
case thisOp of
Nothing -> return ""
Just o ->
return $
(U.toText . getUuid . operationUuid $ entityVal o) <>
": " <> (T.pack . show . operationStatus $ entityVal o))
res
BC.writeBChan chan $ TickMsg $ T.unpack $ T.intercalate "\n" ops
deshieldTransaction ::
ConnectionPool
@ -2072,7 +2053,7 @@ deshieldTransaction ::
-> ZcashNet
-> ZcashAccountId
-> Int
-> ProposedNote
-> Scientific
-> IO ()
deshieldTransaction pool chan zHost zPort znet accId bl pnote = do
BC.writeBChan chan $ TickMsg "Deshielding funds..."

View file

@ -3,6 +3,7 @@
-- | Core wallet functionality for Zenith
module Zenith.Core where
import Control.Concurrent (forkIO)
import Control.Exception (throwIO, try)
import Control.Monad (forM, unless, when)
import Control.Monad.IO.Class (liftIO)
@ -25,6 +26,8 @@ import Data.Scientific (Scientific, scientific, toBoundedInteger)
import qualified Data.Text as T
import qualified Data.Text.Encoding as E
import Data.Time
import qualified Data.UUID as U
import Data.UUID.V4 (nextRandom)
import qualified Database.Esqueleto.Experimental as ESQ
import Database.Persist
import Database.Persist.Sqlite
@ -41,6 +44,7 @@ import ZcashHaskell.Orchard
, getOrchardTreeParts
, getOrchardWitness
, isValidUnifiedAddress
, parseAddress
, updateOrchardCommitmentTree
, updateOrchardWitness
)
@ -80,7 +84,10 @@ import Zenith.Types
, ValidAddressAPI(..)
, ZcashNetDB(..)
, ZebraTreeInfo(..)
, ZenithStatus(..)
, ZenithUuid(..)
)
import Zenith.Utils (getTransparentFromUA)
-- * Zebra Node interaction
-- | Checks the status of the `zebrad` node
@ -746,14 +753,37 @@ deshieldNotes ::
-> ZcashNet
-> ZcashAccountId
-> Int
-> ProposedNote
-> Scientific
-> NoLoggingT IO (Either TxError HexString)
deshieldNotes pool zebraHost zebraPort znet za bh pnote = do
bal <- liftIO $ getShieldedBalance pool za
let zats = pn_amt pnote * scientific 1 8
addrs <- getAddresses pool za
let defAddr =
parseAddress $
E.encodeUtf8 $ getUA $ walletAddressUAddress $ entityVal $ head addrs
case defAddr of
Nothing -> return $ Left ZHError
Just (Unified x) -> do
case getTransparentFromUA x of
Nothing -> return $ Left ZHError
Just ta -> do
let zats = pnote * scientific 1 8
if fromInteger bal > (scientific 2 4 + zats)
then prepareTxV2 pool zebraHost zebraPort znet za bh [pnote] Low
then prepareTxV2
pool
zebraHost
zebraPort
znet
za
bh
[ ProposedNote
(ValidAddressAPI $ Transparent ta)
pnote
Nothing
]
Low
else return $ Left InsufficientFunds
_anyOther -> return $ Left ZHError
shieldTransparentNotes ::
ConnectionPool
@ -762,8 +792,8 @@ shieldTransparentNotes ::
-> ZcashNet
-> ZcashAccountId
-> Int
-> NoLoggingT IO [Either TxError HexString]
shieldTransparentNotes pool zebraHost zebraPort znet za bh = do
-> NoLoggingT IO [Either TxError U.UUID]
shieldTransparentNotes pool zHost zPort znet za bh = do
accRead <- liftIO $ getAccountById pool za
logDebugN $ T.pack $ "Target block: " ++ show bh
case accRead of
@ -772,15 +802,29 @@ shieldTransparentNotes pool zebraHost zebraPort znet za bh = do
return [Left ZHError]
Just acc -> do
trNotes' <- liftIO $ getWalletUnspentTrNotes pool za
if null trNotes'
then return [Left InsufficientFunds]
else do
dRecvs <- liftIO $ getReceivers pool trNotes'
let fNotes =
map
(\x ->
filter (\y -> walletTrNoteAddress (entityVal y) == x) trNotes')
filter
(\y -> walletTrNoteAddress (entityVal y) == x)
trNotes')
dRecvs
sTree <- liftIO $ getSaplingTree pool
oTree <- liftIO $ getOrchardTree pool
forM fNotes $ \trNotes -> do
opid <- liftIO nextRandom
startTime <- liftIO getCurrentTime
opkey <-
liftIO $
saveOperation pool $
Operation (ZenithUuid opid) startTime Nothing Processing Nothing
case opkey of
Nothing -> return $ Left ZHError
Just opkey' -> do
let noteTotal = getTotalAmount (trNotes, [], [])
tSpends <-
liftIO $
@ -796,7 +840,8 @@ shieldTransparentNotes pool zebraHost zebraPort znet za bh = do
let dummy =
OutgoingNote
4
(getBytes $ getOrchSK $ zcashAccountOrchSpendKey $ entityVal acc)
(getBytes $
getOrchSK $ zcashAccountOrchSpendKey $ entityVal acc)
(getBytes oRcvr)
(fromIntegral $ noteTotal - 500)
""
@ -805,11 +850,15 @@ shieldTransparentNotes pool zebraHost zebraPort znet za bh = do
let snote =
OutgoingNote
4
(getBytes $ getOrchSK $ zcashAccountOrchSpendKey $ entityVal acc)
(getBytes $
getOrchSK $ zcashAccountOrchSpendKey $ entityVal acc)
(getBytes oRcvr)
(fromIntegral $ noteTotal - fromIntegral feeAmt)
""
True
_ <-
liftIO $
forkIO $ do
tx <-
liftIO $
createTransaction
@ -822,8 +871,25 @@ shieldTransparentNotes pool zebraHost zebraPort znet za bh = do
znet
(bh + 3)
True
logDebugN $ T.pack $ show tx
return tx
case tx of
Left e ->
finalizeOperation pool opkey' Failed $ T.pack $ show e
Right rawTx -> do
zebraRes <-
makeZebraCall
zHost
zPort
"sendrawtransaction"
[Data.Aeson.String $ toText rawTx]
case zebraRes of
Left e1 ->
finalizeOperation pool opkey' Failed $
T.pack $ show e1
Right txId ->
finalizeOperation pool opkey' Successful $
"Tx ID: " <> toText txId
logDebugN $ T.pack $ show opid
return $ Right opid
where
getTotalAmount ::
( [Entity WalletTrNote]

View file

@ -630,6 +630,7 @@ getAddresses pool a =
addrs <- from $ table @WalletAddress
where_ (addrs ^. WalletAddressAccId ==. val a)
where_ (addrs ^. WalletAddressScope ==. val (ScopeDB External))
orderBy [asc $ addrs ^. WalletAddressId]
pure addrs
getAddressById ::

View file

@ -28,6 +28,7 @@ import Data.Scientific (Scientific, fromFloatDigits)
import qualified Data.Text as T
import qualified Data.Text.Encoding as E
import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
import qualified Data.UUID as U
import Database.Esqueleto.Experimental (ConnectionPool, fromSqlKey)
import Database.Persist
import Lens.Micro ((&), (+~), (.~), (?~), (^.), set)
@ -1768,19 +1769,20 @@ shieldTransaction config znet accId sendMsg = do
pool <- runNoLoggingT $ initPool dbPath
bl <- getChainTip zHost zPort
res <- runNoLoggingT $ shieldTransparentNotes pool zHost zPort znet accId bl
forM_ res $ \case
Left e -> sendMsg $ ShowError $ T.pack (show e)
Right rawTx -> do
sendMsg $ ShowMsg "Transaction ready, sending to Zebra..."
resp <-
makeZebraCall
zHost
zPort
"sendrawtransaction"
[Data.Aeson.String $ toText rawTx]
case resp of
Left e1 -> sendMsg $ ShowError $ "Zebra error: " <> T.pack (show e1)
Right txId -> sendMsg $ ShowTxId txId
ops <-
mapM
(\case
Left e -> return $ T.pack $ show e
Right x -> do
thisOp <- getOperation pool x
case thisOp of
Nothing -> return ""
Just o ->
return $
(U.toText . getUuid . operationUuid $ entityVal o) <>
": " <> (T.pack . show . operationStatus $ entityVal o))
res
sendMsg $ ShowMsg $ T.intercalate "\n" ops
deshieldTransaction ::
Config
@ -1800,27 +1802,7 @@ deshieldTransaction config znet accId addR pnote sendMsg = do
let zPort = c_zebraPort config
pool <- runNoLoggingT $ initPool dbPath
bl <- getChainTip zHost zPort
let tAddrMaybe =
Transparent <$>
((decodeTransparentAddress .
E.encodeUtf8 . encodeTransparentReceiver znet) =<<
(t_rec =<<
(isValidUnifiedAddress .
E.encodeUtf8 . getUA . walletAddressUAddress)
(entityVal addr)))
case tAddrMaybe of
Nothing -> sendMsg $ ShowError "No transparent address available"
Just tAddr -> do
res <-
runNoLoggingT $
deshieldNotes
pool
zHost
zPort
znet
accId
bl
(ProposedNote (ValidAddressAPI tAddr) pnote Nothing)
res <- runNoLoggingT $ deshieldNotes pool zHost zPort znet accId bl pnote
case res of
Left e -> sendMsg $ ShowError $ T.pack (show e)
Right rawTx -> do

View file

@ -13,14 +13,14 @@
module Zenith.RPC where
import Control.Concurrent (forkIO)
import Control.Exception (try)
import Control.Monad (unless, when)
import Control.Exception (SomeException(..), try)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Logger (runFileLoggingT, runNoLoggingT, runStderrLoggingT)
import Control.Monad.Logger (runNoLoggingT, runStderrLoggingT)
import Data.Aeson
import qualified Data.HexString as H
import Data.Int
import Data.Scientific (floatingOrInteger)
import Data.Scientific (Scientific(..), floatingOrInteger)
import qualified Data.Text as T
import qualified Data.Text.Encoding as E
import Data.Time.Clock (getCurrentTime)
@ -36,7 +36,7 @@ import Database.Esqueleto.Experimental
)
import Servant
import Text.Read (readMaybe)
import ZcashHaskell.Keys (generateWalletSeedPhrase)
import ZcashHaskell.Keys (deriveUfvk, deriveUivk, generateWalletSeedPhrase)
import ZcashHaskell.Orchard (parseAddress)
import ZcashHaskell.Types
( BlockResponse(..)
@ -50,7 +50,9 @@ import Zenith.Core
( checkBlockChain
, createCustomWalletAddress
, createZcashAccount
, deshieldNotes
, prepareTxV2
, shieldTransparentNotes
, syncWallet
, updateCommitmentTrees
)
@ -96,9 +98,12 @@ import Zenith.Types
( AccountBalance(..)
, Config(..)
, HexStringDB(..)
, OrchardSpendingKeyDB(..)
, PhraseDB(..)
, PrivacyPolicy(..)
, ProposedNote(..)
, SaplingSpendingKeyDB(..)
, TransparentSpendingKeyDB(..)
, ZcashAccountAPI(..)
, ZcashAddressAPI(..)
, ZcashNetDB(..)
@ -121,6 +126,10 @@ data ZenithMethod
| GetNewAddress
| GetOperationStatus
| SendMany
| ShieldNotes
| DeshieldFunds
| GetFVK
| GetIVK
| UnknownMethod
deriving (Eq, Prelude.Show)
@ -136,6 +145,10 @@ instance ToJSON ZenithMethod where
toJSON GetNewAddress = Data.Aeson.String "getnewaddress"
toJSON GetOperationStatus = Data.Aeson.String "getoperationstatus"
toJSON SendMany = Data.Aeson.String "sendmany"
toJSON ShieldNotes = Data.Aeson.String "shieldnotes"
toJSON DeshieldFunds = Data.Aeson.String "deshieldfunds"
toJSON GetFVK = Data.Aeson.String "getfullvk"
toJSON GetIVK = Data.Aeson.String "getincomingvk"
toJSON UnknownMethod = Data.Aeson.Null
instance FromJSON ZenithMethod where
@ -152,6 +165,10 @@ instance FromJSON ZenithMethod where
"getnewaddress" -> pure GetNewAddress
"getoperationstatus" -> pure GetOperationStatus
"sendmany" -> pure SendMany
"shieldnotes" -> pure ShieldNotes
"deshieldfunds" -> pure DeshieldFunds
"getfullvk" -> pure GetFVK
"getincomingvk" -> pure GetIVK
_ -> pure UnknownMethod
data ZenithParams
@ -167,6 +184,9 @@ data ZenithParams
| OpParams !ZenithUuid
| SendParams !Int ![ProposedNote] !PrivacyPolicy
| TestParams !T.Text
| ShieldNotesParams !Int
| DeshieldParams !Int !Scientific
| ViewingKeyParams !Int
deriving (Eq, Prelude.Show)
instance ToJSON ZenithParams where
@ -191,6 +211,10 @@ instance ToJSON ZenithParams where
Data.Aeson.Array $ V.fromList [Data.Aeson.String $ U.toText $ getUuid i]
toJSON (SendParams i ns p) =
Data.Aeson.Array $ V.fromList [jsonNumber i, toJSON ns, toJSON p]
toJSON (ShieldNotesParams i) = Data.Aeson.Array $ V.fromList [jsonNumber i]
toJSON (DeshieldParams i s) =
Data.Aeson.Array $ V.fromList [jsonNumber i, Data.Aeson.Number s]
toJSON (ViewingKeyParams i) = Data.Aeson.Array $ V.fromList [jsonNumber i]
data ZenithResponse
= InfoResponse !T.Text !ZenithInfo
@ -203,6 +227,8 @@ data ZenithResponse
| NewAddrResponse !T.Text !ZcashAddressAPI
| OpResponse !T.Text !Operation
| SendResponse !T.Text !U.UUID
| MultiOpResponse !T.Text ![T.Text]
| ViewingKeyResponse !T.Text !T.Text
| ErrorResponse !T.Text !Double !T.Text
deriving (Eq, Prelude.Show)
@ -224,6 +250,8 @@ instance ToJSON ZenithResponse where
toJSON (NewAddrResponse i a) = packRpcResponse i a
toJSON (OpResponse i u) = packRpcResponse i u
toJSON (SendResponse i o) = packRpcResponse i o
toJSON (MultiOpResponse i o) = packRpcResponse i o
toJSON (ViewingKeyResponse i k) = packRpcResponse i k
instance FromJSON ZenithResponse where
parseJSON =
@ -298,6 +326,9 @@ instance FromJSON ZenithResponse where
k5 <- parseJSON r1
pure $ NoteListResponse i k5
Nothing -> fail "Unknown object"
String s -> do
k7 <- parseJSON r1
pure $ MultiOpResponse i k7
_anyOther -> fail "Malformed JSON"
Number k -> do
case floatingOrInteger k of
@ -305,7 +336,7 @@ instance FromJSON ZenithResponse where
Right k' -> pure $ NewItemResponse i k'
String s -> do
case U.fromText s of
Nothing -> fail "Unknown value"
Nothing -> pure $ ViewingKeyResponse i s
Just u -> pure $ SendResponse i u
_anyOther -> fail "Malformed JSON"
Just e1 -> pure $ ErrorResponse i (ecode e1) (emessage e1)
@ -489,6 +520,47 @@ instance FromJSON RpcCall where
_anyOther -> pure $ RpcCall v i SendMany BadParams
else pure $ RpcCall v i SendMany BadParams
_anyOther -> pure $ RpcCall v i SendMany BadParams
ShieldNotes -> do
p <- obj .: "params"
case p of
Array a ->
if V.length a == 1
then do
x <- parseJSON $ a V.! 0
pure $ RpcCall v i ShieldNotes (ShieldNotesParams x)
else pure $ RpcCall v i ShieldNotes BadParams
_anyOther -> pure $ RpcCall v i ShieldNotes BadParams
DeshieldFunds -> do
p <- obj .: "params"
case p of
Array a ->
if V.length a == 2
then do
x <- parseJSON $ a V.! 0
y <- parseJSON $ a V.! 1
pure $ RpcCall v i DeshieldFunds (DeshieldParams x y)
else pure $ RpcCall v i DeshieldFunds BadParams
_anyOther -> pure $ RpcCall v i DeshieldFunds BadParams
GetFVK -> do
p <- obj .: "params"
case p of
Array a ->
if V.length a == 1
then do
x <- parseJSON $ a V.! 0
pure $ RpcCall v i GetFVK (ViewingKeyParams x)
else pure $ RpcCall v i GetFVK BadParams
_anyOther -> pure $ RpcCall v i GetFVK BadParams
GetIVK -> do
p <- obj .: "params"
case p of
Array a ->
if V.length a == 1
then do
x <- parseJSON $ a V.! 0
pure $ RpcCall v i GetIVK (ViewingKeyParams x)
else pure $ RpcCall v i GetIVK BadParams
_anyOther -> pure $ RpcCall v i GetIVK BadParams
type ZenithRPC
= "status" :> Get '[ JSON] Value :<|> BasicAuth "zenith-realm" Bool :> ReqBody
@ -511,7 +583,7 @@ zenithServer state = getinfo :<|> handleRPC
getinfo =
return $
object
[ "version" .= ("0.7.0.0-beta" :: String)
[ "version" .= ("0.8.0.0-beta" :: String)
, "network" .= ("testnet" :: String)
]
handleRPC :: Bool -> RpcCall -> Handler ZenithResponse
@ -587,7 +659,7 @@ zenithServer state = getinfo :<|> handleRPC
return $
InfoResponse
(callId req)
(ZenithInfo "0.7.0.0-beta" (w_network state) (w_build state))
(ZenithInfo "0.8.0.0-beta" (w_network state) (w_build state))
_anyOtherParams ->
return $ ErrorResponse (callId req) (-32602) "Invalid params"
ListReceived ->
@ -871,6 +943,193 @@ zenithServer state = getinfo :<|> handleRPC
"Account does not exist."
_anyOtherParams ->
return $ ErrorResponse (callId req) (-32602) "Invalid params"
ShieldNotes -> do
case parameters req of
ShieldNotesParams i -> do
let dbPath = w_dbPath state
let net = w_network state
let zHost = w_host state
let zPort = w_port state
pool <- liftIO $ runNoLoggingT $ initPool dbPath
syncChk <- liftIO $ isSyncing pool
if syncChk
then return $
ErrorResponse
(callId req)
(-32012)
"The Zenith server is syncing, please try again later."
else do
acc <-
liftIO $ getAccountById pool $ toSqlKey $ fromIntegral i
case acc of
Just acc' -> do
bl <-
liftIO $
getLastSyncBlock
pool
(zcashAccountWalletId $ entityVal acc')
opids <-
liftIO $
runNoLoggingT $
shieldTransparentNotes
pool
zHost
zPort
net
(entityKey acc')
bl
let ops =
map
(\case
Left e -> T.pack $ show e
Right op -> U.toText op)
opids
return $ MultiOpResponse (callId req) ops
Nothing ->
return $
ErrorResponse
(callId req)
(-32006)
"Account does not exist."
_anyOtherParams ->
return $ ErrorResponse (callId req) (-32602) "Invalid params"
DeshieldFunds -> do
case parameters req of
DeshieldParams i k -> do
let dbPath = w_dbPath state
let net = w_network state
let zHost = w_host state
let zPort = w_port state
pool <- liftIO $ runNoLoggingT $ initPool dbPath
syncChk <- liftIO $ isSyncing pool
if syncChk
then return $
ErrorResponse
(callId req)
(-32012)
"The Zenith server is syncing, please try again later."
else do
opid <- liftIO nextRandom
startTime <- liftIO getCurrentTime
opkey <-
liftIO $
saveOperation pool $
Operation
(ZenithUuid opid)
startTime
Nothing
Processing
Nothing
case opkey of
Nothing ->
return $
ErrorResponse (callId req) (-32010) "Internal Error"
Just opkey' -> do
acc <-
liftIO $ getAccountById pool $ toSqlKey $ fromIntegral i
case acc of
Just acc' -> do
bl <-
liftIO $
getLastSyncBlock
pool
(zcashAccountWalletId $ entityVal acc')
_ <-
liftIO $
forkIO $ do
res <-
runNoLoggingT $
deshieldNotes
pool
zHost
zPort
net
(entityKey acc')
bl
k
case res of
Left e ->
finalizeOperation pool opkey' Failed $
T.pack $ show e
Right rawTx -> do
zebraRes <-
makeZebraCall
zHost
zPort
"sendrawtransaction"
[Data.Aeson.String $ H.toText rawTx]
case zebraRes of
Left e1 ->
finalizeOperation pool opkey' Failed $
T.pack $ show e1
Right txId ->
finalizeOperation pool opkey' Successful $
"Tx ID: " <> H.toText txId
return $ SendResponse (callId req) opid
Nothing ->
return $
ErrorResponse
(callId req)
(-32006)
"Account does not exist."
_anyOtherParams ->
return $ ErrorResponse (callId req) (-32602) "Invalid params"
GetFVK -> do
case parameters req of
ViewingKeyParams aid -> do
let dbPath = w_dbPath state
let net = w_network state
pool <- liftIO $ runNoLoggingT $ initPool dbPath
acc <- liftIO $ getAccountById pool $ toSqlKey $ fromIntegral aid
case acc of
Just acc' -> do
fvk <-
liftIO $
try
(deriveUfvk
net
(getOrchSK $ zcashAccountOrchSpendKey $ entityVal acc')
(getSapSK $ zcashAccountSapSpendKey $ entityVal acc')
(getTranSK $ zcashAccountTPrivateKey $ entityVal acc')) :: Handler
(Either SomeException T.Text)
case fvk of
Left _ ->
return $
ErrorResponse (callId req) (-32010) "Internal Error"
Right fvk' -> return $ ViewingKeyResponse (callId req) fvk'
Nothing ->
return $
ErrorResponse (callId req) (-32006) "Account does not exist."
_anyOtherParams ->
return $ ErrorResponse (callId req) (-32602) "Invalid params"
GetIVK -> do
case parameters req of
ViewingKeyParams aid -> do
let dbPath = w_dbPath state
let net = w_network state
pool <- liftIO $ runNoLoggingT $ initPool dbPath
acc <- liftIO $ getAccountById pool $ toSqlKey $ fromIntegral aid
case acc of
Just acc' -> do
ivk <-
liftIO $
try
(deriveUivk
net
(getOrchSK $ zcashAccountOrchSpendKey $ entityVal acc')
(getSapSK $ zcashAccountSapSpendKey $ entityVal acc')
(getTranSK $ zcashAccountTPrivateKey $ entityVal acc')) :: Handler
(Either SomeException T.Text)
case ivk of
Left _ ->
return $
ErrorResponse (callId req) (-32010) "Internal Error"
Right ivk' -> return $ ViewingKeyResponse (callId req) ivk'
Nothing ->
return $
ErrorResponse (callId req) (-32006) "Account does not exist."
_anyOtherParams ->
return $ ErrorResponse (callId req) (-32602) "Invalid params"
authenticate :: Config -> BasicAuthCheck Bool
authenticate config = BasicAuthCheck check

View file

@ -235,7 +235,7 @@ isValidString c = do
padWithZero :: Int -> String -> String
padWithZero n s
| (length s) >= n = s
| length s >= n = s
| otherwise = padWithZero n ("0" ++ s)
isEmpty :: [a] -> Bool
@ -248,3 +248,6 @@ getChainTip zHost zPort = do
case r of
Left e1 -> pure 0
Right i -> pure i
getTransparentFromUA :: UnifiedAddress -> Maybe TransparentAddress
getTransparentFromUA ua = TransparentAddress (ua_net ua) <$> t_rec ua

View file

@ -86,7 +86,7 @@ main = do
Left e -> assertFailure e
Right r ->
r `shouldBe`
InfoResponse "zh" (ZenithInfo "0.7.0.0-beta" TestNet "v1.9.0")
InfoResponse "zh" (ZenithInfo "0.8.0.0-beta" TestNet "v2.1.0")
describe "Wallets" $ do
describe "listwallet" $ do
it "bad credentials" $ do
@ -676,6 +676,153 @@ main = do
case res of
Left e -> assertFailure e
Right (SendResponse i o) -> o `shouldNotBe` U.nil
describe "Shield notes" $ do
it "bad credentials" $ do
res <-
makeZenithCall
"127.0.0.1"
nodePort
"baduser"
"idontknow"
ShieldNotes
BlankParams
res `shouldBe` Left "Invalid credentials"
describe "correct credentials" $ do
it "no parameters" $ do
res <-
makeZenithCall
"127.0.0.1"
nodePort
nodeUser
nodePwd
ShieldNotes
BlankParams
case res of
Left e -> assertFailure e
Right (ErrorResponse i c m) -> c `shouldBe` (-32602)
it "invalid account" $ do
res <-
makeZenithCall
"127.0.0.1"
nodePort
nodeUser
nodePwd
ShieldNotes
(ShieldNotesParams 27)
case res of
Left e -> assertFailure e
Right (ErrorResponse i c m) -> c `shouldBe` (-32006)
it "valid account" $ do
res <-
makeZenithCall
"127.0.0.1"
nodePort
nodeUser
nodePwd
ShieldNotes
(ShieldNotesParams 1)
case res of
Left e -> assertFailure e
Right (MultiOpResponse i c) -> c `shouldNotBe` []
describe "Viewing Keys" $ do
describe "Full" $ do
it "bad credentials" $ do
res <-
makeZenithCall
"127.0.0.1"
nodePort
"baduser"
"idontknow"
GetFVK
BlankParams
res `shouldBe` Left "Invalid credentials"
describe "correct credentials" $ do
it "no parameters" $ do
res <-
makeZenithCall
"127.0.0.1"
nodePort
nodeUser
nodePwd
GetFVK
BlankParams
case res of
Left e -> assertFailure e
Right (ErrorResponse i c m) -> c `shouldBe` (-32602)
it "invalid account" $ do
res <-
makeZenithCall
"127.0.0.1"
nodePort
nodeUser
nodePwd
GetFVK
(ViewingKeyParams 27)
case res of
Left e -> assertFailure e
Right (ErrorResponse i c m) -> c `shouldBe` (-32006)
it "valid account" $ do
res <-
makeZenithCall
"127.0.0.1"
nodePort
nodeUser
nodePwd
GetFVK
(ViewingKeyParams 1)
case res of
Left e -> assertFailure e
Right (ViewingKeyResponse i c) -> c `shouldNotBe` ""
Right x -> assertFailure $ show x
describe "Incoming" $ do
it "bad credentials" $ do
res <-
makeZenithCall
"127.0.0.1"
nodePort
"baduser"
"idontknow"
GetIVK
BlankParams
res `shouldBe` Left "Invalid credentials"
describe "correct credentials" $ do
it "no parameters" $ do
res <-
makeZenithCall
"127.0.0.1"
nodePort
nodeUser
nodePwd
GetIVK
BlankParams
case res of
Left e -> assertFailure e
Right (ErrorResponse i c m) -> c `shouldBe` (-32602)
it "invalid account" $ do
res <-
makeZenithCall
"127.0.0.1"
nodePort
nodeUser
nodePwd
GetIVK
(ViewingKeyParams 27)
case res of
Left e -> assertFailure e
Right (ErrorResponse i c m) -> c `shouldBe` (-32006)
it "valid account" $ do
res <-
makeZenithCall
"127.0.0.1"
nodePort
nodeUser
nodePwd
GetIVK
(ViewingKeyParams 1)
case res of
Left e -> assertFailure e
Right (ViewingKeyResponse i c) -> c `shouldNotBe` ""
Right x -> assertFailure $ show x
startAPI :: Config -> IO ()
startAPI config = do

View file

@ -643,8 +643,7 @@ main = do
case ix of
Nothing -> assertFailure "couldn't find index at block"
Just i -> do
updatedTree <-
runFileLoggingT "test.log" $ truncateTree oTree i
updatedTree <- runNoLoggingT $ truncateTree oTree i
let finalAnchor =
getOrchardTreeAnchor $
OrchardCommitmentTree $ ztiOrchard zebraTreesIn
@ -737,7 +736,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"
@ -763,7 +762,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"
@ -787,7 +786,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"
@ -815,7 +814,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"
@ -847,7 +846,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"
@ -873,7 +872,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"
@ -897,7 +896,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"
@ -926,7 +925,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"
@ -957,7 +956,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"
@ -983,7 +982,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"
@ -1007,7 +1006,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"
@ -1034,7 +1033,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"
@ -1061,7 +1060,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"
@ -1086,7 +1085,7 @@ main = do
Just ua -> do
pool <- runNoLoggingT $ initPool "/home/rav/Zenith/zenith.db"
tx <-
runFileLoggingT "zenith.log" $
runNoLoggingT $
prepareTxV2
pool
"localhost"

View file

@ -1,7 +1,7 @@
{
"openrpc": "1.0.0-rc1",
"info": {
"version": "0.7.0.0-beta",
"version": "0.8.0.0-beta",
"title": "Zenith RPC",
"description": "The RPC methods to interact with the Zenith Zcash wallet",
"license": {
@ -605,10 +605,9 @@
],
"paramStructure": "by-position",
"result": {
"name": "Operation ID(s)",
"name": "Operation ID",
"schema": {
"type": "array",
"items": { "$ref": "#/components/contentDescriptors/OperationId"}
"$ref": "#/components/contentDescriptors/OperationId"
}
},
"examples": [
@ -620,7 +619,7 @@
{
"name": "Account index",
"summary": "The index for the account to use",
"value": "1"
"value": 1
},
{
"name": "Privacy Policy",
@ -641,9 +640,8 @@
],
"result": {
"name": "SendMany result",
"value": [
"3cc31c07-07cf-4a6e-9190-156c4b8c4088"
]
"value": "3cc31c07-07cf-4a6e-9190-156c4b8c4088"
}
}
],
@ -669,6 +667,204 @@
"errors": [
{ "$ref": "#/components/errors/OpNotFound" }
]
},
{
"name": "shieldnotes",
"summary": "Shield all transparent notes into the Orchard pool for the given account",
"description": "Creates one or more transactions, grouping all the unspent transparent notes for the given account by their transparent address to avoid associating different transparent addresses. These notes are sent to the given account's internal change address as shielded Orchard notes.",
"tags": [],
"params": [
{ "$ref": "#/components/contentDescriptors/AccountId"}
],
"paramStructure": "by-position",
"result": {
"name": "Operation ID(s)",
"schema": {
"type": "array",
"items": { "$ref": "#/components/contentDescriptors/OperationId"}
}
},
"examples": [
{
"name": "Shield transparent notes",
"summary": "Shield transparent notes",
"description": "Shield the transparent notes in a given account",
"params": [
{
"name": "Account index",
"summary": "The index for the account to use",
"value": "3"
}
],
"result": {
"name": "ShieldNotes result",
"value": [
"ab350df0-9f57-44c0-9e0d-f7b8af1f4231",
"8c6f2656-22ef-4f9d-b465-80ddd13fc485"
]
}
},
{
"name": "No transparent funds",
"summary": "Shield transparent notes with no transparent funds",
"description": "Attempt to shield the transparent notes in a given account, when account has none",
"params": [
{
"name": "Account index",
"summary": "The index for the account to use",
"value": "3"
}
],
"result": {
"name": "ShieldNotes result",
"value": [
"InsufficientFunds"
]
}
}
],
"errors": [
{ "$ref": "#/components/errors/ZebraNotAvailable" },
{ "$ref": "#/components/errors/ZenithBusy" },
{ "$ref": "#/components/errors/InvalidAccount" }
]
},
{
"name": "deshieldfunds",
"summary": "De-shield the given amount of ZEC from the given account",
"description": "Creates a new internal transaction with the requested amount of ZEC to the transparent pool. The fee is not included in the given amount.",
"tags": [],
"params": [
{ "$ref": "#/components/contentDescriptors/AccountId"},
{ "$ref": "#/components/contentDescriptors/Amount"}
],
"paramStructure": "by-position",
"result": {
"name": "Operation ID",
"schema": {
"$ref": "#/components/contentDescriptors/OperationId"
}
},
"examples": [
{
"name": "De-Shield funds",
"summary": "De-shield funds",
"description": "Move the given amount of ZEC for the given acount from the shielded pool to the transparent pool",
"params": [
{
"name": "Account index",
"summary": "The index for the account to use",
"value": "3"
},
{
"name": "Amount",
"summary": "The amount of ZEC to use",
"value": 1.23
}
],
"result": {
"name": "Deshield funds result",
"value": "ab350df0-9f57-44c0-9e0d-f7b8af1f4231"
}
},
{
"name": "No transparent funds",
"summary": "Shield transparent notes with no transparent funds",
"description": "Attempt to shield the transparent notes in a given account, when account has none",
"params": [
{
"name": "Account index",
"summary": "The index for the account to use",
"value": "3"
}
],
"result": {
"name": "ShieldNotes result",
"value": [
"InsufficientFunds"
]
}
}
],
"errors": [
{ "$ref": "#/components/errors/ZebraNotAvailable" },
{ "$ref": "#/components/errors/ZenithBusy" },
{ "$ref": "#/components/errors/InvalidAccount" }
]
},
{
"name": "getfullvk",
"summary": "Derive the full viewing key for the given account.",
"description": "Derive the full viewing key for the given account, encoded per ZIP-316.",
"tags": [],
"params": [
{ "$ref": "#/components/contentDescriptors/AccountId"}
],
"paramStructure": "by-position",
"result": {
"name": "Full viewing key",
"schema": {
"$ref": "#/components/schemas/ViewingKey"
}
},
"examples": [
{
"name": "Get full viewing key",
"summary": "Get the full viewing key",
"description": "Get the full viewing key for the give account, encoded per ZIP-316",
"params": [
{
"name": "Account index",
"summary": "The index for the account to use",
"value": 1
}
],
"result": {
"name": "Full Viewing key",
"value": "uview16qdhd9e283s4y53gmw72ag7adzdrj9f9v96dw89ggv9el0yrf7vkappau69j8luq7uf540sr78ncslnqk6kwpc4qeqgfg5vn4xcmllynyfr32cgq6nx5ptku44kfxtsj99px2g9yp7kyc32quun0elakgltqmqflprwmryuelcfwwt58vqap065as7qwljg02l6mkutsh2y9aefd284dsrj0246fd2n4hra3r03uftsh4njh3w590z78tpnfqhjvvwhgus476zrw3fd69qekru709ghr0zr7h8majy9aclwg7uhakt24lmuec8dd7t270kamcs99rz8jasj3jl6m9y77dvkdn23e2kwuc6kyagpstzrdjnlzdldmgsu4k056v80ucajcjvl99pcf2znjg37vztdp4zr5qrphxs4y7wppxmankmdwwgjxhlmyrjd68z80q0n0t2cyqge6mlc7pd5wre4392pjtdaqvtyeg0denh4ekynnjxnm"
}
}
],
"errors": [
{ "$ref": "#/components/errors/InvalidAccount" }
]
},
{
"name": "getincomingvk",
"summary": "Get the incoming viewing key for the given account.",
"description": "Derives the incoming viewing key for the given account per ZIP-316.",
"tags": [],
"params": [
{ "$ref": "#/components/contentDescriptors/AccountId"}
],
"paramStructure": "by-position",
"result": {
"name": "Incoming viewing key",
"schema": {
"$ref": "#/components/schemas/ViewingKey"
}
},
"examples": [
{
"name": "Get incoming viewing key",
"summary": "Get the incoming viewing key",
"description": "Get the incoming viewing key for the give account, encoded per ZIP-316",
"params": [
{
"name": "Account index",
"summary": "The index for the account to use",
"value": 1
}
],
"result": {
"name": "Incoming Viewing key",
"value": "uivk199qcjxrj73n7fapg79a2ltah6f3j83haljcux5t5kvn5unn7rpfmvglttdt9g6na3llkefnd3pn0x9ky6lh8s42trj0vfg5wtv0nrerq0wsq5v4q7lt5j4l9svppspr6h7407ztgsuvkfk977c3tj408nx5phxap8fn3ecdmdrah9spp76md9tel89tuqz6m0xplqp83wj33qf7s3hwfe79t04rq49g24nr3emlpm298wpqla2dvh4rr584kwdtxc9ahse5x0drcjr95tt4k0hxr32l6yturje7dptlgjnr4cm6uk29ysu9l5xwgz40p6alyedzzqltqf5nswy48ekru4ahapw"
}
}
],
"errors": [
{ "$ref": "#/components/errors/InvalidAccount" }
]
}
],
"components": {
@ -700,6 +896,15 @@
"type": "string"
}
},
"Amount": {
"name": "A numeric amount",
"summary": "A numeric amount",
"description": "A number that represents an amount to be used by a function as an input",
"required": true,
"schema": {
"type": "number"
}
},
"Name": {
"name": "Name",
"summary": "A user-friendly name",
@ -835,6 +1040,10 @@
"amount": { "type": "number", "description": "The amount to send in ZEC"},
"memo": { "type": "string", "description": "The shielded memo to include, if applicable"}
}
},
"ViewingKey": {
"type": "string",
"description": "The viewing key, encoded per ZIP-316"
}
},
"examples": {},

View file

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 KiB