react-native-zcash 0.2.3 → 0.3.2

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # React Native Zcash
2
2
 
3
+ ## 0.3.2 (2022-12-20)
4
+
5
+ - getBirthdayHeight: Remove Android specific network name and use host and port for both platforms
6
+
7
+ ## 0.3.1 (2022-12-15)
8
+
9
+ - Add `getBirthdayHeight` method to query blockheight without an active synchronizer
10
+ - iOS: Add missing `getLatestNetworkHeight` method
11
+ - RN: Remove unimplemented methods and POC comments
12
+ - Fix exported types
13
+
3
14
  ## 0.2.3 (2022-08-07)
4
15
 
5
16
  - iOS: Handle potential throw in synchronizer.latestHeight()
package/README.md CHANGED
@@ -5,12 +5,27 @@
5
5
 
6
6
  ## React Native
7
7
 
8
- To use this library on React Native, simply run
8
+ To use this library on React Native, run `yarn add react-native-zcash` to install it. Then add these lines to your Podspec file, to work around certain compatiblity issues between the ZCash SDK and React Native:
9
+
10
+ ```ruby
11
+ pod 'CNIOAtomics', :modular_headers => true
12
+ pod 'CNIOBoringSSL', :modular_headers => true
13
+ pod 'CNIOBoringSSLShims', :modular_headers => true
14
+ pod 'CNIOLinux', :modular_headers => true
15
+ pod 'CNIODarwin', :modular_headers => true
16
+ pod 'CNIOHTTPParser', :modular_headers => true
17
+ pod 'CNIOWindows', :modular_headers => true
18
+ pod 'CGRPCZlib', :modular_headers => true
19
+ pod 'ZcashLightClientKit', :git => 'https://github.com/zcash/ZcashLightClientKit.git', :commit => '74f3ae20f26748e162c051e5fa343c71febc4294'
20
+ ```
21
+
22
+ Finally, you can use CocoaPods to integrate the library with your project:
9
23
 
10
24
  ```bash
11
- yarn add react-native-zcash
12
25
  cd ios
13
26
  pod install
14
27
  ```
15
28
 
16
29
  ## API overview
30
+
31
+ TODO
@@ -5,6 +5,7 @@ import cash.z.ecc.android.sdk.SdkSynchronizer
5
5
  import cash.z.ecc.android.sdk.Synchronizer
6
6
  import cash.z.ecc.android.sdk.db.entity.*
7
7
  import cash.z.ecc.android.sdk.ext.*
8
+ import cash.z.ecc.android.sdk.internal.service.LightWalletGrpcService
8
9
  import cash.z.ecc.android.sdk.internal.transaction.PagedTransactionRepository
9
10
  import cash.z.ecc.android.sdk.internal.*
10
11
  import cash.z.ecc.android.sdk.type.*
@@ -175,6 +176,14 @@ class RNZcashModule(private val reactContext: ReactApplicationContext) :
175
176
  wallet.synchronizer.latestHeight
176
177
  }
177
178
 
179
+ @ReactMethod
180
+ fun getBirthdayHeight(host: String, port: Int, promise: Promise) = promise.wrap {
181
+ var lightwalletService = LightWalletGrpcService(reactApplicationContext, host, port)
182
+ val height = lightwalletService?.getLatestBlockHeight()
183
+ lightwalletService?.shutdown()
184
+ height
185
+ }
186
+
178
187
  @ReactMethod
179
188
  fun getShieldedBalance(alias: String, promise: Promise) = promise.wrap {
180
189
  val wallet = getWallet(alias)
@@ -213,13 +222,9 @@ class RNZcashModule(private val reactContext: ReactApplicationContext) :
213
222
  promise.resolve(map)
214
223
  } else if (tx.isFailure()) {
215
224
  val map = Arguments.createMap()
216
- map.putInt("expiryHeight", tx.expiryHeight)
217
- map.putString("cancelled", tx.cancelled.toString())
218
- map.putString("encodeAttempts", tx.encodeAttempts.toString())
219
- map.putString("submitAttempts", tx.submitAttempts.toString())
220
225
  if (tx.errorMessage != null) map.putString("errorMessage", tx.errorMessage)
221
226
  if (tx.errorCode != null) map.putString("errorCode", tx.errorCode.toString())
222
- promise.resolve(false)
227
+ promise.resolve(map)
223
228
  }
224
229
  }
225
230
  } catch (t: Throwable) {
@@ -305,16 +310,6 @@ class RNZcashModule(private val reactContext: ReactApplicationContext) :
305
310
  .emit(eventName, args)
306
311
  }
307
312
 
308
- // TODO: move this to the SDK
309
- inline fun ByteArray?.toUtf8Memo(): String {
310
- return if (this == null || this[0] >= 0xF5) "" else try {
311
- // trim empty and "replacement characters" for codes that can't be represented in unicode
312
- String(this, StandardCharsets.UTF_8).trim('\u0000', '\uFFFD')
313
- } catch (t: Throwable) {
314
- "Unable to parse memo."
315
- }
316
- }
317
-
318
313
  inline fun ByteArray.toHexReversed(): String {
319
314
  val sb = StringBuilder(size * 2)
320
315
  var i = size - 1
package/ios/RNZcash.m CHANGED
@@ -26,6 +26,17 @@ resolver:(RCTPromiseResolveBlock)resolve
26
26
  rejecter:(RCTPromiseRejectBlock)reject
27
27
  )
28
28
 
29
+ RCT_EXTERN_METHOD(getLatestNetworkHeight:(NSString *)alias
30
+ resolver:(RCTPromiseResolveBlock)resolve
31
+ rejecter:(RCTPromiseRejectBlock)reject
32
+ )
33
+
34
+ RCT_EXTERN_METHOD(getBirthdayHeight:(NSString *)host
35
+ :(NSInteger *)port
36
+ resolver:(RCTPromiseResolveBlock)resolve
37
+ rejecter:(RCTPromiseRejectBlock)reject
38
+ )
39
+
29
40
  RCT_EXTERN_METHOD(spendToAddress:(NSString *)alias
30
41
  :(NSString *)zatoshi
31
42
  :(NSString *)toAddress
package/ios/RNZcash.swift CHANGED
@@ -142,6 +142,32 @@ class RNZcash : RCTEventEmitter {
142
142
  }
143
143
  }
144
144
 
