Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from ZIP 32 account indices to UUID account identifiers #1640

Merged
merged 47 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9b35832
Switch from ZIP 32 account indices to UUID account identifiers
str4d Nov 22, 2024
56a3858
Rename TransactionRecipient.Account
HonzaR Dec 3, 2024
c66b7ad
Fix `Backend.createAccount` API parameters
HonzaR Dec 4, 2024
5d07455
Add `importAccountUfvk` to the Rust backend.
nuttycom Dec 4, 2024
c8c1b2a
Propagate accountName and keySource across SDK
HonzaR Dec 4, 2024
5c3d1b5
Propagate new importAccount across SDK
HonzaR Dec 5, 2024
32e68e3
Wrap createAccount setup information
HonzaR Dec 5, 2024
cdfdbc9
Wrap importAccount setup information
HonzaR Dec 5, 2024
1cfba57
WIP: Add key derivation metadata to JniAccount
nuttycom Dec 6, 2024
7efea35
Fix JniAccount
HonzaR Dec 6, 2024
c1d2ff8
Use updated JniAccount across SDK
HonzaR Dec 6, 2024
ee27c0e
Several tests fix
HonzaR Dec 8, 2024
d87c5bd
Add `Zip32AccountIndex` wrapper
HonzaR Dec 9, 2024
d2b4d1f
Update key source parameter
HonzaR Dec 9, 2024
e4ffb26
Merge branch 'feature-2.2.7' into account-uuids
HonzaR Dec 9, 2024
02e1569
Remove account from `UnifiedSpendingKey`
HonzaR Dec 9, 2024
8823694
Fix `importAccountByUfvk` API
HonzaR Dec 9, 2024
922eb0e
Remove account_uuid from `JniUnifiedSpendingKey` creation
HonzaR Dec 9, 2024
7a95e23
Fixture fix
HonzaR Dec 9, 2024
89b06e4
Refactor Account.accountUuid to wrapper class
HonzaR Dec 9, 2024
d9482b1
Revert "Remove account_uuid from `JniUnifiedSpendingKey` creation"
HonzaR Dec 10, 2024
f669645
Add `JniAccountUsk`
HonzaR Dec 10, 2024
63a9a54
Add `seedFingerprint` and `zip32AccountIndex`
HonzaR Dec 10, 2024
fe653d4
Transactions by account UUID
HonzaR Dec 10, 2024
52f5b28
Refactor default account creation
HonzaR Dec 10, 2024
0909a73
Migrate to Rust crate revision with bugfix to account UUID migration
str4d Dec 10, 2024
477c933
Migrate to Rust crate revision with another bugfix to account UUID mi…
str4d Dec 10, 2024
d299b21
Test fix
HonzaR Dec 11, 2024
3c74069
Migrate to Rust crate revision with a third bugfix to account UUID mi…
str4d Dec 11, 2024
e54fb17
Self-review fixes
HonzaR Dec 11, 2024
51f5cd4
Tests fix
HonzaR Dec 11, 2024
c9bc790
Changelog update
HonzaR Dec 11, 2024
8b558f7
Update backend-lib/src/main/rust/lib.rs
HonzaR Dec 11, 2024
105da9d
Update backend-lib/src/main/rust/lib.rs
HonzaR Dec 11, 2024
0b603e2
Changelog update
HonzaR Dec 11, 2024
c68be81
Update sdk-lib/src/main/java/cash/z/ecc/android/sdk/Synchronizer.kt
HonzaR Dec 11, 2024
d07857c
Update sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/Typesafe…
HonzaR Dec 11, 2024
0fae465
Update sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/Typesafe…
HonzaR Dec 11, 2024
f78ed39
Update sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/Typesafe…
HonzaR Dec 11, 2024
b59e768
Update sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/Typesafe…
HonzaR Dec 11, 2024
e01773e
Update sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/Typesafe…
HonzaR Dec 11, 2024
840df94
Update sdk-lib/src/main/java/cash/z/ecc/android/sdk/model/AccountImpo…
HonzaR Dec 11, 2024
07f357e
Update sdk-lib/src/main/java/cash/z/ecc/android/sdk/model/AccountCrea…
HonzaR Dec 11, 2024
a03ae02
Update sdk-lib/src/main/java/cash/z/ecc/android/sdk/model/Account.kt
HonzaR Dec 11, 2024
cb8036d
Update sdk-lib/src/main/java/cash/z/ecc/android/sdk/SdkSynchronizer.kt
HonzaR Dec 11, 2024
e07d65d
Refactor inputs of `importAccountUfvk`
HonzaR Dec 11, 2024
7a064ec
Use `FirsClassByteArray` for `seed` parameter
HonzaR Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ and this library adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Synchronizer.walletBalances: StateFlow<Map<Account, AccountBalance>?>` that is replacement for the removed
`orchardBalances`, `saplingBalances`, and `transparentBalance`

### Changed
- `Synchronizer.orchardBalances`, `Synchronizer.saplingBalances`, and `Synchronizer.transparentBalance` have been
replaced by `Synchronizer.walletBalances` that provides these balances based on `Account`
### Changed
- `Account` data class works with `accountUuid: ByteArray` instead of the previous ZIP 32 account index
- These functions from `DerivationTool` have been refactored to work with the ZIP 32 account index instead of the
`Account` data class: `deriveUnifiedSpendingKey`, `deriveUnifiedAddress`, `deriveArbitraryAccountKey`

### Removed
- `Synchronizer.sendToAddress` and `Synchronizer.shieldFunds` have been removed, use
`Synchronizer.createProposedTransactions` and `Synchronizer.proposeShielding` instead
- `Synchronizer.orchardBalances`, `Synchronizer.saplingBalances`, and `Synchronizer.transparentBalance`
(use `Synchronizer.walletBalances` instead).

## [2.2.6] - 2024-11-16

Expand Down
38 changes: 16 additions & 22 deletions backend-lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions backend-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ rayon = "1.7"
# JNI
anyhow = "1"
jni = { version = "0.21", default-features = false }
uuid = "1"

# Logging
log-panics = "2.0.0"
Expand Down Expand Up @@ -69,3 +70,10 @@ xz2 = { version = "0.1", features = ["static"] }
name = "zcashwalletsdk"
path = "src/main/rust/lib.rs"
crate-type = ["staticlib", "cdylib"]

[patch.crates-io]
zcash_address = { git = "https://github.com/zcash/librustzcash", rev = "f1724c436a99208e612d8dec2119613fd280492d" }
zcash_client_backend = { git = "https://github.com/zcash/librustzcash", rev = "f1724c436a99208e612d8dec2119613fd280492d" }
zcash_client_sqlite = { git = "https://github.com/zcash/librustzcash", rev = "f1724c436a99208e612d8dec2119613fd280492d" }
zcash_primitives = { git = "https://github.com/zcash/librustzcash", rev = "f1724c436a99208e612d8dec2119613fd280492d" }
zcash_proofs = { git = "https://github.com/zcash/librustzcash", rev = "f1724c436a99208e612d8dec2119613fd280492d" }
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface Backend {
suspend fun initBlockMetaDb(): Int

suspend fun proposeTransfer(
accountIndex: Int,
accountUuid: ByteArray,
to: String,
value: Long,
memo: ByteArray? = null
Expand All @@ -35,12 +35,12 @@ interface Backend {
*/
@Throws(RuntimeException::class)
suspend fun proposeTransferFromUri(
accountIndex: Int,
accountUuid: ByteArray,
uri: String
): ProposalUnsafe

suspend fun proposeShielding(
accountIndex: Int,
accountUuid: ByteArray,
shieldingThreshold: Long,
memo: ByteArray? = null,
transparentReceiver: String? = null
Expand Down Expand Up @@ -85,11 +85,27 @@ interface Backend {
*/
@Throws(RuntimeException::class)
suspend fun createAccount(
accountName: String,
keySource: String?,
seed: ByteArray,
treeState: ByteArray,
recoverUntil: Long?
recoverUntil: Long?,
): JniUnifiedSpendingKey

/**
* @throws RuntimeException as a common indicator of the operation failure
*/
@Throws(RuntimeException::class)
@Suppress("LongParameterList")
suspend fun importAccountUfvk(
accountName: String,
keySource: String?,
ufvk: String,
treeState: ByteArray,
recoverUntil: Long?,
purpose: Int
): JniAccount

/**
* @throws RuntimeException as a common indicator of the operation failure
*/
Expand All @@ -109,13 +125,13 @@ interface Backend {
fun isValidTexAddr(addr: String): Boolean

@Throws(RuntimeException::class)
suspend fun getCurrentAddress(accountIndex: Int): String
suspend fun getCurrentAddress(accountUuid: ByteArray): String

fun getTransparentReceiver(ua: String): String?

fun getSaplingReceiver(ua: String): String?

suspend fun listTransparentReceivers(accountIndex: Int): List<String>
suspend fun listTransparentReceivers(accountUuid: ByteArray): List<String>

fun getBranchIdForHeight(height: Long): Long

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface Derivation {
seed: ByteArray,
networkId: Int,
accountIndex: Int
): JniUnifiedSpendingKey
): ByteArray

/**
* @return a unified full viewing key.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cash.z.ecc.android.sdk.internal.jni

import cash.z.ecc.android.sdk.internal.model.JniAccount

/**
* The number of bytes in the account UUID parameter. It's used e.g. in [JniAccount.accountUuid], or
* [JniUnifiedSpendingKey.accountUuid]
*/
const val JNI_ACCOUNT_UUID_BYTES_SIZE = 16

/**
* The number of bytes in the seed fingerprint parameter. It's used e.g. in [JniAccount.seedFingerprint]
*/
const val JNI_ACCOUNT_SEED_FP_BYTES_SIZE = 32
Loading
Loading