Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions wallet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Comment on lines +53 to +54

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All data mocking is handled here. Any data created in DashPay won't be saved there. I didn't want to add more code to this PR requiring changes to DB tables, etc.

For now these changes will allow a username to be created or restored.

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'
Expand Down
1 change: 1 addition & 0 deletions wallet/src/de/schildbach/wallet/WalletApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions wallet/src/de/schildbach/wallet/service/CoinJoinService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,18 @@ 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
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
Expand Down Expand Up @@ -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)
Comment on lines +214 to +219

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are new 19.1-CJ-SNAPSHOT changes, but I haven't published it yet.

// TODO: _progressFlow.emit(progress)
log.info("Session {} complete. {}% mixed -- {}", sessionId, progress, message)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are some bugs leftover from merging Core 19 changes, masternode changes, etc -- but we didn't actually test this to see if it was working.

return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
Expand Down
16 changes: 7 additions & 9 deletions wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -216,6 +217,8 @@ class PlatformRepo private constructor(val walletApplication: WalletApplication)
dashPayProfileDao.loadAll().forEach {
platform.stateRepository.addValidIdentity(it.userIdentifier)
}

platform.stateRepository.storeIdentity(blockchainIdentity.identity!!)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where we could add other documents that we created, but at this point it doesn't seem necessary to modify DB tables to save those documents.

}
}

Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as in Android DashPay Library, platform.stateRepository. is the better way to make platform calls, so the "intercepter" will catch the calls.

} catch (e: MaxRetriesReachedException) {
null
} catch (e: NoAvailableAddressesForRetryException) {
Expand Down