@chainvue/verus-sapling 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +74 -0
  3. package/README.md +194 -0
  4. package/crate/pkg/package.json +17 -0
  5. package/crate/pkg/verus_sapling_prover.d.ts +71 -0
  6. package/crate/pkg/verus_sapling_prover.js +451 -0
  7. package/crate/pkg/verus_sapling_prover_bg.wasm +0 -0
  8. package/crate/pkg/verus_sapling_prover_bg.wasm.d.ts +15 -0
  9. package/dist/browser/grpcweb.d.ts +29 -0
  10. package/dist/browser/grpcweb.js +149 -0
  11. package/dist/browser/index.d.ts +23 -0
  12. package/dist/browser/index.js +23 -0
  13. package/dist/browser/lightwalletd-web.d.ts +36 -0
  14. package/dist/browser/lightwalletd-web.js +186 -0
  15. package/dist/browser/protobuf.d.ts +38 -0
  16. package/dist/browser/protobuf.js +115 -0
  17. package/dist/browser/prover-worker.d.ts +18 -0
  18. package/dist/browser/prover-worker.js +61 -0
  19. package/dist/browser/worker-prover.d.ts +38 -0
  20. package/dist/browser/worker-prover.js +51 -0
  21. package/dist/errors.d.ts +18 -0
  22. package/dist/errors.js +25 -0
  23. package/dist/hex.d.ts +11 -0
  24. package/dist/hex.js +32 -0
  25. package/dist/index.d.ts +33 -0
  26. package/dist/index.js +35 -0
  27. package/dist/lightwalletd.d.ts +113 -0
  28. package/dist/lightwalletd.js +99 -0
  29. package/dist/money.d.ts +23 -0
  30. package/dist/money.js +40 -0
  31. package/dist/parse.d.ts +45 -0
  32. package/dist/parse.js +129 -0
  33. package/dist/types.d.ts +29 -0
  34. package/dist/types.js +13 -0
  35. package/dist/wallet.d.ts +124 -0
  36. package/dist/wallet.js +179 -0
  37. package/dist/wasm.d.ts +91 -0
  38. package/dist/wasm.js +90 -0
  39. package/dist/zaddr.d.ts +19 -0
  40. package/dist/zaddr.js +107 -0
  41. package/package.json +90 -0
  42. package/proto/compact_formats.proto +62 -0
  43. package/proto/darkside.proto +124 -0
  44. package/proto/service.proto +172 -0
