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

Handling toUserId length error #451

Merged
merged 1 commit into from
Jun 30, 2020
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
11 changes: 8 additions & 3 deletions wallet/src/de/schildbach/wallet/ui/DashPayUserActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,17 @@ class DashPayUserActivity : InteractionAwareActivity() {
when (it.status) {
Status.LOADING -> Toast.makeText(context,
"Sending contact request...", Toast.LENGTH_SHORT).show()
Status.ERROR ->
Toast.makeText(context, "!!Error!!", Toast.LENGTH_SHORT).show()
Status.ERROR -> {
var msg = it.message
if (msg == null) {
msg = "!!Error!!"
}
Toast.makeText(context, msg, Toast.LENGTH_LONG).show()
}
Status.SUCCESS -> {
Toast.makeText(context,
"Contact request sent and verified on the network!",
Toast.LENGTH_SHORT).show()
Toast.LENGTH_LONG).show()
dashPayViewModel.getContactRequestLiveData.removeObserver(this)
}
}
Expand Down
5 changes: 5 additions & 0 deletions wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ class PlatformRepo(val walletApplication: WalletApplication) {
}

suspend fun sendContactRequest(toUserId: String, encryptionKey: KeyParameter): Resource<Nothing> {
//TODO: This can be removed after DashPay Contract is updated. For now it requires
//the toUserId field to have 44 characters, however, some userIds starting at 0 will have Base58[43]
if (toUserId.length != 44) {
return Resource.error("This user doesn't meet the requirements to receive a contact request")
}
return try {
val potentialContactIdentity = platform.identities.get(toUserId)
log.info("potential contact identity: $potentialContactIdentity")
Expand Down