use improved dnssec validation and handle offline state when resolving bip 353 hrns

This commit is contained in:
Craig Raw 2025-07-29 12:52:10 +02:00
parent 5f62523710
commit 4632850e1e
3 changed files with 32 additions and 3 deletions

2
drongo

@ -1 +1 @@
Subproject commit 58cc096f8e5a1274945a252907100c1dc051a996
Subproject commit 056d5f83a6296ad8f673066ea9dbc68972a183e9

View file

@ -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<File> 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;
}

View file

@ -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<ButtonType> 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();