145
+ @objc func getLatestNetworkHeight(_ alias: String, resolver resolve:@escaping RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
146
+ if let wallet = SynchronizerMap[alias] {
147
+ do {
148
+ let height = try wallet.synchronizer.latestHeight()
149
+ resolve(height)
150
+ } catch {
151
+ reject("getLatestNetworkHeight", "Failed to query blockheight", error)
152
+ }
153
+ } else {
154
+ reject("getLatestNetworkHeightError", "Wallet does not exist", genericError)
155
+ }
156
+ }
157
+
158
+ // A convenience method to get the block height when the synchronizer isn't running
159
+ @objc func getBirthdayHeight(_ host: String, _ port: Int, resolver resolve:@escaping RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
160
+ do {
161
+ let endpoint = LightWalletEndpoint(address: host, port: port, secure: true)
162
+ let lightwalletd: LightWalletService = LightWalletGRPCService(endpoint:endpoint)
163
+ let height = try lightwalletd.latestBlockHeight()
164
+ lightwalletd.closeConnection()
165
+ resolve(height)
166
+ } catch {
167
+ reject("getLatestNetworkHeightGrpc", "Failed to query blockheight", error)
168
+ }
169
+ }
170
+
145
171
  @objc func spendToAddress(_ alias: String, _ zatoshi: String, _ toAddress: String, _ memo: String, _ fromAccountIndex: Int, _ spendingKey: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
146
172
  if let wallet = SynchronizerMap[alias] {
147
173
  let amount = Int64(zatoshi)
package/lib/rnzcash.rn.js CHANGED
@@ -40,26 +40,7 @@ function _asyncToGenerator(fn) {
40
40
  };
41
41
  }
42
42
 
43
- var SynchronizerStatus;
44
-
45
- (function (SynchronizerStatus) {
46
- SynchronizerStatus[SynchronizerStatus["STOPPED"] = 0] = "STOPPED";
47
- SynchronizerStatus[SynchronizerStatus["DISCONNECTED"] = 1] = "DISCONNECTED";
48
- SynchronizerStatus[SynchronizerStatus["DOWNLOADING"] = 2] = "DOWNLOADING";
49
- SynchronizerStatus[SynchronizerStatus["VALIDATING"] = 3] = "VALIDATING";
50
- SynchronizerStatus[SynchronizerStatus["SCANNING"] = 4] = "SCANNING";
51
- SynchronizerStatus[SynchronizerStatus["ENHANCING"] = 5] = "ENHANCING";
52
- SynchronizerStatus[SynchronizerStatus["SYNCED"] = 6] = "SYNCED";
53
- })(SynchronizerStatus || (SynchronizerStatus = {}));
54
-
55
43
  var RNZcash = reactNative.NativeModules.RNZcash;
56
-
57
- var snooze = function snooze(ms) {
58
- return new Promise(function (resolve) {
59
- return setTimeout(resolve, ms);
60
- });
61
- };
62
-
63
44
  var KeyTool = {
64
45
  deriveViewingKey: function () {
65
46
  var _deriveViewingKey = _asyncToGenerator(function* (seedBytesHex, network) {
@@ -84,6 +65,18 @@ var KeyTool = {
84
65
  }
85
66
 
86
67
  return deriveSpendingKey;
68
+ }(),
69
+ getBirthdayHeight: function () {
70
+ var _getBirthdayHeight = _asyncToGenerator(function* (host, port) {
71
+ var result = yield RNZcash.getBirthdayHeight(host, port);
72
+ return result;
73
+ });
74
+
75
+ function getBirthdayHeight(_x5, _x6) {
76
+ return _getBirthdayHeight.apply(this, arguments);
77
+ }
78
+
79
+ return getBirthdayHeight;
87
80
  }()
88
81
  };
89
82
  var AddressTool = {
@@ -93,7 +86,7 @@ var AddressTool = {
93
86
  return result;
94
87
  });
95
88
 
96
- function deriveShieldedAddress(_x5, _x6) {
89
+ function deriveShieldedAddress(_x7, _x8) {
97
90
  return _deriveShieldedAddress.apply(this, arguments);
98
91
  }
99
92
 
@@ -109,7 +102,7 @@ var AddressTool = {
109
102
  return result;
110
103
  });
111
104
 
112
- function isValidShieldedAddress(_x7, _x8) {
105
+ function isValidShieldedAddress(_x9, _x10) {
113
106
  return _isValidShieldedAddress.apply(this, arguments);
114
107
  }
115
108
 
@@ -125,85 +118,24 @@ var AddressTool = {
125
118
  return result;
126
119
  });
127
120
 
128
- function isValidTransparentAddress(_x9, _x10) {
121
+ function isValidTransparentAddress(_x11, _x12) {
129
122
  return _isValidTransparentAddress.apply(this, arguments);
130
123
  }
131
124
 
132
125
  return isValidTransparentAddress;
133
126
  }()
134
127
  };
135
-
136
128
  var Synchronizer = /*#__PURE__*/function () {
137
129
  function Synchronizer(alias, network) {
138
130
  this.eventEmitter = new reactNative.NativeEventEmitter(RNZcash);
139
131
  this.subscriptions = [];
140
132
  this.alias = alias;
141
133
  this.network = network;
142
- } /// ////////////////////////////////////////////////////////////////
143
- // Start PoC behavior
144
- // Here are a few functions to demonstrate functionality but the final library should not have these functions
145
- //
146
-
134
+ }
147
135
 
148
136
  var _proto = Synchronizer.prototype;
149
137
 
150
- _proto.readyToSend =
151
- /*#__PURE__*/
152
- function () {
153
- var _readyToSend = _asyncToGenerator(function* () {
154
- var result = yield RNZcash.readyToSend();
155
- return result;
156
- });
157
-
158
- function readyToSend() {
159
- return _readyToSend.apply(this, arguments);
160
- }
161
-
162
- return readyToSend;
163
- }();
164
-
165
- _proto.sendTestTransaction = /*#__PURE__*/function () {
166
- var _sendTestTransaction = _asyncToGenerator(function* (key, address) {
167
- // send an amount that's guaranteed to be too large for our wallet and expect it to fail but at least show how this is done
168
- // simply change these two values to send a real transaction but ensure the function isn't called too often (although funds can't be spent if notes are unconfirmed)
169
- var invalidValue = '9223372036854775807'; // Max long value (change this to 10000 to send a small transaction equal to the miner's fee on every reload and you could send 10,000 of those before it equals 1 ZEC)
170
-
171
- var invalidAccount = 99; // should be 0
172
-
173
- return this.sendToAddress({
174
- zatoshi: invalidValue,
175
- toAddress: address,
176
- memo: 'this is a test transaction that will fail',
177
- fromAccountIndex: invalidAccount,
178
- spendingKey: key
179
- });
180
- });
181
-
182
- function sendTestTransaction(_x11, _x12) {
183
- return _sendTestTransaction.apply(this, arguments);
184
- }
185
-
186
- return sendTestTransaction;
187
- }();
188
-
189
- _proto.getBlockCount = /*#__PURE__*/function () {
190
- var _getBlockCount = _asyncToGenerator(function* () {
191
- var result = yield RNZcash.getBlockCount();
192
- return result;
193
- });
194
-
195
- function getBlockCount() {
196
- return _getBlockCount.apply(this, arguments);
197
- }
198
-
199
- return getBlockCount;
200
- }() // End PoC behavior
201
- /// ////////////////////////////////////////////////////////////////
202
- ;
203
-
204
- _proto.start =
205
- /*#__PURE__*/
206
- function () {
138
+ _proto.start = /*#__PURE__*/function () {
207
139
  var _start = _asyncToGenerator(function* () {
208
140
  var result = yield RNZcash.start(this.alias);
209
141
  return result;
@@ -255,45 +187,6 @@ var Synchronizer = /*#__PURE__*/function () {
255
187
  return getLatestNetworkHeight;
256
188
  }();
257
189
 
258
- _proto.getLatestScannedHeight = /*#__PURE__*/function () {
259
- var _getLatestScannedHeight = _asyncToGenerator(function* () {
260
- var result = yield RNZcash.getLatestScannedHeight();
261
- return result;
262
- });
263
-
264
- function getLatestScannedHeight() {
265
- return _getLatestScannedHeight.apply(this, arguments);
266
- }
267
-
268
- return getLatestScannedHeight;
269
- }();
270
-
271
- _proto.getProgress = /*#__PURE__*/function () {
272
- var _getProgress = _asyncToGenerator(function* () {
273
- var result = yield RNZcash.getProgress();
274
- return result;
275
- });
276
-
277
- function getProgress() {
278
- return _getProgress.apply(this, arguments);
279
- }
280
-
281
- return getProgress;
282
- }();
283
-
284
- _proto.getStatus = /*#__PURE__*/function () {
285
- var _getStatus = _asyncToGenerator(function* () {
286
- var result = yield RNZcash.getStatus();
287
- return SynchronizerStatus[result.name];
288
- });
289
-
290
- function getStatus() {
291
- return _getStatus.apply(this, arguments);
292
- }
293
-
294
- return getStatus;
295
- }();
296
-
297
190
  _proto.getShieldedBalance = /*#__PURE__*/function () {
298
191
  var _getShieldedBalance = _asyncToGenerator(function* () {
299
192
  var result = yield RNZcash.getShieldedBalance(this.alias);
@@ -307,24 +200,6 @@ var Synchronizer = /*#__PURE__*/function () {
307
200
  return getShieldedBalance;
308
201
  }();
309
202
 
310
- _proto.getTransparentBalance = /*#__PURE__*/function () {
311
- var _getTransparentBalance = _asyncToGenerator(function* () {
312
- // TODO: integrate with lightwalletd service to provide taddr balance. Edge probably doesn't need this, though so it can wait.
313
- yield snooze(0); // Hack to make typescript happy
314
-
315
- return {
316
- availableZatoshi: '0',
317
- totalZatoshi: '0'
318
- };
319
- });
320
-
321
- function getTransparentBalance() {
322
- return _getTransparentBalance.apply(this, arguments);
323
- }
324
-
325
- return getTransparentBalance;
326
- }();
327
-
328
203
  _proto.getTransactions = /*#__PURE__*/function () {
329
204
  var _getTransactions = _asyncToGenerator(function* (range) {
330
205
  var result = yield RNZcash.getTransactions(this.alias, range.first, range.last);
@@ -344,8 +219,7 @@ var Synchronizer = /*#__PURE__*/function () {
344
219
 
345
220
  _proto.sendToAddress = /*#__PURE__*/function () {
346
221
  var _sendToAddress = _asyncToGenerator(function* (spendInfo) {
347
- var result = yield RNZcash.spendToAddress(this.alias, spendInfo.zatoshi, spendInfo.toAddress, spendInfo.memo, spendInfo.fromAccountIndex, // TODO: ask is it okay to send this across the boundary or should it live on the native side and never leave?
348
- spendInfo.spendingKey);
222
+ var result = yield RNZcash.spendToAddress(this.alias, spendInfo.zatoshi, spendInfo.toAddress, spendInfo.memo, spendInfo.fromAccountIndex, spendInfo.spendingKey);
349
223
  return result;
350
224
  });
351
225
 
@@ -354,11 +228,7 @@ var Synchronizer = /*#__PURE__*/function () {
354
228
  }
355
229
 
356
230
  return sendToAddress;
357
- }() // estimateFee (spendInfo: SpendInfo): string
358
- // sendToAddress (spendInfo: SpendInfo): void
359
- // getPendingTransactions (): PendingTransactions[]
360
- // getConfirmedTransactions (query: TransactionQuery): ZcashTransaction[]
361
- // Events
231
+ }() // Events
362
232
  ;
363
233
 
364
234
  _proto.subscribe = function subscribe(_ref) {
@@ -390,7 +260,6 @@ var Synchronizer = /*#__PURE__*/function () {
390
260
 
391
261
  return Synchronizer;
392
262
  }();
393
-
394
263
  var makeSynchronizer = /*#__PURE__*/function () {
395
264
  var _ref2 = _asyncToGenerator(function* (initializerConfig) {
396
265
  var synchronizer = new Synchronizer(initializerConfig.alias, initializerConfig.networkName);
@@ -405,5 +274,6 @@ var makeSynchronizer = /*#__PURE__*/function () {
405
274
 
406
275
  exports.AddressTool = AddressTool;
407
276
  exports.KeyTool = KeyTool;
277
+ exports.Synchronizer = Synchronizer;
408
278
  exports.makeSynchronizer = makeSynchronizer;
409
279
  //# sourceMappingURL=rnzcash.rn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rnzcash.rn.js","sources":["../src/types.ts","../src/react-native.ts"],"sourcesContent":["export type Network = 'mainnet' | 'testnet'\n\nexport interface WalletBalance {\n availableZatoshi: string\n totalZatoshi: string\n}\n\nexport interface InitializerConfig {\n networkName: Network\n defaultHost: string\n defaultPort: number\n fullViewingKey: UnifiedViewingKey\n alias: string\n birthdayHeight: number\n}\n\nexport interface SpendInfo {\n zatoshi: string\n toAddress: string\n memo: string\n fromAccountIndex: number\n spendingKey?: string\n}\n\nexport interface TransactionQuery {\n offset?: number\n limit?: number\n startDate?: number\n endDate?: number\n}\n\nexport interface ZcashTransaction {\n txId: string\n accountIndex: number\n fee: string\n value: string\n direction: 'inbound' | 'outbound'\n toAddress: string\n memo?: string\n minedHeight: number // 0 for unconfirmed\n blockTime: number // UNIX timestamp\n}\n\nexport type PendingTransaction = ZcashTransaction & {\n expiryHeight: number\n cancelled: number\n submitAttempts: number\n errorMessage?: string\n errorCode?: number\n createTime: number\n}\n\nexport enum SynchronizerStatus {\n /** Indicates that [stop] has been called on this Synchronizer and it will no longer be used. */\n STOPPED,\n /** Indicates that this Synchronizer is disconnected from its lightwalletd server. When set, a UI element may want to turn red. */\n DISCONNECTED,\n /** Indicates that this Synchronizer is actively downloading new blocks from the server. */\n DOWNLOADING,\n /** Indicates that this Synchronizer is actively validating new blocks that were downloaded from the server. Blocks need to be verified before they are scanned. This confirms that each block is chain-sequential, thereby detecting missing blocks and reorgs. */\n VALIDATING,\n /** Indicates that this Synchronizer is actively decrypting new blocks that were downloaded from the server. */\n SCANNING,\n /** Indicates that this Synchronizer is actively enhancing newly scanned blocks with additional transaction details, fetched from the server. */\n ENHANCING,\n /** Indicates that this Synchronizer is fully up to date and ready for all wallet functions. When set, a UI element may want to turn green. In this state, the balance can be trusted. */\n SYNCED\n}\n\nexport interface UnifiedViewingKey {\n extfvk: string\n extpub: string\n}\n\nexport interface UpdateEvent {\n lastDownloadedHeight: number\n lastScannedHeight: number\n scanProgress: number // 0 - 100\n networkBlockHeight: number\n}\n\nexport interface SynchronizerCallbacks {\n onShieldedBalanceChanged(walletBalance: WalletBalance): void\n onStatusChanged(status: SynchronizerStatus): void\n onUpdate(event: UpdateEvent): void\n onTransactionsChanged(count: number): void\n onPendingTransactionUpdated(tx: PendingTransaction): void\n}\n\nexport interface BlockRange {\n first: number\n last: number\n}\n\nexport interface ConfirmedTransaction {\n value: string\n memo?: string\n minedHeight: number\n rawTransactionId: string\n toAddress?: string\n}\n","import {\n EventSubscription,\n NativeEventEmitter,\n NativeModules\n} from 'react-native'\n\nimport {\n BlockRange,\n ConfirmedTransaction,\n InitializerConfig,\n Network,\n PendingTransaction,\n SpendInfo,\n SynchronizerCallbacks,\n SynchronizerStatus,\n UnifiedViewingKey,\n WalletBalance\n} from './types'\n\nconst { RNZcash } = NativeModules\n\nconst snooze: Function = (ms: number) =>\n new Promise((resolve: Function) => setTimeout(resolve, ms))\n\ntype Callback = (...args: any[]) => any\n\nexport const KeyTool = {\n deriveViewingKey: async (\n seedBytesHex: string,\n network: Network\n ): Promise<UnifiedViewingKey> => {\n const result = await RNZcash.deriveViewingKey(seedBytesHex, network)\n return result\n },\n deriveSpendingKey: async (\n seedBytesHex: string,\n network: Network\n ): Promise<string> => {\n const result = await RNZcash.deriveSpendingKey(seedBytesHex, network)\n return result\n }\n}\n\nexport const AddressTool = {\n deriveShieldedAddress: async (\n viewingKey: string,\n network: Network\n ): Promise<string> => {\n const result = await RNZcash.deriveShieldedAddress(viewingKey, network)\n return result\n },\n isValidShieldedAddress: async (\n address: string,\n network: Network = 'mainnet'\n ): Promise<boolean> => {\n const result = await RNZcash.isValidShieldedAddress(address, network)\n return result\n },\n isValidTransparentAddress: async (\n address: string,\n network: Network = 'mainnet'\n ): Promise<boolean> => {\n const result = await RNZcash.isValidTransparentAddress(address, network)\n return result\n }\n}\n\nclass Synchronizer {\n eventEmitter: NativeEventEmitter\n subscriptions: EventSubscription[]\n alias: string\n network: Network\n\n constructor(alias: string, network: Network) {\n this.eventEmitter = new NativeEventEmitter(RNZcash)\n this.subscriptions = []\n this.alias = alias\n this.network = network\n }\n\n /// ////////////////////////////////////////////////////////////////\n // Start PoC behavior\n // Here are a few functions to demonstrate functionality but the final library should not have these functions\n //\n async readyToSend(): Promise<boolean> {\n const result = await RNZcash.readyToSend()\n return result\n }\n\n async sendTestTransaction(\n key: string,\n address: string\n ): Promise<PendingTransaction> {\n // send an amount that's guaranteed to be too large for our wallet and expect it to fail but at least show how this is done\n // simply change these two values to send a real transaction but ensure the function isn't called too often (although funds can't be spent if notes are unconfirmed)\n const invalidValue = '9223372036854775807' // Max long value (change this to 10000 to send a small transaction equal to the miner's fee on every reload and you could send 10,000 of those before it equals 1 ZEC)\n const invalidAccount = 99 // should be 0\n return this.sendToAddress({\n zatoshi: invalidValue,\n toAddress: address,\n memo: 'this is a test transaction that will fail',\n fromAccountIndex: invalidAccount,\n spendingKey: key\n })\n }\n\n async getBlockCount(): Promise<number> {\n const result = await RNZcash.getBlockCount()\n return result\n }\n // End PoC behavior\n /// ////////////////////////////////////////////////////////////////\n\n async start(): Promise<String> {\n const result = await RNZcash.start(this.alias)\n return result\n }\n\n async stop(): Promise<String> {\n this.unsubscribe()\n const result = await RNZcash.stop(this.alias)\n return result\n }\n\n async initialize(initializerConfig: InitializerConfig): Promise<void> {\n await RNZcash.initialize(\n initializerConfig.fullViewingKey.extfvk,\n initializerConfig.fullViewingKey.extpub,\n initializerConfig.birthdayHeight,\n initializerConfig.alias,\n initializerConfig.networkName,\n initializerConfig.defaultHost,\n initializerConfig.defaultPort\n )\n }\n\n async getLatestNetworkHeight(alias: string): Promise<number> {\n const result = await RNZcash.getLatestNetworkHeight(alias)\n return result\n }\n\n async getLatestScannedHeight(): Promise<number> {\n const result = await RNZcash.getLatestScannedHeight()\n return result\n }\n\n async getProgress(): Promise<number> {\n const result = await RNZcash.getProgress()\n return result\n }\n\n async getStatus(): Promise<SynchronizerStatus> {\n const result = await RNZcash.getStatus()\n return SynchronizerStatus[result.name as keyof typeof SynchronizerStatus]\n }\n\n async getShieldedBalance(): Promise<WalletBalance> {\n const result = await RNZcash.getShieldedBalance(this.alias)\n return result\n }\n\n async getTransparentBalance(): Promise<WalletBalance> {\n // TODO: integrate with lightwalletd service to provide taddr balance. Edge probably doesn't need this, though so it can wait.\n\n await snooze(0) // Hack to make typescript happy\n return {\n availableZatoshi: '0',\n totalZatoshi: '0'\n }\n }\n\n async getTransactions(range: BlockRange): Promise<ConfirmedTransaction[]> {\n const result = await RNZcash.getTransactions(\n this.alias,\n range.first,\n range.last\n )\n return result\n }\n\n rescan(height: number): void {\n RNZcash.rescan(this.alias, height)\n }\n\n async sendToAddress(spendInfo: SpendInfo): Promise<PendingTransaction> {\n const result = await RNZcash.spendToAddress(\n this.alias,\n spendInfo.zatoshi,\n spendInfo.toAddress,\n spendInfo.memo,\n spendInfo.fromAccountIndex,\n // TODO: ask is it okay to send this across the boundary or should it live on the native side and never leave?\n spendInfo.spendingKey\n )\n return result\n }\n\n // estimateFee (spendInfo: SpendInfo): string\n // sendToAddress (spendInfo: SpendInfo): void\n\n // getPendingTransactions (): PendingTransactions[]\n // getConfirmedTransactions (query: TransactionQuery): ZcashTransaction[]\n\n // Events\n\n subscribe({ onStatusChanged, onUpdate }: SynchronizerCallbacks): void {\n this.setListener('StatusEvent', onStatusChanged)\n this.setListener('UpdateEvent', onUpdate)\n }\n\n private setListener<T>(\n eventName: string,\n callback: Callback = (t: any) => null\n ): void {\n this.subscriptions.push(\n this.eventEmitter.addListener(eventName, arg =>\n arg.alias === this.alias ? callback(arg) : null\n )\n )\n }\n\n unsubscribe(): void {\n this.subscriptions.forEach(subscription => {\n subscription.remove()\n })\n }\n}\n\nexport const makeSynchronizer = async (\n initializerConfig: InitializerConfig\n): Promise<Synchronizer> => {\n const synchronizer = new Synchronizer(\n initializerConfig.alias,\n initializerConfig.networkName\n )\n await synchronizer.initialize(initializerConfig)\n return synchronizer\n}\n"],"names":["SynchronizerStatus","RNZcash","NativeModules","snooze","ms","Promise","resolve","setTimeout","KeyTool","deriveViewingKey","seedBytesHex","network","result","deriveSpendingKey","AddressTool","deriveShieldedAddress","viewingKey","isValidShieldedAddress","address","isValidTransparentAddress","Synchronizer","alias","eventEmitter","NativeEventEmitter","subscriptions","readyToSend","sendTestTransaction","key","invalidValue","invalidAccount","sendToAddress","zatoshi","toAddress","memo","fromAccountIndex","spendingKey","getBlockCount","start","stop","unsubscribe","initialize","initializerConfig","fullViewingKey","extfvk","extpub","birthdayHeight","networkName","defaultHost","defaultPort","getLatestNetworkHeight","getLatestScannedHeight","getProgress","getStatus","name","getShieldedBalance","getTransparentBalance","availableZatoshi","totalZatoshi","getTransactions","range","first","last","rescan","height","spendInfo","spendToAddress","subscribe","onStatusChanged","onUpdate","setListener","eventName","callback","t","push","addListener","arg","forEach","subscription","remove","makeSynchronizer","synchronizer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoDYA,kBAAZ;;WAAYA;AAAAA,EAAAA,mBAAAA;AAAAA,EAAAA,mBAAAA;AAAAA,EAAAA,mBAAAA;AAAAA,EAAAA,mBAAAA;AAAAA,EAAAA,mBAAAA;AAAAA,EAAAA,mBAAAA;AAAAA,EAAAA,mBAAAA;GAAAA,uBAAAA;;ICjCJC,UAAYC,0BAAZD;;AAER,IAAME,MAAgB,GAAG,SAAnBA,MAAmB,CAACC,EAAD;AAAA,SACvB,IAAIC,OAAJ,CAAY,UAACC,OAAD;AAAA,WAAuBC,UAAU,CAACD,OAAD,EAAUF,EAAV,CAAjC;AAAA,GAAZ,CADuB;AAAA,CAAzB;;IAKaI,OAAO,GAAG;AACrBC,EAAAA,gBAAgB;AAAA,8CAAE,WAChBC,YADgB,EAEhBC,OAFgB,EAGe;AAC/B,UAAMC,MAAM,SAASX,OAAO,CAACQ,gBAAR,CAAyBC,YAAzB,EAAuCC,OAAvC,CAArB;AACA,aAAOC,MAAP;AACD,KANe;;AAAA;AAAA;AAAA;;AAAA;AAAA,KADK;AAQrBC,EAAAA,iBAAiB;AAAA,+CAAE,WACjBH,YADiB,EAEjBC,OAFiB,EAGG;AACpB,UAAMC,MAAM,SAASX,OAAO,CAACY,iBAAR,CAA0BH,YAA1B,EAAwCC,OAAxC,CAArB;AACA,aAAOC,MAAP;AACD,KANgB;;AAAA;AAAA;AAAA;;AAAA;AAAA;AARI;IAiBVE,WAAW,GAAG;AACzBC,EAAAA,qBAAqB;AAAA,mDAAE,WACrBC,UADqB,EAErBL,OAFqB,EAGD;AACpB,UAAMC,MAAM,SAASX,OAAO,CAACc,qBAAR,CAA8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E,WAAL,CAAiB,aAAjB,EAAgCD,QAAhC;AACD;;SAEOC,cAAR,qBACEC,SADF,EAEEC,QAFF,EAGQ;AAAA;;AAAA,QADNA,QACM;AADNA,MAAAA,QACM,GADe,kBAACC,CAAD;AAAA,eAAY,IAAZ;AAAA,OACf;AAAA;;AACN,SAAKhD,aAAL,CAAmBiD,IAAnB,CACE,KAAKnD,YAAL,CAAkBoD,WAAlB,CAA8BJ,SAA9B,EAAyC,UAAAK,GAAG;AAAA,aAC1CA,GAAG,CAACtD,KAAJ,KAAc,KAAI,CAACA,KAAnB,GAA2BkD,QAAQ,CAACI,GAAD,CAAnC,GAA2C,IADD;AAAA,KAA5C,CADF;AAKD;;SAEDpC,cAAA,uBAAoB;AAClB,SAAKf,aAAL,CAAmBoD,OAAnB,CAA2B,UAAAC,YAAY,EAAI;AACzCA,MAAAA,YAAY,CAACC,MAAb;AACD,KAFD;AAGD;;;;;IAGUC,gBAAgB;AAAA,gCAAG,WAC9BtC,iBAD8B,EAEJ;AAC1B,QAAMuC,YAAY,GAAG,IAAI5D,YAAJ,CACnBqB,iBAAiB,CAACpB,KADC,EAEnBoB,iBAAiB,CAACK,WAFC,CAArB;AAIA,UAAMkC,YAAY,CAACxC,UAAb,CAAwBC,iBAAxB,CAAN;AACA,WAAOuC,YAAP;AACD,GAT4B;;AAAA,kBAAhBD,gBAAgB;AAAA;AAAA;AAAA;;;;;;"}
1
+ {"version":3,"file":"rnzcash.rn.js","sources":["../src/react-native.ts"],"sourcesContent":["import {\n EventSubscription,\n NativeEventEmitter,\n NativeModules\n} from 'react-native'\n\nimport {\n BlockRange,\n ConfirmedTransaction,\n InitializerConfig,\n Network,\n SpendFailure,\n SpendInfo,\n SpendSuccess,\n SynchronizerCallbacks,\n UnifiedViewingKey,\n WalletBalance\n} from './types'\n\nconst { RNZcash } = NativeModules\n\ntype Callback = (...args: any[]) => any\n\nexport const KeyTool = {\n deriveViewingKey: async (\n seedBytesHex: string,\n network: Network\n ): Promise<UnifiedViewingKey> => {\n const result = await RNZcash.deriveViewingKey(seedBytesHex, network)\n return result\n },\n deriveSpendingKey: async (\n seedBytesHex: string,\n network: Network\n ): Promise<string> => {\n const result = await RNZcash.deriveSpendingKey(seedBytesHex, network)\n return result\n },\n getBirthdayHeight: async (host: string, port: number): Promise<number> => {\n const result = await RNZcash.getBirthdayHeight(host, port)\n return result\n }\n}\n\nexport const AddressTool = {\n deriveShieldedAddress: async (\n viewingKey: string,\n network: Network\n ): Promise<string> => {\n const result = await RNZcash.deriveShieldedAddress(viewingKey, network)\n return result\n },\n isValidShieldedAddress: async (\n address: string,\n network: Network = 'mainnet'\n ): Promise<boolean> => {\n const result = await RNZcash.isValidShieldedAddress(address, network)\n return result\n },\n isValidTransparentAddress: async (\n address: string,\n network: Network = 'mainnet'\n ): Promise<boolean> => {\n const result = await RNZcash.isValidTransparentAddress(address, network)\n return result\n }\n}\n\nexport class Synchronizer {\n eventEmitter: NativeEventEmitter\n subscriptions: EventSubscription[]\n alias: string\n network: Network\n\n constructor(alias: string, network: Network) {\n this.eventEmitter = new NativeEventEmitter(RNZcash)\n this.subscriptions = []\n this.alias = alias\n this.network = network\n }\n\n async start(): Promise<String> {\n const result = await RNZcash.start(this.alias)\n return result\n }\n\n async stop(): Promise<String> {\n this.unsubscribe()\n const result = await RNZcash.stop(this.alias)\n return result\n }\n\n async initialize(initializerConfig: InitializerConfig): Promise<void> {\n await RNZcash.initialize(\n initializerConfig.fullViewingKey.extfvk,\n initializerConfig.fullViewingKey.extpub,\n initializerConfig.birthdayHeight,\n initializerConfig.alias,\n initializerConfig.networkName,\n initializerConfig.defaultHost,\n initializerConfig.defaultPort\n )\n }\n\n async getLatestNetworkHeight(alias: string): Promise<number> {\n const result = await RNZcash.getLatestNetworkHeight(alias)\n return result\n }\n\n async getShieldedBalance(): Promise<WalletBalance> {\n const result = await RNZcash.getShieldedBalance(this.alias)\n return result\n }\n\n async getTransactions(range: BlockRange): Promise<ConfirmedTransaction[]> {\n const result = await RNZcash.getTransactions(\n this.alias,\n range.first,\n range.last\n )\n return result\n }\n\n rescan(height: number): void {\n RNZcash.rescan(this.alias, height)\n }\n\n async sendToAddress(\n spendInfo: SpendInfo\n ): Promise<SpendSuccess | SpendFailure> {\n const result = await RNZcash.spendToAddress(\n this.alias,\n spendInfo.zatoshi,\n spendInfo.toAddress,\n spendInfo.memo,\n spendInfo.fromAccountIndex,\n spendInfo.spendingKey\n )\n return result\n }\n\n // Events\n\n subscribe({ onStatusChanged, onUpdate }: SynchronizerCallbacks): void {\n this.setListener('StatusEvent', onStatusChanged)\n this.setListener('UpdateEvent', onUpdate)\n }\n\n private setListener<T>(\n eventName: string,\n callback: Callback = (t: any) => null\n ): void {\n this.subscriptions.push(\n this.eventEmitter.addListener(eventName, arg =>\n arg.alias === this.alias ? callback(arg) : null\n )\n )\n }\n\n unsubscribe(): void {\n this.subscriptions.forEach(subscription => {\n subscription.remove()\n })\n }\n}\n\nexport const makeSynchronizer = async (\n initializerConfig: InitializerConfig\n): Promise<Synchronizer> => {\n const synchronizer = new Synchronizer(\n initializerConfig.alias,\n initializerConfig.networkName\n )\n await synchronizer.initialize(initializerConfig)\n return synchronizer\n}\n"],"names":["RNZcash","NativeModules","KeyTool","deriveViewingKey","seedBytesHex","network","result","deriveSpendingKey","getBirthdayHeight","host","port","AddressTool","deriveShieldedAddress","viewingKey","isValidShieldedAddress","address","isValidTransparentAddress","Synchronizer","alias","eventEmitter","NativeEventEmitter","subscriptions","start","stop","unsubscribe","initialize","initializerConfig","fullViewingKey","extfvk","extpub","birthdayHeight","networkName","defaultHost","defaultPort","getLatestNetworkHeight","getShieldedBalance","getTransactions","range","first","last","rescan","height","sendToAddress","spendInfo","spendToAddress","zatoshi","toAddress","memo","fromAccountIndex","spendingKey","subscribe","onStatusChanged","onUpdate","setListener","eventName","callback","t","push","addListener","arg","forEach","subscription","remove","makeSynchronizer","synchronizer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CA,QAAyC;AACpE,SAAKC,WAAL,CAAiB,aAAjB,EAAgCF,eAAhC;AACA,SAAKE,WAAL,CAAiB,aAAjB,EAAgCD,QAAhC;AACD,GA9EH;;AAAA,SAgFUC,WAhFV,GAgFE,qBACEC,SADF,EAEEC,QAFF,EAGQ;AAAA;;AAAA,QADNA,QACM;AADNA,MAAAA,QACM,GADe,kBAACC,CAAD;AAAA,eAAY,IAAZ;AAAA,OACf;AAAA;;AACN,SAAKnC,aAAL,CAAmBoC,IAAnB,CACE,KAAKtC,YAAL,CAAkBuC,WAAlB,CAA8BJ,SAA9B,EAAyC,UAAAK,GAAG;AAAA,aAC1CA,GAAG,CAACzC,KAAJ,KAAc,KAAI,CAACA,KAAnB,GAA2BqC,QAAQ,CAACI,GAAD,CAAnC,GAA2C,IADD;AAAA,KAA5C,CADF;AAKD,GAzFH;;AAAA,SA2FEnC,WA3FF,GA2FE,uBAAoB;AAClB,SAAKH,aAAL,CAAmBuC,OAAnB,CAA2B,UAAAC,YAAY,EAAI;AACzCA,MAAAA,YAAY,CAACC,MAAb;AACD,KAFD;AAGD,GA/FH;;AAAA;AAAA;IAkGaC,gBAAgB;AAAA,gCAAG,WAC9BrC,iBAD8B,EAEJ;AAC1B,QAAMsC,YAAY,GAAG,IAAI/C,YAAJ,CACnBS,iBAAiB,CAACR,KADC,EAEnBQ,iBAAiB,CAACK,WAFC,CAArB;AAIA,UAAMiC,YAAY,CAACvC,UAAb,CAAwBC,iBAAxB,CAAN;AACA,WAAOsC,YAAP;AACD,GAT4B;;AAAA,kBAAhBD,gBAAgB;AAAA;AAAA;AAAA;;;;;;;"}
@@ -1,38 +1,31 @@
1
1
  import { EventSubscription, NativeEventEmitter } from 'react-native';
2
- import { BlockRange, ConfirmedTransaction, InitializerConfig, Network, PendingTransaction, SpendInfo, SynchronizerCallbacks, SynchronizerStatus, UnifiedViewingKey, WalletBalance } from './types';
2
+ import { BlockRange, ConfirmedTransaction, InitializerConfig, Network, SpendFailure, SpendInfo, SpendSuccess, SynchronizerCallbacks, UnifiedViewingKey, WalletBalance } from './types';
3
3
  export declare const KeyTool: {
4
4
  deriveViewingKey: (seedBytesHex: string, network: Network) => Promise<UnifiedViewingKey>;
5
5
  deriveSpendingKey: (seedBytesHex: string, network: Network) => Promise<string>;
6
+ getBirthdayHeight: (host: string, port: number) => Promise<number>;
6
7
  };
7
8
  export declare const AddressTool: {
8
9
  deriveShieldedAddress: (viewingKey: string, network: Network) => Promise<string>;
9
10
  isValidShieldedAddress: (address: string, network?: Network) => Promise<boolean>;
10
11
  isValidTransparentAddress: (address: string, network?: Network) => Promise<boolean>;
11
12
  };
12
- declare class Synchronizer {
13
+ export declare class Synchronizer {
13
14
  eventEmitter: NativeEventEmitter;
14
15
  subscriptions: EventSubscription[];
15
16
  alias: string;
16
17
  network: Network;
17
18
  constructor(alias: string, network: Network);
18
- readyToSend(): Promise<boolean>;
19
- sendTestTransaction(key: string, address: string): Promise<PendingTransaction>;
20
- getBlockCount(): Promise<number>;
21
19
  start(): Promise<String>;
22
20
  stop(): Promise<String>;
23
21
  initialize(initializerConfig: InitializerConfig): Promise<void>;
24
22
  getLatestNetworkHeight(alias: string): Promise<number>;
25
- getLatestScannedHeight(): Promise<number>;
26
- getProgress(): Promise<number>;
27
- getStatus(): Promise<SynchronizerStatus>;
28
23
  getShieldedBalance(): Promise<WalletBalance>;
29
- getTransparentBalance(): Promise<WalletBalance>;
30
24
  getTransactions(range: BlockRange): Promise<ConfirmedTransaction[]>;
31
25
  rescan(height: number): void;
32
- sendToAddress(spendInfo: SpendInfo): Promise<PendingTransaction>;
26
+ sendToAddress(spendInfo: SpendInfo): Promise<SpendSuccess | SpendFailure>;
33
27
  subscribe({ onStatusChanged, onUpdate }: SynchronizerCallbacks): void;
34
28
  private setListener;
35
29
  unsubscribe(): void;
36
30
  }
37
31
  export declare const makeSynchronizer: (initializerConfig: InitializerConfig) => Promise<Synchronizer>;
38
- export {};
@@ -16,74 +16,50 @@ export interface SpendInfo {
16
16
  toAddress: string;
17
17
  memo: string;
18
18
  fromAccountIndex: number;
19
- spendingKey?: string;
19
+ spendingKey: string;
20
20
  }
21
- export interface TransactionQuery {
22
- offset?: number;
23
- limit?: number;
24
- startDate?: number;
25
- endDate?: number;
26
- }
27
- export interface ZcashTransaction {
21
+ export interface SpendSuccess {
28
22
  txId: string;
29
- accountIndex: number;
30
- fee: string;
31
- value: string;
32
- direction: 'inbound' | 'outbound';
33
- toAddress: string;
34
- memo?: string;
35
- minedHeight: number;
36
- blockTime: number;
23
+ raw: string;
37
24
  }
38
- export declare type PendingTransaction = ZcashTransaction & {
39
- expiryHeight: number;
40
- cancelled: number;
41
- submitAttempts: number;
25
+ export interface SpendFailure {
42
26
  errorMessage?: string;
43
- errorCode?: number;
44
- createTime: number;
45
- };
46
- export declare enum SynchronizerStatus {
47
- /** Indicates that [stop] has been called on this Synchronizer and it will no longer be used. */
48
- STOPPED = 0,
49
- /** Indicates that this Synchronizer is disconnected from its lightwalletd server. When set, a UI element may want to turn red. */
50
- DISCONNECTED = 1,
51
- /** Indicates that this Synchronizer is actively downloading new blocks from the server. */
52
- DOWNLOADING = 2,
53
- /** Indicates that this Synchronizer is actively validating new blocks that were downloaded from the server. Blocks need to be verified before they are scanned. This confirms that each block is chain-sequential, thereby detecting missing blocks and reorgs. */
54
- VALIDATING = 3,
55
- /** Indicates that this Synchronizer is actively decrypting new blocks that were downloaded from the server. */
56
- SCANNING = 4,
57
- /** Indicates that this Synchronizer is actively enhancing newly scanned blocks with additional transaction details, fetched from the server. */
58
- ENHANCING = 5,
59
- /** Indicates that this Synchronizer is fully up to date and ready for all wallet functions. When set, a UI element may want to turn green. In this state, the balance can be trusted. */
60
- SYNCED = 6
27
+ errorCode?: string;
28
+ }
29
+ export interface SynchronizerStatus {
30
+ alias: string;
31
+ name: 'STOPPED' /** Indicates that [stop] has been called on this Synchronizer and it will no longer be used. */ | 'DISCONNECTED' /** Indicates that this Synchronizer is disconnected from its lightwalletd server. When set, a UI element may want to turn red. */ | 'DOWNLOADING' /** Indicates that this Synchronizer is actively downloading new blocks from the server. */ | 'VALIDATING' /** Indicates that this Synchronizer is actively validating new blocks that were downloaded from the server. Blocks need to be verified before they are scanned. This confirms that each block is chain-sequential, thereby detecting missing blocks and reorgs. */ | 'SCANNING' /** Indicates that this Synchronizer is actively decrypting new blocks that were downloaded from the server. */ | 'ENHANCING' /** Indicates that this Synchronizer is actively enhancing newly scanned blocks with additional transaction details, fetched from the server. */ | 'SYNCED'; /** Indicates that this Synchronizer is fully up to date and ready for all wallet functions. When set, a UI element may want to turn green. In this state, the balance can be trusted. */
61
32
  }
62
33
  export interface UnifiedViewingKey {
63
34
  extfvk: string;
64
35
  extpub: string;
65
36
  }
37
+ export interface StatusEvent {
38
+ alias: string;
39
+ name: SynchronizerStatus;
40
+ }
66
41
  export interface UpdateEvent {
42
+ alias: string;
43
+ isDownloading: boolean;
44
+ isScanning: boolean;
67
45
  lastDownloadedHeight: number;
68
46
  lastScannedHeight: number;
69
47
  scanProgress: number;
70
48
  networkBlockHeight: number;
71
49
  }
72
50
  export interface SynchronizerCallbacks {
73
- onShieldedBalanceChanged(walletBalance: WalletBalance): void;
74
51
  onStatusChanged(status: SynchronizerStatus): void;
75
52
  onUpdate(event: UpdateEvent): void;
76
- onTransactionsChanged(count: number): void;
77
- onPendingTransactionUpdated(tx: PendingTransaction): void;
78
53
  }
79
54
  export interface BlockRange {
80
55
  first: number;
81
56
  last: number;
82
57
  }
83
58
  export interface ConfirmedTransaction {
84
- value: string;
85
- memo?: string;
86
- minedHeight: number;
87
59
  rawTransactionId: string;
60
+ blockTimeInSeconds: number;
61
+ minedHeight: number;
62
+ value: string;
88
63
  toAddress?: string;
64
+ memo?: string;
89
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-zcash",
3
- "version": "0.2.3",
3
+ "version": "0.3.2",
4
4
  "description": "Zcash library for React Native",
5
5
  "homepage": "https://github.com/EdgeApp/react-native-zcash",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  "src"
32
32
  ],
33
33
  "main": "lib/rnzcash.rn.js",
34
- "types": "lib/src/index.d.ts",
34
+ "types": "lib/src/react-native.d.ts",
35
35
  "scripts": {
36
36
  "fix": "npm run lint -- --fix",
37
37
  "lint": "eslint .",
@@ -9,19 +9,16 @@ import {
9
9
  ConfirmedTransaction,
10
10
  InitializerConfig,
11
11
  Network,
12
- PendingTransaction,
12
+ SpendFailure,
13
13
  SpendInfo,
14
+ SpendSuccess,
14
15
  SynchronizerCallbacks,
15
- SynchronizerStatus,
16
16
  UnifiedViewingKey,
17
17
  WalletBalance
18
18
  } from './types'
19
19
 
20
20
  const { RNZcash } = NativeModules
21
21
 
22
- const snooze: Function = (ms: number) =>
23
- new Promise((resolve: Function) => setTimeout(resolve, ms))
24
-
25
22
  type Callback = (...args: any[]) => any
26
23
 
27
24
  export const KeyTool = {
@@ -38,6 +35,10 @@ export const KeyTool = {
38
35
  ): Promise<string> => {
39
36
  const result = await RNZcash.deriveSpendingKey(seedBytesHex, network)
40
37
  return result
38
+ },
39
+ getBirthdayHeight: async (host: string, port: number): Promise<number> => {
40
+ const result = await RNZcash.getBirthdayHeight(host, port)
41
+ return result
41
42
  }
42
43
  }
43
44
 
@@ -65,7 +66,7 @@ export const AddressTool = {
65
66
  }
66
67
  }
67
68
 
68
- class Synchronizer {
69
+ export class Synchronizer {
69
70
  eventEmitter: NativeEventEmitter
70
71
  subscriptions: EventSubscription[]
71
72
  alias: string
@@ -78,39 +79,6 @@ class Synchronizer {
78
79
  this.network = network
79
80
  }
80
81
 
81
- /// ////////////////////////////////////////////////////////////////
82
- // Start PoC behavior
83
- // Here are a few functions to demonstrate functionality but the final library should not have these functions
84
- //
85
- async readyToSend(): Promise<boolean> {
86
- const result = await RNZcash.readyToSend()
87
- return result
88
- }
89
-
90
- async sendTestTransaction(
91
- key: string,
92
- address: string
93
- ): Promise<PendingTransaction> {
94
- // send an amount that's guaranteed to be too large for our wallet and expect it to fail but at least show how this is done
95
- // simply change these two values to send a real transaction but ensure the function isn't called too often (although funds can't be spent if notes are unconfirmed)
96
- const invalidValue = '9223372036854775807' // Max long value (change this to 10000 to send a small transaction equal to the miner's fee on every reload and you could send 10,000 of those before it equals 1 ZEC)
97
- const invalidAccount = 99 // should be 0
98
- return this.sendToAddress({
99
- zatoshi: invalidValue,
100
- toAddress: address,
101
- memo: 'this is a test transaction that will fail',
102
- fromAccountIndex: invalidAccount,
103
- spendingKey: key
104
- })
105
- }
106
-
107
- async getBlockCount(): Promise<number> {
108
- const result = await RNZcash.getBlockCount()
109
- return result
110
- }
111
- // End PoC behavior
112
- /// ////////////////////////////////////////////////////////////////
113
-
114
82
  async start(): Promise<String> {
115
83
  const result = await RNZcash.start(this.alias)
116
84
  return result
@@ -139,36 +107,11 @@ class Synchronizer {
139
107
  return result
140
108
  }
141
109
 
142
- async getLatestScannedHeight(): Promise<number> {
143
- const result = await RNZcash.getLatestScannedHeight()
144
- return result
145
- }
146
-
147
- async getProgress(): Promise<number> {
148
- const result = await RNZcash.getProgress()
149
- return result
150
- }
151
-
152
- async getStatus(): Promise<SynchronizerStatus> {
153
- const result = await RNZcash.getStatus()
154
- return SynchronizerStatus[result.name as keyof typeof SynchronizerStatus]
155
- }
156
-
157
110
  async getShieldedBalance(): Promise<WalletBalance> {
158
111
  const result = await RNZcash.getShieldedBalance(this.alias)
159
112
  return result
160
113
  }
161
114
 
162
- async getTransparentBalance(): Promise<WalletBalance> {
163
- // TODO: integrate with lightwalletd service to provide taddr balance. Edge probably doesn't need this, though so it can wait.
164
-
165
- await snooze(0) // Hack to make typescript happy
166
- return {
167
- availableZatoshi: '0',
168
- totalZatoshi: '0'
169
- }
170
- }
171
-
172
115
  async getTransactions(range: BlockRange): Promise<ConfirmedTransaction[]> {
173
116
  const result = await RNZcash.getTransactions(
174
117
  this.alias,
@@ -182,25 +125,20 @@ class Synchronizer {
182
125
  RNZcash.rescan(this.alias, height)
183
126
  }
184
127
 
185
- async sendToAddress(spendInfo: SpendInfo): Promise<PendingTransaction> {
128
+ async sendToAddress(
129
+ spendInfo: SpendInfo
130
+ ): Promise<SpendSuccess | SpendFailure> {
186
131
  const result = await RNZcash.spendToAddress(
187
132
  this.alias,
188
133
  spendInfo.zatoshi,
189
134
  spendInfo.toAddress,
190
135
  spendInfo.memo,
191
136
  spendInfo.fromAccountIndex,
192
- // TODO: ask is it okay to send this across the boundary or should it live on the native side and never leave?
193
137
  spendInfo.spendingKey
194
138
  )
195
139
  return result
196
140
  }
197
141
 
198
- // estimateFee (spendInfo: SpendInfo): string
199
- // sendToAddress (spendInfo: SpendInfo): void
200
-
201
- // getPendingTransactions (): PendingTransactions[]
202
- // getConfirmedTransactions (query: TransactionQuery): ZcashTransaction[]
203
-
204
142
  // Events
205
143
 
206
144
  subscribe({ onStatusChanged, onUpdate }: SynchronizerCallbacks): void {
package/src/types.ts CHANGED
@@ -19,52 +19,29 @@ export interface SpendInfo {
19
19
  toAddress: string
20
20
  memo: string
21
21
  fromAccountIndex: number
22
- spendingKey?: string
22
+ spendingKey: string
23
23
  }
24
24
 
25
- export interface TransactionQuery {
26
- offset?: number
27
- limit?: number
28
- startDate?: number
29
- endDate?: number
30
- }
31
-
32
- export interface ZcashTransaction {
25
+ export interface SpendSuccess {
33
26
  txId: string
34
- accountIndex: number
35
- fee: string
36
- value: string
37
- direction: 'inbound' | 'outbound'
38
- toAddress: string
39
- memo?: string
40
- minedHeight: number // 0 for unconfirmed
41
- blockTime: number // UNIX timestamp
27
+ raw: string
42
28
  }
43
29
 
44
- export type PendingTransaction = ZcashTransaction & {
45
- expiryHeight: number
46
- cancelled: number
47
- submitAttempts: number
30
+ export interface SpendFailure {
48
31
  errorMessage?: string
49
- errorCode?: number
50
- createTime: number
32
+ errorCode?: string
51
33
  }
52
34
 
53
- export enum SynchronizerStatus {
54
- /** Indicates that [stop] has been called on this Synchronizer and it will no longer be used. */
55
- STOPPED,
56
- /** Indicates that this Synchronizer is disconnected from its lightwalletd server. When set, a UI element may want to turn red. */
57
- DISCONNECTED,
58
- /** Indicates that this Synchronizer is actively downloading new blocks from the server. */
59
- DOWNLOADING,
60
- /** Indicates that this Synchronizer is actively validating new blocks that were downloaded from the server. Blocks need to be verified before they are scanned. This confirms that each block is chain-sequential, thereby detecting missing blocks and reorgs. */
61
- VALIDATING,
62
- /** Indicates that this Synchronizer is actively decrypting new blocks that were downloaded from the server. */
63
- SCANNING,
64
- /** Indicates that this Synchronizer is actively enhancing newly scanned blocks with additional transaction details, fetched from the server. */
65
- ENHANCING,
66
- /** Indicates that this Synchronizer is fully up to date and ready for all wallet functions. When set, a UI element may want to turn green. In this state, the balance can be trusted. */
67
- SYNCED
35
+ export interface SynchronizerStatus {
36
+ alias: string
37
+ name:
38
+ | 'STOPPED' /** Indicates that [stop] has been called on this Synchronizer and it will no longer be used. */
39
+ | 'DISCONNECTED' /** Indicates that this Synchronizer is disconnected from its lightwalletd server. When set, a UI element may want to turn red. */
40
+ | 'DOWNLOADING' /** Indicates that this Synchronizer is actively downloading new blocks from the server. */
41
+ | 'VALIDATING' /** Indicates that this Synchronizer is actively validating new blocks that were downloaded from the server. Blocks need to be verified before they are scanned. This confirms that each block is chain-sequential, thereby detecting missing blocks and reorgs. */
42
+ | 'SCANNING' /** Indicates that this Synchronizer is actively decrypting new blocks that were downloaded from the server. */
43
+ | 'ENHANCING' /** Indicates that this Synchronizer is actively enhancing newly scanned blocks with additional transaction details, fetched from the server. */
44
+ | 'SYNCED' /** Indicates that this Synchronizer is fully up to date and ready for all wallet functions. When set, a UI element may want to turn green. In this state, the balance can be trusted. */
68
45
  }
69
46
 
70
47
  export interface UnifiedViewingKey {
@@ -72,7 +49,15 @@ export interface UnifiedViewingKey {
72
49
  extpub: string
73
50
  }
74
51
 
52
+ export interface StatusEvent {
53
+ alias: string
54
+ name: SynchronizerStatus
55
+ }
56
+
75
57
  export interface UpdateEvent {
58
+ alias: string
59
+ isDownloading: boolean
60
+ isScanning: boolean
76
61
  lastDownloadedHeight: number
77
62
  lastScannedHeight: number
78
63
  scanProgress: number // 0 - 100
@@ -80,11 +65,8 @@ export interface UpdateEvent {
80
65
  }
81
66
 
82
67
  export interface SynchronizerCallbacks {
83
- onShieldedBalanceChanged(walletBalance: WalletBalance): void
84
68
  onStatusChanged(status: SynchronizerStatus): void
85
69
  onUpdate(event: UpdateEvent): void
86
- onTransactionsChanged(count: number): void
87
- onPendingTransactionUpdated(tx: PendingTransaction): void
88
70
  }
89
71
 
90
72
  export interface BlockRange {
@@ -93,9 +75,10 @@ export interface BlockRange {
93
75
  }
94
76
 
95
77
  export interface ConfirmedTransaction {
96
- value: string
97
- memo?: string
98
- minedHeight: number
99
78
  rawTransactionId: string
79
+ blockTimeInSeconds: number
80
+ minedHeight: number
81
+ value: string
100
82
  toAddress?: string
83
+ memo?: string
101
84
  }