Skip to content

Commit

Permalink
Fix importAccountUfvk account index parameter
Browse files Browse the repository at this point in the history
jlong->u32 AccountId conversion

and a few more not important changes to the Kotlin side

Co-authored-by: Jack Grigg <[email protected]>
  • Loading branch information
HonzaR and str4d authored Dec 18, 2024
2 parents d80876f + 8d5fcf6 commit 55b37b6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class RustBackend private constructor(
recoverUntil = recoverUntil ?: -1,
purpose = purpose,
seedFingerprint = seedFingerprint,
zip32AccountIndex = zip32AccountIndex,
zip32AccountIndex = zip32AccountIndex ?: -1,
)
}
}
Expand Down Expand Up @@ -434,16 +434,16 @@ class RustBackend private constructor(
): ByteArray =
withContext(SdkDispatchers.DATABASE_IO) {
createPcztFromProposal(
dataDbFile.absolutePath,
accountUuid,
proposal.toByteArray(),
dbDataPath = dataDbFile.absolutePath,
accountUuid = accountUuid,
proposal = proposal.toByteArray(),
networkId = networkId
)
}

override suspend fun addProofsToPczt(pczt: ByteArray): ByteArray =
addProofsToPczt(
pczt,
pczt = pczt,
spendParamsPath = saplingSpendFile.absolutePath,
outputParamsPath = saplingOutputFile.absolutePath
)
Expand All @@ -454,9 +454,9 @@ class RustBackend private constructor(
): ByteArray =
withContext(SdkDispatchers.DATABASE_IO) {
extractAndStoreTxFromPczt(
dataDbFile.absolutePath,
pcztWithProofs,
pcztWithSignatures,
dbDataPath = dataDbFile.absolutePath,
pcztWithProofs = pcztWithProofs,
pcztWithSignatures = pcztWithSignatures,
spendParamsPath = saplingSpendFile.absolutePath,
outputParamsPath = saplingOutputFile.absolutePath,
networkId = networkId
Expand Down Expand Up @@ -597,7 +597,7 @@ class RustBackend private constructor(
recoverUntil: Long,
purpose: Int,
seedFingerprint: ByteArray?,
zip32AccountIndex: Long?,
zip32AccountIndex: Long,
): JniAccount

@JvmStatic
Expand Down
7 changes: 5 additions & 2 deletions backend-lib/src/main/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ pub extern "C" fn Java_cash_z_ecc_android_sdk_internal_jni_RustBackend_importAcc
recover_until: jlong,
purpose: jint,
seed_fingerprint_bytes: JByteArray<'local>,
hd_account_index_raw: u32,
hd_account_index_raw: jlong,
) -> jobject {
let res = catch_unwind(&mut env, |env| {
let network = parse_network(network_id as u32)?;
Expand Down Expand Up @@ -564,7 +564,10 @@ pub extern "C" fn Java_cash_z_ecc_android_sdk_internal_jni_RustBackend_importAcc
} else {
None
};
let hd_account_index = zip32::AccountId::try_from(hd_account_index_raw).ok();

let hd_account_index = u32::try_from(hd_account_index_raw)
.ok()
.and_then(|hd_account_index_non_null| zip32::AccountId::try_from(hd_account_index_non_null).ok());

let derivation = seed_fingerprint
.zip(hd_account_index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ internal object TxOutputsViewDefinition {

const val COLUMN_INTEGER_OUTPUT_INDEX = "output_index" // $NON-NLS

const val COLUMN_INTEGER_FROM_ACCOUNT = "from_account_id" // $NON-NLS

const val COLUMN_STRING_TO_ADDRESS = "to_address" // $NON-NLS

const val COLUMN_BLOB_TO_ACCOUNT = "to_account_uuid" // $NON-NLS
Expand Down

0 comments on commit 55b37b6

Please sign in to comment.