Skip to content

Commit

Permalink
Add support for .crypto domain resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
sudoryan committed May 19, 2021
1 parent cf0c4cc commit a766898
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions wallet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ dependencies {
implementation "androidx.room:room-runtime:2.2.5"
annotationProcessor "androidx.room:room-compiler:2.2.5"
api 'com.dogecoin:libdohj-core:0.15-SNAPSHOT'
implementation('com.unstoppabledomains:resolution:1.13.3') {
exclude group: 'org.bouncycastle'
}
implementation 'com.lambdaworks:scrypt:1.4.0'
implementation 'com.google.protobuf:protobuf-java:3.7.1'
implementation 'com.google.guava:guava:29.0-android'
Expand Down
17 changes: 13 additions & 4 deletions wallet/src/de/schildbach/wallet/ui/send/SendCoinsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
import androidx.lifecycle.ViewModelProvider;
import com.google.common.base.Joiner;
import com.google.common.util.concurrent.ListenableFuture;
import com.unstoppabledomains.exceptions.ns.NamingServiceException;
import com.unstoppabledomains.resolution.DomainResolution;
import com.unstoppabledomains.resolution.Resolution;

import de.schildbach.wallet.Configuration;
import de.schildbach.wallet.Constants;
import de.schildbach.wallet.R;
Expand Down Expand Up @@ -587,16 +591,21 @@ public boolean onOptionsItemSelected(final MenuItem item) {

private void validateReceivingAddress() {
try {
final String addressStr = receivingAddressView.getText().toString().trim();
String addressStr = receivingAddressView.getText().toString().trim();
if (!addressStr.isEmpty()) {
String domain = "";
if (addressStr.endsWith(".crypto")) {
DomainResolution resolution = new Resolution();
domain = addressStr;
addressStr = resolution.getAddress(addressStr, "DOGE");
}
final Address address = Address.fromString(Constants.NETWORK_PARAMETERS, addressStr);
final String label = addressBookDao.resolveLabel(address.toString());
viewModel.validatedAddress = new AddressAndLabel(Constants.NETWORK_PARAMETERS, address.toString(),
label);
viewModel.validatedAddress = new AddressAndLabel(Constants.NETWORK_PARAMETERS, address.toString(), domain != "" ? domain : label);
receivingAddressView.setText(null);
log.info("Locked to valid address: {}", viewModel.validatedAddress);
}
} catch (final AddressFormatException x) {
} catch (final AddressFormatException | NamingServiceException x) {
// swallow
}
}
Expand Down

0 comments on commit a766898

Please sign in to comment.