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' 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) { 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..817eaf42ea 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) } @@ -682,7 +682,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..e00e09bb3b 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,7 @@ 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) - } else { - null - } + platform.stateRepository.fetchIdentityFromPubKeyHash(firstIdentityKey.pubKeyHash) } catch (e: MaxRetriesReachedException) { null } catch (e: NoAvailableAddressesForRetryException) {