diff --git a/drongo b/drongo index 58cc096f..056d5f83 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 58cc096f8e5a1274945a252907100c1dc051a996 +Subproject commit 056d5f83a6296ad8f673066ea9dbc68972a183e9 diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Config.java b/src/main/java/com/sparrowwallet/sparrow/io/Config.java index 61c77301..9d4f76ec 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Config.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Config.java @@ -54,6 +54,7 @@ public class Config { private boolean signBsmsExports = false; private boolean preventSleep = false; private Boolean connectToBroadcast; + private Boolean connectToResolve; private Boolean suggestSendToMany; private List recentWalletFiles; private Integer keyDerivationPeriod; @@ -365,6 +366,15 @@ public class Config { flush(); } + public Boolean getConnectToResolve() { + return connectToResolve; + } + + public void setConnectToResolve(Boolean connectToResolve) { + this.connectToResolve = connectToResolve; + flush(); + } + public Boolean getSuggestSendToMany() { return suggestSendToMany; } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java index 71f6868b..6e196c9b 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java @@ -1,5 +1,6 @@ package com.sparrowwallet.sparrow.wallet; +import com.google.common.base.Throwables; import com.google.common.eventbus.Subscribe; import com.sparrowwallet.drongo.BitcoinUnit; import com.sparrowwallet.drongo.KeyPurpose; @@ -181,11 +182,29 @@ public class PaymentController extends WalletFormController implements Initializ String dnsPaymentHrn = getDnsPaymentHrn(newValue); if(dnsPaymentHrn != null) { + if(Config.get().hasServer() && !AppServices.isConnected() && !AppServices.isConnecting()) { + if(Config.get().getConnectToResolve() == null) { + Platform.runLater(() -> { + ConfirmationAlert confirmationAlert = new ConfirmationAlert("Connect to resolve?", "Connect to the configured server to resolve the address?", ButtonType.NO, ButtonType.YES); + Optional optType = confirmationAlert.showAndWait(); + if(confirmationAlert.isDontAskAgain() && optType.isPresent()) { + Config.get().setConnectToResolve(optType.get() == ButtonType.YES); + } + if(optType.isPresent() && optType.get() == ButtonType.YES) { + EventManager.get().post(new RequestConnectEvent()); + } + }); + } else if(Config.get().getConnectToResolve()) { + Platform.runLater(() -> EventManager.get().post(new RequestConnectEvent())); + } + return; + } + DnsPaymentService dnsPaymentService = new DnsPaymentService(dnsPaymentHrn); dnsPaymentService.setOnSucceeded(_ -> dnsPaymentService.getValue().ifPresent(dnsPayment -> setDnsPayment(dnsPayment))); dnsPaymentService.setOnFailed(failEvent -> { if(failEvent.getSource().getException() != null && !(failEvent.getSource().getException().getCause() instanceof TimeoutException)) { - AppServices.showErrorDialog("Validation failed for " + dnsPaymentHrn, failEvent.getSource().getException().getMessage()); + AppServices.showErrorDialog("Validation failed for " + dnsPaymentHrn, Throwables.getRootCause(failEvent.getSource().getException()).getMessage()); } }); dnsPaymentService.start(); @@ -393,7 +412,7 @@ public class PaymentController extends WalletFormController implements Initializ address.setText(dnsPayment.hrn()); revalidate(address, addressListener); address.leftProperty().set(getBitcoinCharacter()); - if(label.getText().isEmpty()) { + if(label.getText().isEmpty() || label.getText().startsWith("To ₿")) { label.setText("To " + dnsPayment); } label.requestFocus();