Skip to content
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

Restore Identity from First Public Key #513

Merged
merged 25 commits into from
Oct 6, 2020

Conversation

HashEngineering
Copy link
Collaborator

@HashEngineering HashEngineering commented Sep 24, 2020

Issue being fixed or feature implemented

NMA-590

Due to the changes made, the identity, username and contacts will be loaded at 30%, instead of the normal 90-100 percent which results in missing transactions and requires a blockchain rescan.

This resolves some causes of missing payments from contacts after restoring a wallet from a recovery phrase.

Related PR's and Dependencies

dashpay/android-dashpay#24

Screenshots / Videos

Screenshot_1600883380-smaller

How Has This Been Tested?

  • QA (Mobile Team)

Checklist:

  • I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

Comment on lines +24 to +35
fun Context.lifecycleOwner(): LifecycleOwner? {
var curContext = this
var maxDepth = 20
while (maxDepth-- > 0 && curContext !is LifecycleOwner) {
curContext = (curContext as ContextWrapper).baseContext
}
return if (curContext is LifecycleOwner) {
curContext as LifecycleOwner
} else {
null
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I needed a way to get the LifeCycleOwner of a View that is derived from a ConstraintLayout for an observer.

@@ -8,7 +8,7 @@
<string name="blockchain_state_progress_days">%1$s, %2$d days behind</string>
<string name="blockchain_state_progress_weeks">%1$s, %2$d weeks behind</string>
<string name="blockchain_state_progress_months">%1$s, %2$d months behind</string>
<string name="blockchain_state_progress_downloading">Synchronizing with network</string>
<string name="blockchain_state_progress_downloading">Synchronizing with network (%1$s%%)</string>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is used by the Notification for the foreground service.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To display the percent complete like this (5%)

@@ -31,6 +31,7 @@ import org.dashevo.dpp.identity.IdentityPublicKey
data class BlockchainIdentityData(var creationState: CreationState = CreationState.NONE,
var creationStateErrorMessage: String?,
var username: String?,
var userId: String?,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to store the userId because if we are restoring a recovery phrase, we won't have the credit funding transaction until later in the sync process.

@@ -66,7 +67,7 @@ class MoreFragment : Fragment(R.layout.activity_more) {
}

val blockchainIdentity = PlatformRepo.getInstance().getBlockchainIdentity()
if (blockchainIdentity != null) {
if (blockchainIdentity != null && blockchainIdentity.registrationStatus == BlockchainIdentity.RegistrationStatus.REGISTERED) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Prevents crash if no user is registered on the More Screen.

//and sent as a Resource.error
val creditFundingTx = wallet.getCreditFundingTransaction(wallet.getTransaction(blockchainIdentityData.creditFundingTxId))
val userId = creditFundingTx.creditBurnIdentityIdentifier.toStringBase58()
val userId = blockchainIdentity.uniqueIdString
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

since the userId is saved in the database, we don't need to load it from the wallet.

uniqueId = Sha256Hash.wrap(Base58.decode(blockchainIdentityData.userId))
}
} else {
return blockchainIdentity
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we return the blockchainIdentity because this is during the registration process and there is no other data to load.

log.info("update contacts not completed: blockchainIdentity has not been initialized")
}

val userId = blockchainIdentity.uniqueIdString!! //blockchainIdentityData!!.getIdentity(walletApplication.wallet) ?: return
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops. left a comment

Comment on lines +826 to +832
// If new keychains were added to the wallet, then update the bloom filters
if (addedContact) {
val intent = Intent(BlockchainService.ACTION_RESET_BLOOMFILTERS, null, walletApplication,
BlockchainServiceImpl::class.java)
walletApplication.startService(intent)
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was moved up in case there is an exception when processing profiles.

@HashEngineering HashEngineering merged commit a3d48e7 into evonet-develop Oct 6, 2020
@HashEngineering HashEngineering deleted the chain-sync-phase-3a branch November 30, 2020 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants