From b6c85d22c07631b53b5c4c4c933d13f85a00c67b Mon Sep 17 00:00:00 2001 From: Milan Date: Thu, 27 Feb 2025 10:19:36 +0100 Subject: [PATCH] Rust PCZT update (#1780) * Rust PCZT update * Code cleanup --- CHANGELOG.md | 1 + .../zcash/ui/common/datasource/ProposalDataSource.kt | 10 ++++++++++ .../ui/common/repository/KeystoneProposalRepository.kt | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88f70d420..911ab9603 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this application adheres to [Semantic Versioning](https://semver.org/spec/v2 - `Flexa` version has been bumped to 1.0.11 - Several non-FOSS dependencies has been removed for the new FOSS Zashi build type - Keystone flows swapped the buttons for the better UX, the main CTA is the closes button for a thumb. +- `Synchronizer.redactPcztForSigner` is now called in order to generate pczt bytes to display as QR for Keystone ## [1.3.3 (839)] - 2025-01-23 diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/datasource/ProposalDataSource.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/datasource/ProposalDataSource.kt index b4f27464f..963aef484 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/datasource/ProposalDataSource.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/datasource/ProposalDataSource.kt @@ -57,10 +57,14 @@ interface ProposalDataSource { proposal: Proposal, usk: UnifiedSpendingKey ): SubmitResult + + @Throws(PcztException.RedactPcztForSignerException::class) + suspend fun redactPcztForSigner(pczt: Pczt): Pczt } class TransactionProposalNotCreatedException(reason: Exception) : Exception(reason) +@Suppress("TooManyFunctions") class ProposalDataSourceImpl( private val synchronizerProvider: SynchronizerProvider, ) : ProposalDataSource { @@ -172,6 +176,12 @@ class ProposalDataSourceImpl( ) } + override suspend fun redactPcztForSigner(pczt: Pczt): Pczt = + withContext(Dispatchers.IO) { + synchronizerProvider.getSynchronizer() + .redactPcztForSigner(pczt) + } + private suspend inline fun submitTransactionInternal( crossinline block: suspend (Synchronizer) -> Flow ): SubmitResult = diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/repository/KeystoneProposalRepository.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/repository/KeystoneProposalRepository.kt index c1d895d6d..6fc1d8b6e 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/repository/KeystoneProposalRepository.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/repository/KeystoneProposalRepository.kt @@ -146,8 +146,9 @@ class KeystoneProposalRepositoryImpl( override suspend fun createPCZTEncoder(): UREncoder = withContext(Dispatchers.IO) { val pczt = proposalPczt ?: throw IllegalStateException("Proposal not created") + val redactedPczt = proposalDataSource.redactPcztForSigner(pczt.clonePczt()) keystoneZcashSDK.generatePczt( - pczt = pczt.clonePczt().toByteArray() + pczt = redactedPczt.toByteArray() ) }