-
Notifications
You must be signed in to change notification settings - Fork 277
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
Add ENS and UD resolver #779
Open
paxriel
wants to merge
6
commits into
m2049r:master
Choose a base branch
from
paxriel:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6addda5
Add UD resolver
paxriel e722366
Removed check in BarcodeData.java for domain name format
paxriel 0b1fa4e
Parse OpenAlias before UD to reduce response time for OpenAlias addre…
paxriel 7c78d6b
Add UD license and add new domains to help.xml
paxriel 8f3d644
Closes PR #1
paxriel 1226468
Merge branch 'master' into master
paxriel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,13 @@ | |
package com.m2049r.xmrwallet.data; | ||
|
||
import android.net.Uri; | ||
import android.util.Patterns; | ||
|
||
import com.m2049r.xmrwallet.util.OpenAliasHelper; | ||
import com.unstoppabledomains.exceptions.ns.NamingServiceException; | ||
import com.unstoppabledomains.resolution.DomainResolution; | ||
import com.unstoppabledomains.resolution.Resolution; | ||
import com.unstoppabledomains.resolution.naming.service.NamingServiceType; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
@@ -175,13 +180,58 @@ static public BarcodeData fromString(String qrCode) { | |
// maybe it's naked? | ||
bcData = parseNaked(qrCode); | ||
} | ||
if (bcData == null) { | ||
// Check for UD domain | ||
bcData = parseUD(qrCode); | ||
} | ||
if (bcData == null) { | ||
// check for OpenAlias | ||
bcData = parseOpenAlias(qrCode, false); | ||
} | ||
return bcData; | ||
} | ||
|
||
static public BarcodeData parseUD(String udString) { | ||
Timber.d("parseUD=%s", udString); | ||
if (udString == null || !Patterns.DOMAIN_NAME.matcher(udString).matches()) return null; | ||
|
||
DomainResolution resolution = Resolution.builder() | ||
.providerUrl(NamingServiceType.ENS, "https://cloudflare-eth.com") | ||
.build(); | ||
|
||
final String[] address = {null}; | ||
final Crypto[] crypto = {null}; | ||
Thread udThread = new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
for (Crypto currentCrypto: Crypto.values()) { | ||
try { | ||
address[0] = resolution.getAddress(udString, currentCrypto.getSymbol().toLowerCase()); | ||
crypto[0] = currentCrypto; | ||
break; | ||
} catch (NamingServiceException e) { | ||
Timber.d(e.getLocalizedMessage()); | ||
} | ||
} | ||
} | ||
}); | ||
udThread.start(); | ||
try { | ||
udThread.join(); | ||
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. why start a thread and then block the UI thread waiting for it to finish anyway? |
||
} catch (InterruptedException e) { | ||
return null; | ||
} | ||
if (crypto[0] == null) { | ||
Timber.d("Unsupported UD address %s", udString); | ||
return null; | ||
} | ||
if (!crypto[0].validate(address[0])) { | ||
Timber.d("%s address invalid", crypto[0]); | ||
return null; | ||
} | ||
return new BarcodeData(crypto[0], address[0], udString, null, null, Security.NORMAL); | ||
} | ||
|
||
static public BarcodeData parseOpenAlias(String oaString, boolean dnssec) { | ||
Timber.d("parseOpenAlias=%s", oaString); | ||
if (oaString == null) return null; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The default
DOMAIN_NAME
pattern probably won't match some crypto TLDs.I can't double-check now, but looking at https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/util/Patterns.java#309 it looks like it won't match
888
andx
domains.Since you are already handling any errors that may be returned from the library. What do you think about removing this check altogether?
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.
That's a good point, I'll remove the domain check