Commit Graph

58 Commits

Author SHA1 Message Date
Honza ef248c9dc5 Throw exception instead of custom error
- This step unify our approach to validation on client side across all server calls
2023-01-31 09:32:34 +01:00
Honza 0e4d634693 Merge + changelog update
- Updated changelog
- Merged branch 'main' into 615-networking-module

* main:
  [#882] Check properties on CI
  [#874] GRPC 1.52.1
  [#892] Emulator.wtf Gradle Plugin 0.0.15
  [#888] Android Gradle Plugin 7.4
  [#851] Androidx Updates
  [#851] Kotlin 1.8
  [#779] Resolve flaky DatabaseCoordinatorTest
  [#886] Support null block heights
  [#881] Use variables for Test Lab
  [#860] Flank 23.01.0

# Conflicts:
#	CHANGELOG.md
#	gradle.properties
2023-01-30 09:56:21 +01:00
Honza e2d1d93ac2 Unify new clients instances name 2023-01-29 18:37:44 +01:00
Honza b57b379416 Rename local variable 2023-01-25 10:45:28 +01:00
Carter Jernigan 30979e5ebf [#851] Androidx Updates
Note that the APIs for Room, Sqlite, and Compose changed slightly with these dependency updates
2023-01-18 11:23:25 -05:00
Honza 64e5a5cfa5 Adopt enhanced GRPC response model
- Adopted in a few endpoints
2023-01-16 17:50:36 +01:00
Carter Jernigan 4ad1da49d0
[#886] Support null block heights
Co-authored-by: Honza <rychnovsky.honza@gmail.com>
2023-01-12 11:32:43 -05:00
Honza b1b474af5b Repackage cash.z.wallet.sdk.rpc to cash.z.wallet.sdk.internal.rpc 2023-01-11 16:18:33 +01:00
Honza 8e1bef361d Merge branch 'main' into 615-networking-module
* main: (108 commits)
  [#862] Disable logging with ProGuard for Demo-app
  [#704] No static field PREVIEW_SDK_INT
  [#824] rust: cargo update
  [#855] Abandoned address property
  [#854] Regular checkpoint files update
  [#850] Use new API for build step outputs
  Bump actions/cache from 3.2.0 to 3.2.2 in /.github/actions/setup
  [#631] Initial Compose scaffolding for demo app
  Bump actions/cache from 3.0.11 to 3.2.0 in /.github/actions/setup (#845)
  [#841] Ktlint 0.48.0
  [#795] Detekt 1.22.0
  [#820] Kotlin 1.7.21 + KSP 1.7.21
  rust: Lower default log level to INFO
  Initialize the Rust library atomically
  rust: Cache span names as `CString`s
  rust: Document NDK methods and expose `ATrace_isEnabled`
  rust: cargo update
  [#819] Dokka 1.7.20
  [#815] Gradle Versions Plugin 0.44.0
  [#796] Gradle 7.6
  ...

# Conflicts:
#	CHANGELOG.md
#	darkside-test-lib/src/androidTest/java/cash/z/ecc/android/sdk/darkside/test/TestWallet.kt
#	demo-app/src/androidTest/java/cash/z/wallet/sdk/sample/demoapp/SampleCodeTest.kt
#	demo-app/src/main/java/cash/z/ecc/android/sdk/demoapp/MainActivity.kt
#	demo-app/src/main/java/cash/z/ecc/android/sdk/demoapp/demos/getbalance/GetBalanceFragment.kt
#	demo-app/src/main/java/cash/z/ecc/android/sdk/demoapp/demos/listtransactions/ListTransactionsFragment.kt
#	demo-app/src/main/java/cash/z/ecc/android/sdk/demoapp/demos/listutxos/ListUtxosFragment.kt
#	demo-app/src/main/java/cash/z/ecc/android/sdk/demoapp/demos/send/SendFragment.kt
#	gradle.properties
#	sdk-lib/src/androidTest/java/cash/z/ecc/android/sdk/integration/SanityTest.kt
#	sdk-lib/src/androidTest/java/cash/z/ecc/android/sdk/integration/TestnetIntegrationTest.kt
#	sdk-lib/src/androidTest/java/cash/z/ecc/android/sdk/integration/service/ChangeServiceTest.kt
#	sdk-lib/src/androidTest/java/cash/z/ecc/android/sdk/internal/transaction/PersistentTransactionManagerTest.kt
#	sdk-lib/src/androidTest/java/cash/z/ecc/android/sdk/util/TestWallet.kt
#	sdk-lib/src/main/AndroidManifest.xml
#	sdk-lib/src/main/java/cash/z/ecc/android/sdk/Initializer.kt
#	sdk-lib/src/main/java/cash/z/ecc/android/sdk/SdkSynchronizer.kt
#	sdk-lib/src/main/java/cash/z/ecc/android/sdk/Synchronizer.kt
#	sdk-lib/src/main/java/cash/z/ecc/android/sdk/block/CompactBlockProcessor.kt
#	sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/block/CompactBlockDownloader.kt
#	sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/service/LightWalletGrpcService.kt
#	sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/transaction/PersistentTransactionManager.kt
#	settings.gradle.kts
2023-01-09 14:29:14 +01:00
Honza Rychnovsky c3e41a68c2
[#795] Detekt 1.22.0
* [#795] Detekt 1.22.0

* Fix rules/its findings
2022-12-19 08:08:25 +01:00
Honza Rychnovsky 97c0628798
[#789] Benchmarking Demo-app
* [#789] Add Benchmark module to Demo-app

* Code cleanup

* Opti-in experimental coroutines api in tests

* Add Testing documentation

* Documentation update + ktlint

* Check screen on and keyguard unlocked in each test

* Introduce UiAutomator extensions

* Enhance BenchmarkTrace events definition

* Remove unnecessary mutex

* Change blocks range

* Increase sync blockchain timeout

- To always fit in the Balances screen timeout for the selected blocks range

* Remove unnecessary fun suspend modifiers

* Macrobenchmark lib bump to 1.2.0-alpha8

* Remove duplicate label attr in app/manifest

* File and link benchmark on CI task

* Add proguard keep rules

* Documentation update
2022-12-13 14:25:09 +01:00
Carter Jernigan 103d2748c6 [#780] Fix failure to submit transactions 2022-11-17 08:35:37 -05:00
Carter Jernigan 3eddd56691 [#778] Fix PendingTransactionEntity crash 2022-11-17 08:35:37 -05:00
Carter Jernigan 6a6cbf4048 [#760] Fix database queries
This resolves some query regressions that were introduced as part of [#705]
2022-11-04 10:01:09 -04:00
Carter Jernigan 61f1c1a9cb
[#753] Add API for querying recipients 2022-10-31 15:27:34 -04:00
Carter Jernigan 9af6986e43
[#748] Internal recipients for pending transactions 2022-10-26 21:37:40 -04:00
Carter Jernigan f169b112ef [#743] Add API for reading memos 2022-10-24 11:54:57 -04:00
Carter Jernigan 4c2807aefd
[#705] Roomoval
The Android and Rust code have previously managed joint custody of the derived data database.  With more complex migrations now required, we need to make the Android side read-only.  To achieve that, the Android side will remove Room and instead rely on more primitive SQLite APIs for read-only access.

As part of implementing this change, database management throughout the SDK is being refactored.

There will be multiple representations of the data:
 - Database representation (and some Entity representations in the places that Room hasn’t been removed yet).  These representations are not as type safe and don’t match Kotlin best practices in all cases.
 - Once #615 is implemented there will also be network representations
 - Type safe models, which often appear in the public API  The Database and Network representations will be converted to and from the type safe model representation.
2022-10-19 16:52:54 -04:00
Carter Jernigan f2effc8dd2 Merge branch 'main' of github.com:zcash/zcash-android-wallet-sdk into merge-main
# Conflicts:
#	CHANGELOG.md
#	sdk-lib/src/androidTest/java/cash/z/ecc/android/sdk/ext/TestExtensions.kt
#	sdk-lib/src/androidTest/java/cash/z/ecc/android/sdk/integration/SanityTest.kt
#	sdk-lib/src/androidTest/java/cash/z/ecc/android/sdk/integration/SmokeTest.kt
#	sdk-lib/src/androidTest/java/cash/z/ecc/android/sdk/util/AddressGeneratorUtil.kt
#	sdk-lib/src/androidTest/java/cash/z/ecc/android/sdk/util/BalancePrinterUtil.kt
#	sdk-lib/src/main/java/cash/z/ecc/android/sdk/Initializer.kt
#	sdk-lib/src/main/java/cash/z/ecc/android/sdk/SdkSynchronizer.kt
#	sdk-lib/src/main/java/cash/z/ecc/android/sdk/Synchronizer.kt
#	sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/transaction/WalletTransactionEncoder.kt
#	sdk-lib/src/main/java/cash/z/ecc/android/sdk/jni/RustBackendWelding.kt
2022-10-18 07:28:12 -04:00
Carter Jernigan 4c2fdeeb73 Add Account type 2022-10-06 14:49:04 -04:00
Jack Grigg 88bbd0afcb Use the binary USK format for transaction creation
Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-10-06 14:49:04 -04:00
Carter Jernigan 3b826f8f6a Simplify Synchronizer instantiation
fix

synchronizer
2022-10-06 14:49:04 -04:00
Carter Jernigan 597cc43886 Replace `Synchronizer.getAddress()` with `Synchronizer.getCurrentAddress()`
The SDK now exposes UAs primarily, with additional methods for obtaining
corresponding Sapling and transparent addresses for legacy compatibility.

The `Account` DAO is also fixed to use the migrated `accounts` table format.

The demo app now shows the current UA and the legacy Sapling and transparent
addresses.

Closes zcash/zcash-android-wallet-sdk#677.
2022-10-06 14:49:04 -04:00
Jack Grigg c6fd783317 Add a `seed` argument to `Synchronizer.Companion.new`
This enables callers to recover from an error that indicates the seed
is needed for a database migration.
2022-10-06 14:49:04 -04:00
Jack Grigg b19ee179c5 Migrate to latest revision of `zcash_primitives` 2022-10-06 14:49:04 -04:00
Honza Rychnovsky e62ca0de70
[#665] Recover from corrupted sapling-spend.params and sapling-output.params files
* [#665] Recover from corrupted sapling-spend.params and sapling-output.params

* Make parameters on exception internal

* Make SaplingParameters internal

* Fix for changed parameters visibility in tests

Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-09-27 07:03:36 +02:00
Carter Jernigan b58ffec5ba [#615] Refactor lightwalletd client
This moves the lightwalletd client code to a separate Gradle module, but does not yet do much clean up the public API (e.g. hiding generated GRPC objects).  That will be a followon change via #673

I’ve prototyped a safer version of the API that would be implemented for #673 for two specific calls: obtaining the current block height and obtaining the light wallet info.  These were the easiest endpoints to update and they provide a useful exploration for the future changes needed.
2022-09-14 15:33:36 -04:00
Honza Rychnovsky 35e38ddb19
[#666] Download sapling files atomically (#707)
- Enhanced implementation of SaplingParamTool component. It got sapling files move from legacy folder to the preferred one functionality. It downloads the sapling files atomically now (through the temporary file names). It contains all related constants now. It works with SaplingParamToolProperties, which allows us to easily test the SaplingParamTool functionalities. It also now checks file hashes. Removed unnecessary clear function from the component. Changed valid function.
- Moved related constants from ZcashSdk class to SaplingParamTool class
- Changed Initializer, WalletTransactionEncoder and RustBackend classes to work with File instead of path String
- Minor changes in comments in other classes
- Added getSha1Hash() extension function to the FileExt class

* Related tests

- Two new test fixtures to simplify our tests
- Test for getSha1Hash() extension function
- Minor changes in existing tests
- Created new SaplingParamToolBasicTest, which covers non-integration functionality of SaplingParamTool
- Moved integration tests of the SaplingParamTool to the new SaplingParamToolIntegrationTest and added some new

* Related manual tests

- Created Download sapling files manual test
- Created Move sapling files to no_backup manual test
- Update existing Move database files to no_bakcup manual test


Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-09-06 06:44:33 -04:00
Bruno Wieczorek ec6b714f92
[#288] Replace Deprecated Usage of `ConflatedBroadcastChannel`
Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-08-27 08:25:54 -04:00
Honza Rychnovsky 12c23dd054
[#664] Check sapling files size
* [#664] Transfer maximum bytes from remote file
* Tests for limiting sapling files max size
* Address comments from review
* Optimization of sapling files download
* Add units to data class
Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-08-26 15:31:56 +02:00
Honza Rychnovsky 1fae5beab6
[#509] Remove OkHttp and Okio dependencies
* [#509] Remove OkHttp and Okio dependencies
- Okio -> Java NIO anf OkHttp -> HttpURLConnection in SaplingParamTool class
- Both replaced also in the test packages
- Removed dependencies to the replaced components
- Again switched a few assertions from JUnit to kotlin.test
- Created readLinesInFlow() function which is now reused in few places and runs without OkHttp
- Added subsequent TODOs to code base
- Wrapped to withContext to move it to an IO thread.
- Added use function on the stream and close() at the end of the channels use.
Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-08-25 14:36:57 +02:00
Jack Grigg 0b80bff23d Merge branch 'main' into merge-detekt-warning-fixes 2022-08-23 21:28:01 +01:00
Honza Rychnovsky 345af7aacc
[#366] Fix Detekt warnings
* Disable baseline file. Too many functions.
* CurrencyFormatter.kt suppress too many functions
* PersistentTransactionManager.kt suppress too many functions
* OutboundTransactionManager suppress too many functions
* Suppress long parameter list
* Too many functions
* Add log to avoid empty block warning
* Fix several magic number warnings
* Solve max line length warnings
* Solve max line length warnings
* Suppress too long method warnings
* Suppress too complex method warnings
* Suppress large class warning
* Fixed empty catch block
* Changed directory path to the file
* Fix too generic and swallowed exception
* Fix print stack trace warning
* Suppressed single top level file name declaration
* Change parameters name
* Suppress Spread operator warning
* Remove unused private code
* Add Locale to suppress default locale used warning
* Solve several forbidden TODOs warnings
* Fixed another max line length warning
* Simplify return statement
* Suppress class to object change
* Make DemoConstants variables const
* Use error() instead of throwing an IllegalStateException
* Solve too complex condition
* Suppress intentionally generic and swallowed exception
* Suppress TooGenericExceptionCaught
* Solve or suppress several TooGenericExceptionCaught
* Fix swallowed exception
* Suppress warning TooGenericExceptionCaught of PersistentTransactionManager
* Suppress warning TooGenericExceptionCaught of WalletTransactionEncoder
* Suppress TooGenericExceptionCaught of SdkSynchronizer
* Suppress TooGenericExceptionCaught in SaplingParamTool
* Suppress TooGenericExceptionCaught in CompactBlockDownloader
* Suppress TooGenericExceptionCaught in CheckpointTool
* Fix TooGenericExceptionCaught in WalletService
* Suppress TooGenericExceptionCaught in DerivedDataDb
* Suppress TooGenericExceptionCaught in CompactBlockProcessor
* Apply ktlint format after all the previous changes
* Remove detekt baseline file
* Set Android studio right margin
* Address comments from review
* Suppress failing tests on CI
2022-08-23 15:49:00 +02:00
Jack Grigg 5db232cba7 Fix mismatched variable names in overridden methods 2022-08-23 00:16:14 +01:00
Jack Grigg 0a2b2d32f6 Merge branch 'main' into merge-1.9.0-beta03 2022-08-22 21:36:51 +01:00
Jack Grigg 609cc861e9 Merge tag 'v1.9.0-beta03' into merge-1.9.0-beta03 2022-08-22 21:23:43 +01:00
Jack Grigg 46af668449 [#525] Add `AddressType.Unified` and `Synchronizer.isValidUnifiedAddr` 2022-08-22 20:57:41 +01:00
Jack Grigg cfdd3640a9 [#525] Derive transparent account privkey instead of transparent secret key
We need the transparent account privkey in order to be able to derive
the secret key for any leaf transparent address under the ZIP 316
diversified address tree.
2022-08-22 20:57:41 +01:00
Carter Jernigan f7c9bad367 [#525] Replace UnifiedViewingKey with UnifiedFullViewingKey
UnifiedViewingKey had a bug that made it incompatible with ZIP 316.

For compatibility with the current `zcash/librustzcash` revision we use
a temporary fake UFVK encoding that stores sufficient information to use
the current APIs, and a superset of the actual ZIP 316 FVK information.
2022-08-22 20:57:41 +01:00
Honza Rychnovsky 150778f008
[#367] Fix Kotlin compiler warnings
* Fix missing room schema export directory
* Fix returned unused fields from cursor
* Fix missing db column index
* Improved TODO. Added suppress warning
* Changed parameters name to correspond to their supertype
* Changed type to Kotlin variant
* Use priority parameter
* Unified parameter names
* Suppress unchecked type warning
* Removed inline function
* Suppress obsolete coroutine warnings
* Improve previous commit
* Fix unnecessary safe call warning
* Remove unused parameter
* Unreachable code
* toLowerCase where possible
* Changed parameter name
* Suppress several "unused" warnings
* Fixed fromHtml() deprecation
* Suppress intentionally unused parameter warning
* Remove redundant initializer
* Remove inline function
* Suppress intentionally used deprecated code
* Unreachable code
* Suppress obsolete coroutine warnings
* Suppress intentionally unused parameter
* Remove unused expression
* Supertype parameter name
* Warnings of GetBlockRangeFragment.kt
* Deprecated onActivityCreated
* Suppress obsolete coroutine/flow warnings
* Unnecessary null check
* Suppress intentionally unused parameter
* Suppress intentionally unused parameters
* Deprecated onActivityCreated
* Predetermined type
* ListUtxosFragment clean code
* Suppress intentionally unused parameter
* Lint checks warnings fix
* Add data db migration
* Enable treating Kotlin compiler warnings as errors
* Solve several darkside-test-lib tests warnings
* Solve several demo-app tests warnings
* Solve several sdk-lib tests warnings
* Ktlint check result fix
* Remove parentheses now that Synchronizer is not cast
* Remove wildcard imports for java.util
* Revert "Add data db migration"
* Revert "Fix missing db column index"
* Suppress missing indexes on data db entities

Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-08-17 15:48:02 +02:00
Honza Rychnovsky c721a5e24e
[#343] Store database files in no_backup folder
Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-08-12 11:05:00 -04:00
Carter Jernigan e01a906407
[#593] Refactor ZcashNetwork
Splits the ZcashNetwork and Lightwalletd server information, making it easier to configure different servers
2022-08-02 09:29:09 -04:00
Carter Jernigan 3535ba905e [#629] Stream blocks during download
This change leverages the gRPC streaming API along with the elimination of bulk inserts to SQLite to reduce the amount of memory required to write blocks.
2022-07-28 15:49:46 -04:00
Carter Jernigan 8e3c4a636f [#610] Fix block download regression
This includes a few different fixes that prevented the demo app and other SDK consumers from working.

First, initialization of the demo app was fixed to use the sapling activation height rather than the current latest checkpoint.

Second, CompactBlockProcessor wasn’t downloading blocks.

Third, a few potential thread safety issues were resolved by making fields that are accessed by multiple threads volatile.
2022-07-26 08:46:53 -04:00
Carter Jernigan 1135353a84
[#606] Fix BlockHeight read from CompactBlockStore 2022-07-15 07:09:00 -04:00
Carter Jernigan 9b666833b1
[#474] Add type safe BlockHeight API
- Replace int with type safe BlockHeight(Long) object
 - Fix down casting bug, as BlockHeight is uint32 but Java only supports int32 or int64
 - Rename WalletBirthday to Checkpoint and hide from the public API
2022-07-12 08:40:09 -04:00
Carter Jernigan a1cc8f0b69 [#477] Fixes for Zatoshi object 2022-07-07 13:45:03 -04:00
Carter Jernigan 3fa7a98fbf [#580] ktlint 0.46.1
Update baseline
2022-06-27 08:42:37 -04:00
Carter Jernigan 823e8387cb
[#477] Typesafe Zatoshi APIs for amounts 2022-06-21 19:34:42 -04:00
Carter Jernigan 971c65a520 [#549] Update checkpoints
This resolves several issues including:
 - Updated checkpoints
 - #550 Support for new checkpoint format with NU5
 - #377 Removed explicit dependency on GSON
2022-06-14 13:42:46 -04:00