react-native-zcash 0.8.0 → 0.9.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.
- package/CHANGELOG.md +10 -0
- package/android/build.gradle +3 -3
- package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/2640000.json +8 -0
- package/android/src/main/assets/co.electriccoin.zcash/checkpoint/mainnet/2650000.json +8 -0
- package/android/src/main/java/app/edge/rnzcash/RNZcashModule.kt +15 -25
- package/ios/RNZcash.m +3 -5
- package/ios/RNZcash.swift +42 -23
- package/ios/ZCashLightClientKit/Block/Actions/Action.swift +1 -0
- package/ios/ZCashLightClientKit/Block/Actions/EnhanceAction.swift +1 -1
- package/ios/ZCashLightClientKit/Block/Actions/ProcessSuggestedScanRangesAction.swift +1 -1
- package/ios/ZCashLightClientKit/Block/Actions/ScanAction.swift +1 -1
- package/ios/ZCashLightClientKit/Block/Actions/TxResubmissionAction.swift +75 -0
- package/ios/ZCashLightClientKit/Block/Actions/UpdateChainTipAction.swift +1 -1
- package/ios/ZCashLightClientKit/Block/Actions/UpdateSubtreeRootsAction.swift +3 -1
- package/ios/ZCashLightClientKit/Block/CompactBlockProcessor.swift +14 -0
- package/ios/ZCashLightClientKit/Block/Download/BlockDownloaderService.swift +2 -2
- package/ios/ZCashLightClientKit/Block/Enhance/BlockEnhancer.swift +54 -49
- package/ios/ZCashLightClientKit/Checkpoint/BundleCheckpointSource.swift +1 -6
- package/ios/ZCashLightClientKit/Checkpoint/CheckpointSourceFactory.swift +1 -1
- package/ios/ZCashLightClientKit/ClosureSynchronizer.swift +3 -1
- package/ios/ZCashLightClientKit/CombineSynchronizer.swift +6 -2
- package/ios/ZCashLightClientKit/Constants/ZcashSDK.swift +15 -0
- package/ios/ZCashLightClientKit/DAO/TransactionDao.swift +20 -4
- package/ios/ZCashLightClientKit/Entity/TransactionEntity.swift +27 -24
- package/ios/ZCashLightClientKit/Error/Sourcery/generateErrorCode.sh +2 -2
- package/ios/ZCashLightClientKit/Error/ZcashError.swift +32 -1
- package/ios/ZCashLightClientKit/Error/ZcashErrorCode.swift +11 -1
- package/ios/ZCashLightClientKit/Error/ZcashErrorCodeDefinition.swift +18 -0
- package/ios/ZCashLightClientKit/Initializer.swift +22 -14
- package/ios/ZCashLightClientKit/Metrics/SDKMetrics.swift +0 -1
- package/ios/ZCashLightClientKit/Model/FiatCurrencyResult.swift +25 -0
- package/ios/ZCashLightClientKit/Model/Proposal.swift +1 -1
- package/ios/ZCashLightClientKit/Model/TransactionDataRequest.swift +26 -0
- package/ios/ZCashLightClientKit/Model/WalletTypes.swift +39 -1
- package/ios/ZCashLightClientKit/Model/Zatoshi.swift +1 -1
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/LightWalletGRPCService.swift +39 -2
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/proto/service.proto +5 -4
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/service.grpc.swift +819 -3
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/service.pb.swift +2 -2
- package/ios/ZCashLightClientKit/Modules/Service/LightWalletService.swift +3 -1
- package/ios/ZCashLightClientKit/Providers/ResourceProvider.swift +10 -0
- package/ios/ZCashLightClientKit/Repository/TransactionRepository.swift +4 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2475000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2477500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2482500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2485000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2487500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2492500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2495000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2497500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2502500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2505000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2507500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2512500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2515000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2517500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2522500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2525000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2527500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2532500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2535000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2537500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2542500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2545000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2547500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2552500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2555000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2557500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2562500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2565000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2567500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2572500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2575000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2577500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2582500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2585000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2587500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2592500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2595000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2597500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2602500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2605000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2607500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2612500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2615000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2617500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2622500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2625000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2627500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2632500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2635000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2637500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2640000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2642500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2645000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2647500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2650000.json +8 -0
- package/ios/ZCashLightClientKit/Rust/ZcashKeyDerivationBackend.swift +4 -24
- package/ios/ZCashLightClientKit/Rust/ZcashKeyDerivationBackendWelding.swift +0 -15
- package/ios/ZCashLightClientKit/Rust/ZcashRustBackend.swift +133 -32
- package/ios/ZCashLightClientKit/Rust/ZcashRustBackendWelding.swift +18 -1
- package/ios/ZCashLightClientKit/Synchronizer/ClosureSDKSynchronizer.swift +4 -0
- package/ios/ZCashLightClientKit/Synchronizer/CombineSDKSynchronizer.swift +5 -1
- package/ios/ZCashLightClientKit/Synchronizer/Dependencies.swift +53 -3
- package/ios/ZCashLightClientKit/Synchronizer/SDKSynchronizer.swift +236 -7
- package/ios/ZCashLightClientKit/Synchronizer.swift +28 -0
- package/ios/ZCashLightClientKit/Tool/DerivationTool.swift +29 -5
- package/ios/ZCashLightClientKit/Tor/TorClient.swift +57 -0
- package/ios/ZCashLightClientKit/Utils/LoggingProxy.swift +4 -0
- package/ios/ZCashLightClientKit/Utils/OSLogger.swift +4 -0
- package/ios/libzcashlc.xcframework/Info.plist +5 -5
- package/ios/libzcashlc.xcframework/ios-arm64/libzcashlc.a +0 -0
- package/ios/libzcashlc.xcframework/ios-arm64_x86_64-simulator/libzcashlc.a +0 -0
- package/ios/zcashlc.h +287 -42
- package/lib/rnzcash.rn.js +8 -8
- package/lib/rnzcash.rn.js.map +1 -1
- package/lib/src/react-native.d.ts +3 -3
- package/lib/src/types.d.ts +4 -2
- package/package.json +1 -1
- package/src/react-native.ts +13 -18
- package/src/types.ts +5 -2
package/ios/zcashlc.h
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
#include <stdint.h>
|
|
4
4
|
#include <stdlib.h>
|
|
5
5
|
|
|
6
|
+
typedef struct TorRuntime TorRuntime;
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* A struct that contains details about an account in the wallet.
|
|
8
10
|
*/
|
|
@@ -277,17 +279,20 @@ typedef struct FFIBlocksMeta {
|
|
|
277
279
|
} FFIBlocksMeta;
|
|
278
280
|
|
|
279
281
|
/**
|
|
280
|
-
* A struct that contains a pointer to, and length information for, a
|
|
281
|
-
* boxed slice.
|
|
282
|
+
* A struct that optionally contains a pointer to, and length information for, a
|
|
283
|
+
* heap-allocated boxed slice.
|
|
284
|
+
*
|
|
285
|
+
* This is an FFI representation of `Option<Box<[u8]>>`.
|
|
282
286
|
*
|
|
283
287
|
* # Safety
|
|
284
288
|
*
|
|
285
|
-
* - `ptr`
|
|
286
|
-
* alignment of `1`.
|
|
289
|
+
* - If `ptr` is non-null, it must be valid for reads for `len` bytes, and it must have
|
|
290
|
+
* an alignment of `1`.
|
|
287
291
|
* - The memory referenced by `ptr` must not be mutated for the lifetime of the struct
|
|
288
292
|
* (up until [`zcashlc_free_boxed_slice`] is called with it).
|
|
289
293
|
* - The total size `len` must be no larger than `isize::MAX`. See the safety
|
|
290
294
|
* documentation of `pointer::offset`.
|
|
295
|
+
* - When `ptr` is null, `len` should be zero.
|
|
291
296
|
*/
|
|
292
297
|
typedef struct FfiBoxedSlice {
|
|
293
298
|
uint8_t *ptr;
|
|
@@ -316,16 +321,173 @@ typedef struct FfiTxIds {
|
|
|
316
321
|
uintptr_t len;
|
|
317
322
|
} FfiTxIds;
|
|
318
323
|
|
|
324
|
+
/**
|
|
325
|
+
* Metadata about the status of a transaction obtained by inspecting the chain state.
|
|
326
|
+
*/
|
|
327
|
+
enum FfiTransactionStatus_Tag {
|
|
328
|
+
/**
|
|
329
|
+
* The requested transaction ID was not recognized by the node.
|
|
330
|
+
*/
|
|
331
|
+
TxidNotRecognized,
|
|
332
|
+
/**
|
|
333
|
+
* The requested transaction ID corresponds to a transaction that is recognized by the node,
|
|
334
|
+
* but is in the mempool or is otherwise not mined in the main chain (but may have been mined
|
|
335
|
+
* on a fork that was reorged away).
|
|
336
|
+
*/
|
|
337
|
+
NotInMainChain,
|
|
338
|
+
/**
|
|
339
|
+
* The requested transaction ID corresponds to a transaction that has been included in the
|
|
340
|
+
* block at the provided height.
|
|
341
|
+
*/
|
|
342
|
+
Mined,
|
|
343
|
+
};
|
|
344
|
+
typedef uint8_t FfiTransactionStatus_Tag;
|
|
345
|
+
|
|
346
|
+
typedef struct FfiTransactionStatus {
|
|
347
|
+
FfiTransactionStatus_Tag tag;
|
|
348
|
+
union {
|
|
349
|
+
struct {
|
|
350
|
+
uint32_t mined;
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
} FfiTransactionStatus;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* A request for transaction data enhancement, spentness check, or discovery
|
|
357
|
+
* of spends from a given transparent address within a specific block range.
|
|
358
|
+
*/
|
|
359
|
+
enum FfiTransactionDataRequest_Tag {
|
|
360
|
+
/**
|
|
361
|
+
* Information about the chain's view of a transaction is requested.
|
|
362
|
+
*
|
|
363
|
+
* The caller evaluating this request on behalf of the wallet backend should respond to this
|
|
364
|
+
* request by determining the status of the specified transaction with respect to the main
|
|
365
|
+
* chain; if using `lightwalletd` for access to chain data, this may be obtained by
|
|
366
|
+
* interpreting the results of the [`GetTransaction`] RPC method. It should then call
|
|
367
|
+
* [`WalletWrite::set_transaction_status`] to provide the resulting transaction status
|
|
368
|
+
* information to the wallet backend.
|
|
369
|
+
*
|
|
370
|
+
* [`GetTransaction`]: crate::proto::service::compact_tx_streamer_client::CompactTxStreamerClient::get_transaction
|
|
371
|
+
*/
|
|
372
|
+
GetStatus,
|
|
373
|
+
/**
|
|
374
|
+
* Transaction enhancement (download of complete raw transaction data) is requested.
|
|
375
|
+
*
|
|
376
|
+
* The caller evaluating this request on behalf of the wallet backend should respond to this
|
|
377
|
+
* request by providing complete data for the specified transaction to
|
|
378
|
+
* [`wallet::decrypt_and_store_transaction`]; if using `lightwalletd` for access to chain
|
|
379
|
+
* state, this may be obtained via the [`GetTransaction`] RPC method. If no data is available
|
|
380
|
+
* for the specified transaction, this should be reported to the backend using
|
|
381
|
+
* [`WalletWrite::set_transaction_status`]. A [`TransactionDataRequest::Enhancement`] request
|
|
382
|
+
* subsumes any previously existing [`TransactionDataRequest::GetStatus`] request.
|
|
383
|
+
*
|
|
384
|
+
* [`GetTransaction`]: crate::proto::service::compact_tx_streamer_client::CompactTxStreamerClient::get_transaction
|
|
385
|
+
*/
|
|
386
|
+
Enhancement,
|
|
387
|
+
/**
|
|
388
|
+
* Information about transactions that receive or spend funds belonging to the specified
|
|
389
|
+
* transparent address is requested.
|
|
390
|
+
*
|
|
391
|
+
* Fully transparent transactions, and transactions that do not contain either shielded inputs
|
|
392
|
+
* or shielded outputs belonging to the wallet, may not be discovered by the process of chain
|
|
393
|
+
* scanning; as a consequence, the wallet must actively query to find transactions that spend
|
|
394
|
+
* such funds. Ideally we'd be able to query by [`OutPoint`] but this is not currently
|
|
395
|
+
* functionality that is supported by the light wallet server.
|
|
396
|
+
*
|
|
397
|
+
* The caller evaluating this request on behalf of the wallet backend should respond to this
|
|
398
|
+
* request by detecting transactions involving the specified address within the provided block
|
|
399
|
+
* range; if using `lightwalletd` for access to chain data, this may be performed using the
|
|
400
|
+
* [`GetTaddressTxids`] RPC method. It should then call [`wallet::decrypt_and_store_transaction`]
|
|
401
|
+
* for each transaction so detected.
|
|
402
|
+
*
|
|
403
|
+
* [`GetTaddressTxids`]: crate::proto::service::compact_tx_streamer_client::CompactTxStreamerClient::get_taddress_txids
|
|
404
|
+
*/
|
|
405
|
+
SpendsFromAddress,
|
|
406
|
+
};
|
|
407
|
+
typedef uint8_t FfiTransactionDataRequest_Tag;
|
|
408
|
+
|
|
409
|
+
typedef struct SpendsFromAddress_Body {
|
|
410
|
+
char *address;
|
|
411
|
+
uint32_t block_range_start;
|
|
412
|
+
/**
|
|
413
|
+
* An optional end height; no end height is represented as `-1`
|
|
414
|
+
*/
|
|
415
|
+
int64_t block_range_end;
|
|
416
|
+
} SpendsFromAddress_Body;
|
|
417
|
+
|
|
418
|
+
typedef struct FfiTransactionDataRequest {
|
|
419
|
+
FfiTransactionDataRequest_Tag tag;
|
|
420
|
+
union {
|
|
421
|
+
struct {
|
|
422
|
+
uint8_t get_status[32];
|
|
423
|
+
};
|
|
424
|
+
struct {
|
|
425
|
+
uint8_t enhancement[32];
|
|
426
|
+
};
|
|
427
|
+
SpendsFromAddress_Body spends_from_address;
|
|
428
|
+
};
|
|
429
|
+
} FfiTransactionDataRequest;
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* A struct that contains a pointer to, and length information for, a heap-allocated
|
|
433
|
+
* slice of [`FfiTransactionDataRequest`] values.
|
|
434
|
+
*
|
|
435
|
+
* # Safety
|
|
436
|
+
*
|
|
437
|
+
* - `ptr` must be non-null and must be valid for reads for `len * mem::size_of::<FfiTransactionDataRequest>()`
|
|
438
|
+
* many bytes, and it must be properly aligned. This means in particular:
|
|
439
|
+
* - The entire memory range pointed to by `ptr` must be contained within a single allocated
|
|
440
|
+
* object. Slices can never span across multiple allocated objects.
|
|
441
|
+
* - `ptr` must be non-null and aligned even for zero-length slices.
|
|
442
|
+
* - `ptr` must point to `len` consecutive properly initialized values of type
|
|
443
|
+
* [`FfiTransactionDataRequest`].
|
|
444
|
+
* - The total size `len * mem::size_of::<FfiTransactionDataRequest>()` of the slice pointed to
|
|
445
|
+
* by `ptr` must be no larger than isize::MAX. See the safety documentation of pointer::offset.
|
|
446
|
+
* - See the safety documentation of [`FfiTransactionDataRequest`]
|
|
447
|
+
*/
|
|
448
|
+
typedef struct FfiTransactionDataRequests {
|
|
449
|
+
struct FfiTransactionDataRequest *ptr;
|
|
450
|
+
uintptr_t len;
|
|
451
|
+
} FfiTransactionDataRequests;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* A decimal suitable for converting into an `NSDecimalNumber`.
|
|
455
|
+
*/
|
|
456
|
+
typedef struct Decimal {
|
|
457
|
+
uint64_t mantissa;
|
|
458
|
+
int16_t exponent;
|
|
459
|
+
bool is_sign_negative;
|
|
460
|
+
} Decimal;
|
|
461
|
+
|
|
319
462
|
/**
|
|
320
463
|
* Initializes global Rust state, such as the logging infrastructure and threadpools.
|
|
321
464
|
*
|
|
322
|
-
*
|
|
465
|
+
* `log_level` defines how the Rust layer logs its events. These values are supported,
|
|
466
|
+
* each level logging more information in addition to the earlier levels:
|
|
467
|
+
* - `off`: The logs are completely disabled.
|
|
468
|
+
* - `error`: Logs very serious errors.
|
|
469
|
+
* - `warn`: Logs hazardous situations.
|
|
470
|
+
* - `info`: Logs useful information.
|
|
471
|
+
* - `debug`: Logs lower priority information.
|
|
472
|
+
* - `trace`: Logs very low priority, often extremely verbose, information.
|
|
473
|
+
*
|
|
474
|
+
* # Safety
|
|
475
|
+
*
|
|
476
|
+
* - The memory pointed to by `log_level` must contain a valid nul terminator at the end
|
|
477
|
+
* of the string.
|
|
478
|
+
* - `log_level` must be valid for reads of bytes up to and including the nul terminator.
|
|
479
|
+
* This means in particular:
|
|
480
|
+
* - The entire memory range of this `CStr` must be contained within a single allocated
|
|
481
|
+
* object!
|
|
482
|
+
* - The memory referenced by the returned `CStr` must not be mutated for the duration of
|
|
483
|
+
* the function call.
|
|
484
|
+
* - The nul terminator must be within `isize::MAX` from `log_level`.
|
|
323
485
|
*
|
|
324
486
|
* # Panics
|
|
325
487
|
*
|
|
326
488
|
* This method panics if called more than once.
|
|
327
489
|
*/
|
|
328
|
-
void zcashlc_init_on_load(
|
|
490
|
+
void zcashlc_init_on_load(const char *log_level);
|
|
329
491
|
|
|
330
492
|
/**
|
|
331
493
|
* Returns the length of the last error message to be logged.
|
|
@@ -469,6 +631,20 @@ struct FFIBinaryKey *zcashlc_create_account(const uint8_t *db_data,
|
|
|
469
631
|
* - `1` for `Ok(true)`.
|
|
470
632
|
* - `0` for `Ok(false)`.
|
|
471
633
|
* - `-1` for `Err(_)`.
|
|
634
|
+
*
|
|
635
|
+
* # Safety
|
|
636
|
+
*
|
|
637
|
+
* - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
|
|
638
|
+
* alignment of `1`. Its contents must be a string representing a valid system path in the
|
|
639
|
+
* operating system's preferred representation.
|
|
640
|
+
* - The memory referenced by `db_data` must not be mutated for the duration of the function call.
|
|
641
|
+
* - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
|
|
642
|
+
* documentation of pointer::offset.
|
|
643
|
+
* - `seed` must be non-null and valid for reads for `seed_len` bytes, and it must have an
|
|
644
|
+
* alignment of `1`.
|
|
645
|
+
* - The memory referenced by `seed` must not be mutated for the duration of the function call.
|
|
646
|
+
* - The total size `seed_len` must be no larger than `isize::MAX`. See the safety documentation
|
|
647
|
+
* of pointer::offset.
|
|
472
648
|
*/
|
|
473
649
|
int8_t zcashlc_is_seed_relevant_to_any_derived_account(const uint8_t *db_data,
|
|
474
650
|
uintptr_t db_data_len,
|
|
@@ -637,17 +813,6 @@ char *zcashlc_get_transparent_receiver_for_unified_address(const char *ua);
|
|
|
637
813
|
*/
|
|
638
814
|
char *zcashlc_get_sapling_receiver_for_unified_address(const char *ua);
|
|
639
815
|
|
|
640
|
-
/**
|
|
641
|
-
* Returns true when the provided address decodes to a valid Sapling payment address for the
|
|
642
|
-
* specified network, false in any other case.
|
|
643
|
-
*
|
|
644
|
-
* # Safety
|
|
645
|
-
*
|
|
646
|
-
* - `address` must be non-null and must point to a null-terminated UTF-8 string.
|
|
647
|
-
* - The memory referenced by `address` must not be mutated for the duration of the function call.
|
|
648
|
-
*/
|
|
649
|
-
bool zcashlc_is_valid_sapling_address(const char *address, uint32_t network_id);
|
|
650
|
-
|
|
651
816
|
/**
|
|
652
817
|
* Returns the network type and address kind for the given address string,
|
|
653
818
|
* if the address is a valid Zcash address.
|
|
@@ -657,6 +822,7 @@ bool zcashlc_is_valid_sapling_address(const char *address, uint32_t network_id);
|
|
|
657
822
|
* * p2sh: 1
|
|
658
823
|
* * sapling: 2
|
|
659
824
|
* * unified: 3
|
|
825
|
+
* * tex: 4
|
|
660
826
|
*
|
|
661
827
|
* # Safety
|
|
662
828
|
*
|
|
@@ -667,17 +833,6 @@ bool zcashlc_get_address_metadata(const char *address,
|
|
|
667
833
|
uint32_t *network_id_ret,
|
|
668
834
|
uint32_t *addr_kind_ret);
|
|
669
835
|
|
|
670
|
-
/**
|
|
671
|
-
* Returns true when the address is a valid transparent payment address for the specified network,
|
|
672
|
-
* false in any other case.
|
|
673
|
-
*
|
|
674
|
-
* # Safety
|
|
675
|
-
*
|
|
676
|
-
* - `address` must be non-null and must point to a null-terminated UTF-8 string.
|
|
677
|
-
* - The memory referenced by `address` must not be mutated for the duration of the function call.
|
|
678
|
-
*/
|
|
679
|
-
bool zcashlc_is_valid_transparent_address(const char *address, uint32_t network_id);
|
|
680
|
-
|
|
681
836
|
/**
|
|
682
837
|
* Returns true when the provided key decodes to a valid Sapling extended spending key for the
|
|
683
838
|
* specified network, false in any other case.
|
|
@@ -712,18 +867,6 @@ bool zcashlc_is_valid_viewing_key(const char *key, uint32_t network_id);
|
|
|
712
867
|
*/
|
|
713
868
|
bool zcashlc_is_valid_unified_full_viewing_key(const char *ufvk, uint32_t network_id);
|
|
714
869
|
|
|
715
|
-
/**
|
|
716
|
-
* Returns true when the provided key decodes to a valid unified address for the
|
|
717
|
-
* specified network, false in any other case.
|
|
718
|
-
*
|
|
719
|
-
* # Safety
|
|
720
|
-
*
|
|
721
|
-
* - `address` must be non-null and must point to a null-terminated UTF-8 string.
|
|
722
|
-
* - The memory referenced by `address` must not be mutated for the duration of the
|
|
723
|
-
* function call.
|
|
724
|
-
*/
|
|
725
|
-
bool zcashlc_is_valid_unified_address(const char *address, uint32_t network_id);
|
|
726
|
-
|
|
727
870
|
/**
|
|
728
871
|
* Returns the verified transparent balance for `address`, which ignores utxos that have been
|
|
729
872
|
* received too recently and are not yet deemed spendable according to `min_confirmations`.
|
|
@@ -1266,7 +1409,7 @@ int32_t zcashlc_decrypt_and_store_transaction(const uint8_t *db_data,
|
|
|
1266
1409
|
uintptr_t db_data_len,
|
|
1267
1410
|
const uint8_t *tx,
|
|
1268
1411
|
uintptr_t tx_len,
|
|
1269
|
-
|
|
1412
|
+
int64_t mined_height,
|
|
1270
1413
|
uint32_t network_id);
|
|
1271
1414
|
|
|
1272
1415
|
/**
|
|
@@ -1295,6 +1438,8 @@ void zcashlc_free_boxed_slice(struct FfiBoxedSlice *ptr);
|
|
|
1295
1438
|
* - `to` must be non-null and must point to a null-terminated UTF-8 string.
|
|
1296
1439
|
* - `memo` must either be null (indicating an empty memo or a transparent recipient) or point to a
|
|
1297
1440
|
* 512-byte array.
|
|
1441
|
+
* - Call [`zcashlc_free_boxed_slice`] to free the memory associated with the returned
|
|
1442
|
+
* pointer when done using it.
|
|
1298
1443
|
*/
|
|
1299
1444
|
struct FfiBoxedSlice *zcashlc_propose_transfer(const uint8_t *db_data,
|
|
1300
1445
|
uintptr_t db_data_len,
|
|
@@ -1322,7 +1467,9 @@ struct FfiBoxedSlice *zcashlc_propose_transfer(const uint8_t *db_data,
|
|
|
1322
1467
|
* - `payment_uri` must be non-null and must point to a null-terminated UTF-8 string.
|
|
1323
1468
|
* - `network_id` a u32. 0 for Testnet and 1 for Mainnet
|
|
1324
1469
|
* - `min_confirmations` number of confirmations of the funds to spend
|
|
1325
|
-
* - `use_zip317_fees` `true
|
|
1470
|
+
* - `use_zip317_fees` `true` to use ZIP-317 fees.
|
|
1471
|
+
* - Call [`zcashlc_free_boxed_slice`] to free the memory associated with the returned
|
|
1472
|
+
* pointer when done using it.
|
|
1326
1473
|
*/
|
|
1327
1474
|
struct FfiBoxedSlice *zcashlc_propose_transfer_from_uri(const uint8_t *db_data,
|
|
1328
1475
|
uintptr_t db_data_len,
|
|
@@ -1357,6 +1504,8 @@ void zcashlc_string_free(char *s);
|
|
|
1357
1504
|
* - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
|
|
1358
1505
|
* documentation of pointer::offset.
|
|
1359
1506
|
* - `shielding_threshold` a non-negative shielding threshold amount in zatoshi
|
|
1507
|
+
* - Call [`zcashlc_free_boxed_slice`] to free the memory associated with the returned
|
|
1508
|
+
* pointer when done using it.
|
|
1360
1509
|
*/
|
|
1361
1510
|
struct FfiBoxedSlice *zcashlc_propose_shielding(const uint8_t *db_data,
|
|
1362
1511
|
uintptr_t db_data_len,
|
|
@@ -1439,3 +1588,99 @@ struct FfiTxIds *zcashlc_create_proposed_transactions(const uint8_t *db_data,
|
|
|
1439
1588
|
const uint8_t *output_params,
|
|
1440
1589
|
uintptr_t output_params_len,
|
|
1441
1590
|
uint32_t network_id);
|
|
1591
|
+
|
|
1592
|
+
/**
|
|
1593
|
+
* Sets the transaction status to the provided value.
|
|
1594
|
+
*
|
|
1595
|
+
* # Safety
|
|
1596
|
+
*
|
|
1597
|
+
* - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must
|
|
1598
|
+
* have an alignment of `1`. Its contents must be a string representing a valid system
|
|
1599
|
+
* path in the operating system's preferred representation.
|
|
1600
|
+
* - The memory referenced by `db_data` must not be mutated for the duration of the
|
|
1601
|
+
* function call.
|
|
1602
|
+
* - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
|
|
1603
|
+
* documentation of pointer::offset.
|
|
1604
|
+
* - `txid_bytes` must be non-null and valid for reads for `db_data_len` bytes, and it must have
|
|
1605
|
+
* an alignment of `1`.
|
|
1606
|
+
* - The memory referenced by `txid_bytes_len` must not be mutated for the duration of the
|
|
1607
|
+
* function call.
|
|
1608
|
+
* - The total size `txid_bytes_len` must be no larger than `isize::MAX`. See the safety
|
|
1609
|
+
* documentation of pointer::offset.
|
|
1610
|
+
*/
|
|
1611
|
+
void zcashlc_set_transaction_status(const uint8_t *db_data,
|
|
1612
|
+
uintptr_t db_data_len,
|
|
1613
|
+
uint32_t network_id,
|
|
1614
|
+
const uint8_t *txid_bytes,
|
|
1615
|
+
uintptr_t txid_bytes_len,
|
|
1616
|
+
struct FfiTransactionStatus status);
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* Frees an array of FfiTransactionDataRequest values as allocated by `zcashlc_transaction_data_requests`.
|
|
1620
|
+
*
|
|
1621
|
+
* # Safety
|
|
1622
|
+
*
|
|
1623
|
+
* - `ptr` if `ptr` is non-null it must point to a struct having the layout of [`FfiTransactionDataRequests`].
|
|
1624
|
+
* See the safety documentation of [`FfiTransactionDataRequests`].
|
|
1625
|
+
*/
|
|
1626
|
+
void zcashlc_free_transaction_data_requests(struct FfiTransactionDataRequests *ptr);
|
|
1627
|
+
|
|
1628
|
+
/**
|
|
1629
|
+
* Returns a list of transaction data requests that the network client should satisfy.
|
|
1630
|
+
*
|
|
1631
|
+
* # Safety
|
|
1632
|
+
*
|
|
1633
|
+
* - `db_data` must be non-null and valid for reads for `db_data_len` bytes, and it must have an
|
|
1634
|
+
* alignment of `1`. Its contents must be a string representing a valid system path in the
|
|
1635
|
+
* operating system's preferred representation.
|
|
1636
|
+
* - The memory referenced by `db_data` must not be mutated for the duration of the function call.
|
|
1637
|
+
* - The total size `db_data_len` must be no larger than `isize::MAX`. See the safety
|
|
1638
|
+
* documentation of pointer::offset.
|
|
1639
|
+
* - Call [`zcashlc_free_transaction_data_requests`] to free the memory associated with the
|
|
1640
|
+
* returned pointer when done using it.
|
|
1641
|
+
*/
|
|
1642
|
+
struct FfiTransactionDataRequests *zcashlc_transaction_data_requests(const uint8_t *db_data,
|
|
1643
|
+
uintptr_t db_data_len,
|
|
1644
|
+
uint32_t network_id);
|
|
1645
|
+
|
|
1646
|
+
/**
|
|
1647
|
+
* Creates a Tor runtime.
|
|
1648
|
+
*
|
|
1649
|
+
* # Safety
|
|
1650
|
+
*
|
|
1651
|
+
* - `tor_dir` must be non-null and valid for reads for `tor_dir_len` bytes, and it must
|
|
1652
|
+
* have an alignment of `1`. Its contents must be a string representing a valid system
|
|
1653
|
+
* path in the operating system's preferred representation.
|
|
1654
|
+
* - The memory referenced by `tor_dir` must not be mutated for the duration of the
|
|
1655
|
+
* function call.
|
|
1656
|
+
* - The total size `tor_dir_len` must be no larger than `isize::MAX`. See the safety
|
|
1657
|
+
* documentation of pointer::offset.
|
|
1658
|
+
* - Call [`zcashlc_free_tor_runtime`] to free the memory associated with the returned
|
|
1659
|
+
* pointer when done using it.
|
|
1660
|
+
*/
|
|
1661
|
+
struct TorRuntime *zcashlc_create_tor_runtime(const uint8_t *tor_dir, uintptr_t tor_dir_len);
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* Frees a Tor runtime.
|
|
1665
|
+
*
|
|
1666
|
+
* # Safety
|
|
1667
|
+
*
|
|
1668
|
+
* - If `ptr` is non-null, it must point to a struct having the layout of [`TorRuntime`].
|
|
1669
|
+
*/
|
|
1670
|
+
void zcashlc_free_tor_runtime(struct TorRuntime *ptr);
|
|
1671
|
+
|
|
1672
|
+
/**
|
|
1673
|
+
* Fetches the current ZEC-USD exchange rate over Tor.
|
|
1674
|
+
*
|
|
1675
|
+
* The result is a [`Decimal`] struct containing the fields necessary to construct an
|
|
1676
|
+
* [`NSDecimalNumber`](https://developer.apple.com/documentation/foundation/nsdecimalnumber/1416003-init).
|
|
1677
|
+
*
|
|
1678
|
+
* Returns a negative value on error.
|
|
1679
|
+
*
|
|
1680
|
+
* # Safety
|
|
1681
|
+
*
|
|
1682
|
+
* - `tor_runtime` must be non-null and point to a struct having the layout of
|
|
1683
|
+
* [`TorRuntime`].
|
|
1684
|
+
* - `tor_runtime` must not be passed to two FFI calls at the same time.
|
|
1685
|
+
*/
|
|
1686
|
+
struct Decimal zcashlc_get_exchange_rate_usd(struct TorRuntime *tor_runtime);
|
package/lib/rnzcash.rn.js
CHANGED
|
@@ -159,8 +159,8 @@ var Synchronizer = /*#__PURE__*/function () {
|
|
|
159
159
|
}();
|
|
160
160
|
|
|
161
161
|
_proto.proposeTransfer = /*#__PURE__*/function () {
|
|
162
|
-
var _proposeTransfer = _asyncToGenerator(function* (
|
|
163
|
-
var result = yield RNZcash.proposeTransfer(this.alias,
|
|
162
|
+
var _proposeTransfer = _asyncToGenerator(function* (opts) {
|
|
163
|
+
var result = yield RNZcash.proposeTransfer(this.alias, opts.zatoshi, opts.toAddress, opts.memo);
|
|
164
164
|
return result;
|
|
165
165
|
});
|
|
166
166
|
|
|
@@ -171,17 +171,17 @@ var Synchronizer = /*#__PURE__*/function () {
|
|
|
171
171
|
return proposeTransfer;
|
|
172
172
|
}();
|
|
173
173
|
|
|
174
|
-
_proto.
|
|
175
|
-
var
|
|
176
|
-
var result = yield RNZcash.
|
|
174
|
+
_proto.createTransfer = /*#__PURE__*/function () {
|
|
175
|
+
var _createTransfer = _asyncToGenerator(function* (opts) {
|
|
176
|
+
var result = yield RNZcash.createTransfer(this.alias, opts.proposalBase64, opts.mnemonicSeed);
|
|
177
177
|
return result;
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
-
function
|
|
181
|
-
return
|
|
180
|
+
function createTransfer(_x10) {
|
|
181
|
+
return _createTransfer.apply(this, arguments);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
return
|
|
184
|
+
return createTransfer;
|
|
185
185
|
}();
|
|
186
186
|
|
|
187
187
|
_proto.shieldFunds = /*#__PURE__*/function () {
|
package/lib/rnzcash.rn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rnzcash.rn.js","sources":["../src/react-native.ts"],"sourcesContent":["import { add } from 'biggystring'\nimport {\n EventSubscription,\n NativeEventEmitter,\n NativeModules\n} from 'react-native'\n\nimport {\n Addresses,\n InitializerConfig,\n Network,\n ProposalSuccess,\n ShieldFundsInfo,\n SpendFailure,\n SpendInfo,\n SpendSuccess,\n SynchronizerCallbacks,\n Transaction,\n TransferSpendInfo\n} from './types'\nexport * from './types'\n\nconst { RNZcash } = NativeModules\n\ntype Callback = (...args: any[]) => any\n\nexport const Tools = {\n deriveViewingKey: async (\n seedBytesHex: string,\n network: Network\n ): Promise<string> => {\n const result = await RNZcash.deriveViewingKey(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 isValidAddress: async (\n address: string,\n network: Network = 'mainnet'\n ): Promise<boolean> => {\n const result = await RNZcash.isValidAddress(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 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.mnemonicSeed,\n initializerConfig.birthdayHeight,\n initializerConfig.alias,\n initializerConfig.networkName,\n initializerConfig.defaultHost,\n initializerConfig.defaultPort,\n initializerConfig.newWallet\n )\n }\n\n async deriveUnifiedAddress(): Promise<Addresses> {\n const result = await RNZcash.deriveUnifiedAddress(this.alias)\n return result\n }\n\n async getLatestNetworkHeight(alias: string): Promise<number> {\n const result = await RNZcash.getLatestNetworkHeight(alias)\n return result\n }\n\n async rescan(): Promise<void> {\n await RNZcash.rescan(this.alias)\n }\n\n async proposeTransfer(\n spendInfo: TransferSpendInfo\n ): Promise<ProposalSuccess> {\n const result = await RNZcash.proposeTransfer(\n this.alias,\n spendInfo.zatoshi,\n spendInfo.toAddress,\n spendInfo.memo\n )\n return result\n }\n\n async sendToAddress(\n spendInfo: SpendInfo\n ): Promise<SpendSuccess | SpendFailure> {\n const result = await RNZcash.sendToAddress(\n this.alias,\n spendInfo.zatoshi,\n spendInfo.toAddress,\n spendInfo.memo,\n spendInfo.mnemonicSeed\n )\n return result\n }\n\n async shieldFunds(shieldFundsInfo: ShieldFundsInfo): Promise<Transaction> {\n const result = await RNZcash.shieldFunds(\n this.alias,\n shieldFundsInfo.seed,\n shieldFundsInfo.memo,\n shieldFundsInfo.threshold\n )\n return result\n }\n\n // Events\n\n subscribe({\n onBalanceChanged,\n onStatusChanged,\n onTransactionsChanged,\n onUpdate,\n onError\n }: SynchronizerCallbacks): void {\n this.setListener('BalanceEvent', event => {\n const {\n transparentAvailableZatoshi,\n transparentTotalZatoshi,\n saplingAvailableZatoshi,\n saplingTotalZatoshi,\n orchardAvailableZatoshi,\n orchardTotalZatoshi\n } = event\n\n event.availableZatoshi = add(\n add(transparentAvailableZatoshi, saplingAvailableZatoshi),\n orchardAvailableZatoshi\n )\n event.totalZatoshi = add(\n add(transparentTotalZatoshi, saplingTotalZatoshi),\n orchardTotalZatoshi\n )\n onBalanceChanged(event)\n })\n this.setListener('StatusEvent', onStatusChanged)\n this.setListener('TransactionEvent', onTransactionsChanged)\n this.setListener('UpdateEvent', onUpdate)\n this.setListener('ErrorEvent', onError)\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","Tools","deriveViewingKey","seedBytesHex","network","result","getBirthdayHeight","host","port","isValidAddress","address","Synchronizer","alias","eventEmitter","NativeEventEmitter","subscriptions","stop","unsubscribe","initialize","initializerConfig","mnemonicSeed","birthdayHeight","networkName","defaultHost","defaultPort","newWallet","deriveUnifiedAddress","getLatestNetworkHeight","rescan","proposeTransfer","spendInfo","zatoshi","toAddress","memo","sendToAddress","shieldFunds","shieldFundsInfo","seed","threshold","subscribe","onBalanceChanged","onStatusChanged","onTransactionsChanged","onUpdate","onError","setListener","event","transparentAvailableZatoshi","transparentTotalZatoshi","saplingAvailableZatoshi","saplingTotalZatoshi","orchardAvailableZatoshi","orchardTotalZatoshi","availableZatoshi","add","totalZatoshi","eventName","callback","t","push","addListener","arg","forEach","subscription","remove","makeSynchronizer","synchronizer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
|
+
{"version":3,"file":"rnzcash.rn.js","sources":["../src/react-native.ts"],"sourcesContent":["import { add } from 'biggystring'\nimport {\n EventSubscription,\n NativeEventEmitter,\n NativeModules\n} from 'react-native'\n\nimport {\n Addresses,\n CreateTransferOpts,\n InitializerConfig,\n Network,\n ProposalSuccess,\n ProposeTransferOpts,\n ShieldFundsInfo,\n SpendFailure,\n SynchronizerCallbacks,\n Transaction\n} from './types'\nexport * from './types'\n\nconst { RNZcash } = NativeModules\n\ntype Callback = (...args: any[]) => any\n\nexport const Tools = {\n deriveViewingKey: async (\n seedBytesHex: string,\n network: Network\n ): Promise<string> => {\n const result = await RNZcash.deriveViewingKey(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 isValidAddress: async (\n address: string,\n network: Network = 'mainnet'\n ): Promise<boolean> => {\n const result = await RNZcash.isValidAddress(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 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.mnemonicSeed,\n initializerConfig.birthdayHeight,\n initializerConfig.alias,\n initializerConfig.networkName,\n initializerConfig.defaultHost,\n initializerConfig.defaultPort,\n initializerConfig.newWallet\n )\n }\n\n async deriveUnifiedAddress(): Promise<Addresses> {\n const result = await RNZcash.deriveUnifiedAddress(this.alias)\n return result\n }\n\n async getLatestNetworkHeight(alias: string): Promise<number> {\n const result = await RNZcash.getLatestNetworkHeight(alias)\n return result\n }\n\n async rescan(): Promise<void> {\n await RNZcash.rescan(this.alias)\n }\n\n async proposeTransfer(opts: ProposeTransferOpts): Promise<ProposalSuccess> {\n const result = await RNZcash.proposeTransfer(\n this.alias,\n opts.zatoshi,\n opts.toAddress,\n opts.memo\n )\n return result\n }\n\n async createTransfer(\n opts: CreateTransferOpts\n ): Promise<string | SpendFailure> {\n const result = await RNZcash.createTransfer(\n this.alias,\n opts.proposalBase64,\n opts.mnemonicSeed\n )\n return result\n }\n\n async shieldFunds(shieldFundsInfo: ShieldFundsInfo): Promise<Transaction> {\n const result = await RNZcash.shieldFunds(\n this.alias,\n shieldFundsInfo.seed,\n shieldFundsInfo.memo,\n shieldFundsInfo.threshold\n )\n return result\n }\n\n // Events\n\n subscribe({\n onBalanceChanged,\n onStatusChanged,\n onTransactionsChanged,\n onUpdate,\n onError\n }: SynchronizerCallbacks): void {\n this.setListener('BalanceEvent', event => {\n const {\n transparentAvailableZatoshi,\n transparentTotalZatoshi,\n saplingAvailableZatoshi,\n saplingTotalZatoshi,\n orchardAvailableZatoshi,\n orchardTotalZatoshi\n } = event\n\n event.availableZatoshi = add(\n add(transparentAvailableZatoshi, saplingAvailableZatoshi),\n orchardAvailableZatoshi\n )\n event.totalZatoshi = add(\n add(transparentTotalZatoshi, saplingTotalZatoshi),\n orchardTotalZatoshi\n )\n onBalanceChanged(event)\n })\n this.setListener('StatusEvent', onStatusChanged)\n this.setListener('TransactionEvent', onTransactionsChanged)\n this.setListener('UpdateEvent', onUpdate)\n this.setListener('ErrorEvent', onError)\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","Tools","deriveViewingKey","seedBytesHex","network","result","getBirthdayHeight","host","port","isValidAddress","address","Synchronizer","alias","eventEmitter","NativeEventEmitter","subscriptions","stop","unsubscribe","initialize","initializerConfig","mnemonicSeed","birthdayHeight","networkName","defaultHost","defaultPort","newWallet","deriveUnifiedAddress","getLatestNetworkHeight","rescan","proposeTransfer","opts","zatoshi","toAddress","memo","createTransfer","proposalBase64","shieldFunds","shieldFundsInfo","seed","threshold","subscribe","onBalanceChanged","onStatusChanged","onTransactionsChanged","onUpdate","onError","setListener","event","transparentAvailableZatoshi","transparentTotalZatoshi","saplingAvailableZatoshi","saplingTotalZatoshi","orchardAvailableZatoshi","orchardTotalZatoshi","availableZatoshi","add","totalZatoshi","eventName","callback","t","push","addListener","arg","forEach","subscription","remove","makeSynchronizer","synchronizer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqBQA,UAAYC,0BAAZD;IAIKE,KAAK,GAAG;AACnBC,EAAAA,gBAAgB;AAAA,8CAAE,WAChBC,YADgB,EAEhBC,OAFgB,EAGI;AACpB,UAAMC,MAAM,SAASN,OAAO,CAACG,gBAAR,CAAyBC,YAAzB,EAAuCC,OAAvC,CAArB;AACA,aAAOC,MAAP;AACD,KANe;;AAAA;AAAA;AAAA;;AAAA;AAAA,KADG;AAQnBC,EAAAA,iBAAiB;AAAA,+CAAE,WAAOC,IAAP,EAAqBC,IAArB,EAAuD;AACxE,UAAMH,MAAM,SAASN,OAAO,CAACO,iBAAR,CAA0BC,IAA1B,EAAgCC,IAAhC,CAArB;AACA,aAAOH,MAAP;AACD,KAHgB;;AAAA;AAAA;AAAA;;AAAA;AAAA,KARE;AAYnBI,EAAAA,cAAc;AAAA,4CAAE,WACdC,OADc,EAEdN,OAFc,EAGO;AAAA,UADrBA,OACqB;AADrBA,QAAAA,OACqB,GADF,SACE;AAAA;;AACrB,UAAMC,MAAM,SAASN,OAAO,CAACU,cAAR,C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A2C,IADD;AAAA,KAA5C,CADF;AAKD,GAxHH;;AAAA,SA0HE7C,WA1HF,GA0HE,uBAAoB;AAClB,SAAKF,aAAL,CAAmBgD,OAAnB,CAA2B,UAAAC,YAAY,EAAI;AACzCA,MAAAA,YAAY,CAACC,MAAb;AACD,KAFD;AAGD,GA9HH;;AAAA;AAAA;IAiIaC,gBAAgB;AAAA,gCAAG,WAC9B/C,iBAD8B,EAEJ;AAC1B,QAAMgD,YAAY,GAAG,IAAIxD,YAAJ,CACnBQ,iBAAiB,CAACP,KADC,EAEnBO,iBAAiB,CAACG,WAFC,CAArB;AAIA,UAAM6C,YAAY,CAACjD,UAAb,CAAwBC,iBAAxB,CAAN;AACA,WAAOgD,YAAP;AACD,GAT4B;;AAAA,kBAAhBD,gBAAgB;AAAA;AAAA;AAAA;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventSubscription, NativeEventEmitter } from 'react-native';
|
|
2
|
-
import { Addresses, InitializerConfig, Network, ProposalSuccess, ShieldFundsInfo, SpendFailure,
|
|
2
|
+
import { Addresses, CreateTransferOpts, InitializerConfig, Network, ProposalSuccess, ProposeTransferOpts, ShieldFundsInfo, SpendFailure, SynchronizerCallbacks, Transaction } from './types';
|
|
3
3
|
export * from './types';
|
|
4
4
|
export declare const Tools: {
|
|
5
5
|
deriveViewingKey: (seedBytesHex: string, network: Network) => Promise<string>;
|
|
@@ -17,8 +17,8 @@ export declare class Synchronizer {
|
|
|
17
17
|
deriveUnifiedAddress(): Promise<Addresses>;
|
|
18
18
|
getLatestNetworkHeight(alias: string): Promise<number>;
|
|
19
19
|
rescan(): Promise<void>;
|
|
20
|
-
proposeTransfer(
|
|
21
|
-
|
|
20
|
+
proposeTransfer(opts: ProposeTransferOpts): Promise<ProposalSuccess>;
|
|
21
|
+
createTransfer(opts: CreateTransferOpts): Promise<string | SpendFailure>;
|
|
22
22
|
shieldFunds(shieldFundsInfo: ShieldFundsInfo): Promise<Transaction>;
|
|
23
23
|
subscribe({ onBalanceChanged, onStatusChanged, onTransactionsChanged, onUpdate, onError }: SynchronizerCallbacks): void;
|
|
24
24
|
private setListener;
|
package/lib/src/types.d.ts
CHANGED
|
@@ -8,13 +8,14 @@ export interface InitializerConfig {
|
|
|
8
8
|
birthdayHeight: number;
|
|
9
9
|
newWallet: boolean;
|
|
10
10
|
}
|
|
11
|
-
export interface
|
|
11
|
+
export interface ProposeTransferOpts {
|
|
12
12
|
zatoshi: string;
|
|
13
13
|
toAddress: string;
|
|
14
14
|
memo?: string;
|
|
15
15
|
}
|
|
16
|
-
export interface
|
|
16
|
+
export interface CreateTransferOpts {
|
|
17
17
|
mnemonicSeed: string;
|
|
18
|
+
proposalBase64: string;
|
|
18
19
|
}
|
|
19
20
|
export interface ShieldFundsInfo {
|
|
20
21
|
seed: string;
|
|
@@ -22,6 +23,7 @@ export interface ShieldFundsInfo {
|
|
|
22
23
|
threshold: string;
|
|
23
24
|
}
|
|
24
25
|
export interface ProposalSuccess {
|
|
26
|
+
proposalBase64: string;
|
|
25
27
|
transactionCount: number;
|
|
26
28
|
totalFee: string;
|
|
27
29
|
}
|
package/package.json
CHANGED
package/src/react-native.ts
CHANGED
|
@@ -7,16 +7,15 @@ import {
|
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
Addresses,
|
|
10
|
+
CreateTransferOpts,
|
|
10
11
|
InitializerConfig,
|
|
11
12
|
Network,
|
|
12
13
|
ProposalSuccess,
|
|
14
|
+
ProposeTransferOpts,
|
|
13
15
|
ShieldFundsInfo,
|
|
14
16
|
SpendFailure,
|
|
15
|
-
SpendInfo,
|
|
16
|
-
SpendSuccess,
|
|
17
17
|
SynchronizerCallbacks,
|
|
18
|
-
Transaction
|
|
19
|
-
TransferSpendInfo
|
|
18
|
+
Transaction
|
|
20
19
|
} from './types'
|
|
21
20
|
export * from './types'
|
|
22
21
|
|
|
@@ -90,27 +89,23 @@ export class Synchronizer {
|
|
|
90
89
|
await RNZcash.rescan(this.alias)
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
async proposeTransfer(
|
|
94
|
-
spendInfo: TransferSpendInfo
|
|
95
|
-
): Promise<ProposalSuccess> {
|
|
92
|
+
async proposeTransfer(opts: ProposeTransferOpts): Promise<ProposalSuccess> {
|
|
96
93
|
const result = await RNZcash.proposeTransfer(
|
|
97
94
|
this.alias,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
opts.zatoshi,
|
|
96
|
+
opts.toAddress,
|
|
97
|
+
opts.memo
|
|
101
98
|
)
|
|
102
99
|
return result
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
async
|
|
106
|
-
|
|
107
|
-
): Promise<
|
|
108
|
-
const result = await RNZcash.
|
|
102
|
+
async createTransfer(
|
|
103
|
+
opts: CreateTransferOpts
|
|
104
|
+
): Promise<string | SpendFailure> {
|
|
105
|
+
const result = await RNZcash.createTransfer(
|
|
109
106
|
this.alias,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
spendInfo.memo,
|
|
113
|
-
spendInfo.mnemonicSeed
|
|
107
|
+
opts.proposalBase64,
|
|
108
|
+
opts.mnemonicSeed
|
|
114
109
|
)
|
|
115
110
|
return result
|
|
116
111
|
}
|
package/src/types.ts
CHANGED
|
@@ -10,13 +10,15 @@ export interface InitializerConfig {
|
|
|
10
10
|
newWallet: boolean
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export interface
|
|
13
|
+
export interface ProposeTransferOpts {
|
|
14
14
|
zatoshi: string
|
|
15
15
|
toAddress: string
|
|
16
16
|
memo?: string
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
export interface CreateTransferOpts {
|
|
19
20
|
mnemonicSeed: string
|
|
21
|
+
proposalBase64: string
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export interface ShieldFundsInfo {
|
|
@@ -26,6 +28,7 @@ export interface ShieldFundsInfo {
|
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export interface ProposalSuccess {
|
|
31
|
+
proposalBase64: string
|
|
29
32
|
transactionCount: number
|
|
30
33
|
totalFee: string
|
|
31
34
|
}
|