From e5dfe7f76dbb15a7d40f151ad5a3dd887df4471e Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Mon, 14 Aug 2023 16:37:55 -0700 Subject: [PATCH 1/5] chore: use 0.24-MOCK-SNAPSHOT versions for some platform libs --- wallet/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wallet/build.gradle b/wallet/build.gradle index 5c2f470022..775b4e2932 100644 --- a/wallet/build.gradle +++ b/wallet/build.gradle @@ -50,8 +50,8 @@ dependencies { implementation "androidx.biometric:biometric:1.1.0" implementation "org.dashj:dashj-core:$dashjVersion" - implementation 'org.dashj.platform:dashpay:0.24-SNAPSHOT' - implementation 'org.dashj.platform:platform-core:0.24-SNAPSHOT' + implementation 'org.dashj.platform:dashpay:0.24-MOCK-SNAPSHOT' + implementation 'org.dashj.platform:platform-core:0.24-MOCK-SNAPSHOT' implementation 'org.dashj.platform:dpp:0.24-SNAPSHOT' implementation 'org.dashj.platform:dapi-client:0.24-SNAPSHOT' implementation 'org.dashj:dashj-merk:0.22-SNAPSHOT' From cb462da4ef5e0c1382fad38a5de8933a5b2b6df3 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Mon, 14 Aug 2023 16:38:29 -0700 Subject: [PATCH 2/5] fix: set the wallet on the auth keychain group ext --- wallet/src/de/schildbach/wallet/WalletApplication.java | 1 + 1 file changed, 1 insertion(+) diff --git a/wallet/src/de/schildbach/wallet/WalletApplication.java b/wallet/src/de/schildbach/wallet/WalletApplication.java index 8fecf7f588..0de8f4b3b2 100644 --- a/wallet/src/de/schildbach/wallet/WalletApplication.java +++ b/wallet/src/de/schildbach/wallet/WalletApplication.java @@ -396,6 +396,7 @@ public void setWallet(Wallet newWallet) { authenticationGroupExtension.freshKey(AuthenticationKeyChain.KeyChainType.MASTERNODE_VOTING); authenticationGroupExtension.freshKey(AuthenticationKeyChain.KeyChainType.MASTERNODE_OPERATOR); authenticationGroupExtension.freshKey(AuthenticationKeyChain.KeyChainType.MASTERNODE_PLATFORM_OPERATOR); + authenticationGroupExtension.setWallet(wallet); } WalletEx walletEx = (WalletEx) wallet; if (walletEx.getCoinJoin() != null) { From 354e76636de0fd45f5f31936e8a2702c1aac38fd Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Mon, 14 Aug 2023 16:40:05 -0700 Subject: [PATCH 3/5] fix: update to latest CoinJoin DashJ lib --- .../wallet/service/CoinJoinService.kt | 8 +++++-- .../service/platform/PlatformSyncService.kt | 2 +- .../ui/dashpay/CreateIdentityService.kt | 7 +++--- .../wallet/ui/dashpay/PlatformRepo.kt | 24 ++++++++++++------- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/wallet/src/de/schildbach/wallet/service/CoinJoinService.kt b/wallet/src/de/schildbach/wallet/service/CoinJoinService.kt index 990bfe1701..92b330d085 100644 --- a/wallet/src/de/schildbach/wallet/service/CoinJoinService.kt +++ b/wallet/src/de/schildbach/wallet/service/CoinJoinService.kt @@ -33,6 +33,7 @@ import kotlinx.coroutines.sync.withLock import org.bitcoinj.coinjoin.CoinJoinClientManager import org.bitcoinj.coinjoin.CoinJoinClientOptions import org.bitcoinj.coinjoin.PoolMessage +import org.bitcoinj.coinjoin.PoolState import org.bitcoinj.coinjoin.PoolStatus import org.bitcoinj.coinjoin.callbacks.RequestDecryptedKey import org.bitcoinj.coinjoin.callbacks.RequestKeyParameter @@ -40,10 +41,10 @@ import org.bitcoinj.coinjoin.listeners.MixingCompleteListener import org.bitcoinj.coinjoin.listeners.SessionCompleteListener import org.bitcoinj.coinjoin.progress.MixingProgressTracker import org.bitcoinj.coinjoin.utils.CoinJoinManager -import org.bitcoinj.coinjoin.utils.ProTxToOutpoint import org.bitcoinj.core.AbstractBlockChain import org.bitcoinj.core.Coin import org.bitcoinj.core.Context +import org.bitcoinj.core.MasternodeAddress import org.bitcoinj.utils.Threading import org.bitcoinj.wallet.Wallet import org.bitcoinj.wallet.WalletEx @@ -210,9 +211,12 @@ class CoinJoinMixingService @Inject constructor( wallet: WalletEx?, sessionId: Int, denomination: Int, + state: PoolState?, message: PoolMessage?, + address: MasternodeAddress?, + joined: Boolean ) { - super.onSessionComplete(wallet, sessionId, denomination, message) + super.onSessionComplete(wallet, sessionId, denomination, state, message, address, joined) // TODO: _progressFlow.emit(progress) log.info("Session {} complete. {}% mixed -- {}", sessionId, progress, message) } diff --git a/wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt b/wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt index 1aa4d46d31..84bff23524 100644 --- a/wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt +++ b/wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt @@ -194,7 +194,7 @@ class PlatformSynchronizationService @Inject constructor( override suspend fun updateContactRequests() { // if there is no wallet or identity, then skip the remaining steps of the update - if (platformRepo.hasIdentity || walletApplication.wallet == null) { + if (!platformRepo.hasIdentity || walletApplication.wallet == null) { return } diff --git a/wallet/src/de/schildbach/wallet/ui/dashpay/CreateIdentityService.kt b/wallet/src/de/schildbach/wallet/ui/dashpay/CreateIdentityService.kt index beadc60f70..581e3b1385 100644 --- a/wallet/src/de/schildbach/wallet/ui/dashpay/CreateIdentityService.kt +++ b/wallet/src/de/schildbach/wallet/ui/dashpay/CreateIdentityService.kt @@ -317,7 +317,7 @@ class CreateIdentityService : LifecycleService() { if (blockchainIdentityData.creationState <= CreationState.UPGRADING_WALLET) { platformRepo.updateIdentityCreationState(blockchainIdentityData, CreationState.UPGRADING_WALLET) - val seed = platformRepo.getWalletSeed() ?: throw IllegalStateException("cannot obtain wallet seed") + val seed = wallet.keyChainSeed ?: throw IllegalStateException("cannot obtain wallet seed") platformRepo.addWalletAuthenticationKeysAsync(seed, encryptionKey) } @@ -472,7 +472,7 @@ class CreateIdentityService : LifecycleService() { if (blockchainIdentityData.creationState <= CreationState.UPGRADING_WALLET) { platformRepo.updateIdentityCreationState(blockchainIdentityData, CreationState.UPGRADING_WALLET) - val seed = platformRepo.getWalletSeed() ?: throw IllegalStateException("cannot obtain wallet seed") + val seed = wallet.keyChainSeed ?: throw IllegalStateException("cannot obtain wallet seed") platformRepo.addWalletAuthenticationKeysAsync(seed, encryptionKey) } @@ -656,6 +656,7 @@ class CreateIdentityService : LifecycleService() { blockchainIdentityData = BlockchainIdentityData(CreationState.NONE, null, null, null, true) val authExtension = walletApplication.wallet!!.getKeyChainExtension(AuthenticationGroupExtension.EXTENSION_ID) as AuthenticationGroupExtension + //authExtension.setWallet(walletApplication.wallet!!) // why is the wallet not set? we didn't deserialize it probably! val cftxs = authExtension.creditFundingTransactions val creditFundingTransaction: CreditFundingTransaction? = cftxs.find { it.creditBurnIdentityIdentifier.bytes!!.contentEquals(identity) } @@ -682,7 +683,7 @@ class CreateIdentityService : LifecycleService() { val wallet = walletApplication.wallet!! val encryptionKey = platformRepo.getWalletEncryptionKey() ?: throw IllegalStateException("cannot obtain wallet encryption key") - val seed = platformRepo.getWalletSeed() ?: throw IllegalStateException("cannot obtain wallet seed") + val seed = wallet.keyChainSeed ?: throw IllegalStateException("cannot obtain wallet seed") // create the Blockchain Identity object val blockchainIdentity = BlockchainIdentity(platformRepo.platform, 0, wallet, authExtension) diff --git a/wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt b/wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt index d56d9e8795..7b1a4d07d9 100644 --- a/wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt +++ b/wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt @@ -149,6 +149,7 @@ class PlatformRepo private constructor(val walletApplication: WalletApplication) } suspend fun init() { + authenticationGroupExtension = walletApplication.wallet?.getKeyChainExtension(AuthenticationGroupExtension.EXTENSION_ID) as AuthenticationGroupExtension blockchainIdentityDataDao.load()?.let { blockchainIdentity = initBlockchainIdentity(it, walletApplication.wallet!!) platformRepoInstance.initializeStateRepository() @@ -216,6 +217,8 @@ class PlatformRepo private constructor(val walletApplication: WalletApplication) dashPayProfileDao.loadAll().forEach { platform.stateRepository.addValidIdentity(it.userIdentifier) } + + platform.stateRepository.storeIdentity(blockchainIdentity.identity!!) } } @@ -576,10 +579,10 @@ class PlatformRepo private constructor(val walletApplication: WalletApplication) val wallet = walletApplication.wallet as WalletEx // this will initialize any missing key chains wallet.initializeCoinJoin(keyParameter) - val authenticationGroupExtension = AuthenticationGroupExtension(wallet) - authenticationGroupExtension.addEncryptedKeyChains(wallet.params, seed, keyParameter, keyChainTypes) - wallet.addOrGetExistingExtension(authenticationGroupExtension) + var authenticationGroupExtension = AuthenticationGroupExtension(wallet) + authenticationGroupExtension = wallet.addOrGetExistingExtension(authenticationGroupExtension) as AuthenticationGroupExtension + authenticationGroupExtension.addEncryptedKeyChains(wallet.params, seed, keyParameter, keyChainTypes) this@PlatformRepo.authenticationGroupExtension = authenticationGroupExtension } } @@ -1019,12 +1022,17 @@ class PlatformRepo private constructor(val walletApplication: WalletApplication) val firstIdentityKey = getBlockchainIdentityKey(0, encryptionKey) ?: return null return try { - val identityBytes = platform.client.getIdentityByFirstPublicKey(firstIdentityKey.pubKeyHash, true) - if (identityBytes != null && identityBytes.isNotEmpty()) { - platform.dpp.identity.createFromBuffer(identityBytes) + platform.stateRepository.fetchIdentityFromPubKeyHash(firstIdentityKey.pubKeyHash) + /*if (identity != null) { + identity } else { - null - } + val identityBytes = platform.client.getIdentityByFirstPublicKey(firstIdentityKey.pubKeyHash, true) + if (identityBytes != null && identityBytes.isNotEmpty()) { + platform.dpp.identity.createFromBuffer(identityBytes) + } else { + null + } + }*/ } catch (e: MaxRetriesReachedException) { null } catch (e: NoAvailableAddressesForRetryException) { From 120466a44d6fa0da2b7511f7ac48750eb87a0537 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Mon, 14 Aug 2023 16:43:10 -0700 Subject: [PATCH 4/5] fix: update to latest CoinJoin DashJ lib --- .../de/schildbach/wallet/ui/dashpay/PlatformRepo.kt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt b/wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt index 7b1a4d07d9..e00e09bb3b 100644 --- a/wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt +++ b/wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt @@ -1023,16 +1023,6 @@ class PlatformRepo private constructor(val walletApplication: WalletApplication) return try { platform.stateRepository.fetchIdentityFromPubKeyHash(firstIdentityKey.pubKeyHash) - /*if (identity != null) { - identity - } else { - val identityBytes = platform.client.getIdentityByFirstPublicKey(firstIdentityKey.pubKeyHash, true) - if (identityBytes != null && identityBytes.isNotEmpty()) { - platform.dpp.identity.createFromBuffer(identityBytes) - } else { - null - } - }*/ } catch (e: MaxRetriesReachedException) { null } catch (e: NoAvailableAddressesForRetryException) { From e65b96426b15764ea20386ebede9861c0931bc05 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Sun, 20 Aug 2023 21:07:11 -0700 Subject: [PATCH 5/5] chore: remove commented line --- .../src/de/schildbach/wallet/ui/dashpay/CreateIdentityService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/wallet/src/de/schildbach/wallet/ui/dashpay/CreateIdentityService.kt b/wallet/src/de/schildbach/wallet/ui/dashpay/CreateIdentityService.kt index 581e3b1385..817eaf42ea 100644 --- a/wallet/src/de/schildbach/wallet/ui/dashpay/CreateIdentityService.kt +++ b/wallet/src/de/schildbach/wallet/ui/dashpay/CreateIdentityService.kt @@ -656,7 +656,6 @@ class CreateIdentityService : LifecycleService() { blockchainIdentityData = BlockchainIdentityData(CreationState.NONE, null, null, null, true) val authExtension = walletApplication.wallet!!.getKeyChainExtension(AuthenticationGroupExtension.EXTENSION_ID) as AuthenticationGroupExtension - //authExtension.setWallet(walletApplication.wallet!!) // why is the wallet not set? we didn't deserialize it probably! val cftxs = authExtension.creditFundingTransactions val creditFundingTransaction: CreditFundingTransaction? = cftxs.find { it.creditBurnIdentityIdentifier.bytes!!.contentEquals(identity) }