-
Notifications
You must be signed in to change notification settings - Fork 179
feat(dashpay): use mock state repository #1181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e5dfe7f
cb462da
354e766
120466a
e65b964
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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!!) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -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) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as in Android DashPay Library, |
||
| } catch (e: MaxRetriesReachedException) { | ||
| null | ||
| } catch (e: NoAvailableAddressesForRetryException) { | ||
|
|
||
There was a problem hiding this comment.
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.