@@ -0,0 +1,124 @@
1
+ // Copyright (c) 2019-2020 The Zcash developers
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or https://www.opensource.org/licenses/mit-license.php .
4
+
5
+ syntax = "proto3";
6
+ package cash.z.wallet.sdk.rpc;
7
+ option go_package = "lightwalletd/walletrpc";
8
+ option swift_prefix = "";
9
+ import "service.proto";
10
+
11
+ message DarksideMetaState {
12
+ int32 saplingActivation = 1;
13
+ string branchID = 2;
14
+ string chainName = 3;
15
+ }
16
+
17
+ // A block is a hex-encoded string.
18
+ message DarksideBlock {
19
+ string block = 1;
20
+ }
21
+
22
+ // DarksideBlocksURL is typically something like:
23
+ // https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/basic-reorg/before-reorg.txt
24
+ message DarksideBlocksURL {
25
+ string url = 1;
26
+ }
27
+
28
+ // DarksideTransactionsURL refers to an HTTP source that contains a list
29
+ // of hex-encoded transactions, one per line, that are to be associated
30
+ // with the given height (fake-mined into the block at that height)
31
+ message DarksideTransactionsURL {
32
+ int32 height = 1;
33
+ string url = 2;
34
+ }
35
+
36
+ message DarksideHeight {
37
+ int32 height = 1;
38
+ }
39
+
40
+ message DarksideEmptyBlocks {
41
+ int32 height = 1;
42
+ int32 nonce = 2;
43
+ int32 count = 3;
44
+ }
45
+
46
+ // Darksidewalletd maintains two staging areas, blocks and transactions. The
47
+ // Stage*() gRPCs add items to the staging area; ApplyStaged() "applies" everything
48
+ // in the staging area to the working (operational) state that the mock zcashd
49
+ // serves; transactions are placed into their corresponding blocks (by height).
50
+ service DarksideStreamer {
51
+ // Reset reverts all darksidewalletd state (active block range, latest height,
52
+ // staged blocks and transactions) and lightwalletd state (cache) to empty,
53
+ // the same as the initial state. This occurs synchronously and instantaneously;
54
+ // no reorg happens in lightwalletd. This is good to do before each independent
55
+ // test so that no state leaks from one test to another.
56
+ // Also sets (some of) the values returned by GetLightdInfo(). The Sapling
57
+ // activation height specified here must be where the block range starts.
58
+ rpc Reset(DarksideMetaState) returns (Empty) {}
59
+
60
+ // StageBlocksStream accepts a list of blocks and saves them into the blocks
61
+ // staging area until ApplyStaged() is called; there is no immediate effect on
62
+ // the mock zcashd. Blocks are hex-encoded. Order is important, see ApplyStaged.
63
+ rpc StageBlocksStream(stream DarksideBlock) returns (Empty) {}
64
+
65
+ // StageBlocks is the same as StageBlocksStream() except the blocks are fetched
66
+ // from the given URL. Blocks are one per line, hex-encoded (not JSON).
67
+ rpc StageBlocks(DarksideBlocksURL) returns (Empty) {}
68
+
69
+ // StageBlocksCreate is like the previous two, except it creates 'count'
70
+ // empty blocks at consecutive heights starting at height 'height'. The
71
+ // 'nonce' is part of the header, so it contributes to the block hash; this
72
+ // lets you create identical blocks (same transactions and height), but with
73
+ // different hashes.
74
+ rpc StageBlocksCreate(DarksideEmptyBlocks) returns (Empty) {}
75
+
76
+ // StageTransactionsStream stores the given transaction-height pairs in the
77
+ // staging area until ApplyStaged() is called. Note that these transactions
78
+ // are not returned by the production GetTransaction() gRPC until they
79
+ // appear in a "mined" block (contained in the active blockchain presented
80
+ // by the mock zcashd).
81
+ rpc StageTransactionsStream(stream RawTransaction) returns (Empty) {}
82
+
83
+ // StageTransactions is the same except the transactions are fetched from
84
+ // the given url. They are all staged into the block at the given height.
85
+ // Staging transactions to different heights requires multiple calls.
86
+ rpc StageTransactions(DarksideTransactionsURL) returns (Empty) {}
87
+
88
+ // ApplyStaged iterates the list of blocks that were staged by the
89
+ // StageBlocks*() gRPCs, in the order they were staged, and "merges" each
90
+ // into the active, working blocks list that the mock zcashd is presenting
91
+ // to lightwalletd. Even as each block is applied, the active list can't
92
+ // have gaps; if the active block range is 1000-1006, and the staged block
93
+ // range is 1003-1004, the resulting range is 1000-1004, with 1000-1002
94
+ // unchanged, blocks 1003-1004 from the new range, and 1005-1006 dropped.
95
+ //
96
+ // After merging all blocks, ApplyStaged() appends staged transactions (in
97
+ // the order received) into each one's corresponding (by height) block
98
+ // The staging area is then cleared.
99
+ //
100
+ // The argument specifies the latest block height that mock zcashd reports
101
+ // (i.e. what's returned by GetLatestBlock). Note that ApplyStaged() can
102
+ // also be used to simply advance the latest block height presented by mock
103
+ // zcashd. That is, there doesn't need to be anything in the staging area.
104
+ rpc ApplyStaged(DarksideHeight) returns (Empty) {}
105
+
106
+ // Calls to the production gRPC SendTransaction() store the transaction in
107
+ // a separate area (not the staging area); this method returns all transactions
108
+ // in this separate area, which is then cleared. The height returned
109
+ // with each transaction is -1 (invalid) since these transactions haven't
110
+ // been mined yet. The intention is that the transactions returned here can
111
+ // then, for example, be given to StageTransactions() to get them "mined"
112
+ // into a specified block on the next ApplyStaged().
113
+ rpc GetIncomingTransactions(Empty) returns (stream RawTransaction) {}
114
+
115
+ // Clear the incoming transaction pool.
116
+ rpc ClearIncomingTransactions(Empty) returns (Empty) {}
117
+
118
+ // Add a GetAddressUtxosReply entry to be returned by GetAddressUtxos().
119
+ // There is no staging or applying for these, very simple.
120
+ rpc AddAddressUtxo(GetAddressUtxosReply) returns (Empty) {}
121
+
122
+ // Clear the list of GetAddressUtxos entries (can't fail)
123
+ rpc ClearAddressUtxo(Empty) returns (Empty) {}
124
+ }
@@ -0,0 +1,172 @@
1
+ // Copyright (c) 2019-2020 The Zcash developers
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or https://www.opensource.org/licenses/mit-license.php .
4
+
5
+ syntax = "proto3";
6
+ package cash.z.wallet.sdk.rpc;
7
+ option go_package = "lightwalletd/walletrpc";
8
+ option swift_prefix = "";
9
+ import "compact_formats.proto";
10
+
11
+ // A BlockID message contains identifiers to select a block: a height or a
12
+ // hash. Specification by hash is not implemented, but may be in the future.
13
+ message BlockID {
14
+ uint64 height = 1;
15
+ bytes hash = 2;
16
+ }
17
+
18
+ // BlockRange specifies a series of blocks from start to end inclusive.
19
+ // Both BlockIDs must be heights; specification by hash is not yet supported.
20
+ message BlockRange {
21
+ BlockID start = 1;
22
+ BlockID end = 2;
23
+ }
24
+
25
+ // A TxFilter contains the information needed to identify a particular
26
+ // transaction: either a block and an index, or a direct transaction hash.
27
+ // Currently, only specification by hash is supported.
28
+ message TxFilter {
29
+ BlockID block = 1; // block identifier, height or hash
30
+ uint64 index = 2; // index within the block
31
+ bytes hash = 3; // transaction ID (hash, txid)
32
+ }
33
+
34
+ // RawTransaction contains the complete transaction data. It also optionally includes
35
+ // the block height in which the transaction was included, or, when returned
36
+ // by GetMempoolStream(), the latest block height.
37
+ message RawTransaction {
38
+ bytes data = 1; // exact data returned by Zcash 'getrawtransaction'
39
+ uint64 height = 2; // height that the transaction was mined (or -1)
40
+ }
41
+
42
+ // A SendResponse encodes an error code and a string. It is currently used
43
+ // only by SendTransaction(). If error code is zero, the operation was
44
+ // successful; if non-zero, it and the message specify the failure.
45
+ message SendResponse {
46
+ int32 errorCode = 1;
47
+ string errorMessage = 2;
48
+ }
49
+
50
+ // Chainspec is a placeholder to allow specification of a particular chain fork.
51
+ message ChainSpec {}
52
+
53
+ // Empty is for gRPCs that take no arguments, currently only GetLightdInfo.
54
+ message Empty {}
55
+
56
+ // LightdInfo returns various information about this lightwalletd instance
57
+ // and the state of the blockchain.
58
+ message LightdInfo {
59
+ string version = 1;
60
+ string vendor = 2;
61
+ bool taddrSupport = 3; // true
62
+ string chainName = 4; // either "main" or "test"
63
+ uint64 saplingActivationHeight = 5; // depends on mainnet or testnet
64
+ string consensusBranchId = 6; // protocol identifier, see consensus/upgrades.cpp
65
+ uint64 blockHeight = 7; // latest block on the best chain
66
+ string gitCommit = 8;
67
+ string branch = 9;
68
+ string buildDate = 10;
69
+ string buildUser = 11;
70
+ uint64 estimatedHeight = 12; // less than tip height if zcashd is syncing
71
+ string zcashdBuild = 13; // example: "v4.1.1-877212414"
72
+ string zcashdSubversion = 14; // example: "/MagicBean:4.1.1/"
73
+ string chainID = 15;
74
+ }
75
+
76
+ // TransparentAddressBlockFilter restricts the results to the given address
77
+ // or block range.
78
+ message TransparentAddressBlockFilter {
79
+ string address = 1; // t-address
80
+ BlockRange range = 2; // start, end heights
81
+ }
82
+
83
+ // Duration is currently used only for testing, so that the Ping rpc
84
+ // can simulate a delay, to create many simultaneous connections. Units
85
+ // are microseconds.
86
+ message Duration {
87
+ int64 intervalUs = 1;
88
+ }
89
+
90
+ // PingResponse is used to indicate concurrency, how many Ping rpcs
91
+ // are executing upon entry and upon exit (after the delay).
92
+ // This rpc is used for testing only.
93
+ message PingResponse {
94
+ int64 entry = 1;
95
+ int64 exit = 2;
96
+ }
97
+
98
+ message Address {
99
+ string address = 1;
100
+ }
101
+ message AddressList {
102
+ repeated string addresses = 1;
103
+ }
104
+ message Balance {
105
+ int64 valueZat = 1;
106
+ }
107
+
108
+ // The TreeState is derived from the Zcash z_gettreestate rpc.
109
+ message TreeState {
110
+ string network = 1; // "main" or "test"
111
+ uint64 height = 2;
112
+ string hash = 3; // block id
113
+ uint32 time = 4; // Unix epoch time when the block was mined
114
+ string tree = 5; // sapling commitment tree state
115
+ }
116
+
117
+ // Results are sorted by height, which makes it easy to issue another
118
+ // request that picks up from where the previous left off.
119
+ message GetAddressUtxosArg {
120
+ repeated string addresses = 1;
121
+ uint64 startHeight = 2;
122
+ uint32 maxEntries = 3; // zero means unlimited
123
+ }
124
+ message GetAddressUtxosReply {
125
+ string address = 6;
126
+ bytes txid = 1;
127
+ int32 index = 2;
128
+ bytes script = 3;
129
+ int64 valueZat = 4;
130
+ uint64 height = 5;
131
+ }
132
+ message GetAddressUtxosReplyList {
133
+ repeated GetAddressUtxosReply addressUtxos = 1;
134
+ }
135
+
136
+ service CompactTxStreamer {
137
+ // Return the height of the tip of the best chain
138
+ rpc GetLatestBlock(ChainSpec) returns (BlockID) {}
139
+ // Return the compact block corresponding to the given block identifier
140
+ rpc GetBlock(BlockID) returns (CompactBlock) {}
141
+ // Return a list of consecutive compact blocks
142
+ rpc GetBlockRange(BlockRange) returns (stream CompactBlock) {}
143
+
144
+ // Return the requested full (not compact) transaction (as from zcashd)
145
+ rpc GetTransaction(TxFilter) returns (RawTransaction) {}
146
+ // Submit the given transaction to the Zcash network
147
+ rpc SendTransaction(RawTransaction) returns (SendResponse) {}
148
+
149
+ // Return the txids corresponding to the given t-address within the given block range
150
+ rpc GetTaddressTxids(TransparentAddressBlockFilter) returns (stream RawTransaction) {}
151
+ rpc GetTaddressBalance(AddressList) returns (Balance) {}
152
+ rpc GetTaddressBalanceStream(stream Address) returns (Balance) {}
153
+
154
+ // Return a stream of current Mempool transactions. This will keep the output stream open while
155
+ // there are mempool transactions. It will close the returned stream when a new block is mined.
156
+ rpc GetMempoolStream(Empty) returns (stream RawTransaction) {}
157
+
158
+ // GetTreeState returns the note commitment tree state corresponding to the given block.
159
+ // See section 3.7 of the Zcash protocol specification. It returns several other useful
160
+ // values also (even though they can be obtained using GetBlock).
161
+ // The block can be specified by either height or hash.
162
+ rpc GetTreeState(BlockID) returns (TreeState) {}
163
+ rpc GetLatestTreeState(Empty) returns (TreeState) {}
164
+
165
+ rpc GetAddressUtxos(GetAddressUtxosArg) returns (GetAddressUtxosReplyList) {}
166
+ rpc GetAddressUtxosStream(GetAddressUtxosArg) returns (stream GetAddressUtxosReply) {}
167
+
168
+ // Return information about this lightwalletd instance and the blockchain
169
+ rpc GetLightdInfo(Empty) returns (LightdInfo) {}
170
+ // Testing-only, requires lightwalletd --ping-very-insecure (do not enable in production)
171
+ rpc Ping(Duration) returns (PingResponse) {}
172
+ }