mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-11-05 11:56:37 +00:00
use improved dnssec validation and handle offline state when resolving bip 353 hrns
This commit is contained in:
parent
5f62523710
commit
4632850e1e
3 changed files with 32 additions and 3 deletions
2
drongo
2
drongo
|
|
@ -1 +1 @@
|
||||||
Subproject commit 58cc096f8e5a1274945a252907100c1dc051a996
|
Subproject commit 056d5f83a6296ad8f673066ea9dbc68972a183e9
|
||||||
|
|
@ -54,6 +54,7 @@ public class Config {
|
||||||
private boolean signBsmsExports = false;
|
private boolean signBsmsExports = false;
|
||||||
private boolean preventSleep = false;
|
private boolean preventSleep = false;
|
||||||
private Boolean connectToBroadcast;
|
private Boolean connectToBroadcast;
|
||||||
|
private Boolean connectToResolve;
|
||||||
private Boolean suggestSendToMany;
|
private Boolean suggestSendToMany;
|
||||||
private List<File> recentWalletFiles;
|
private List<File> recentWalletFiles;
|
||||||
private Integer keyDerivationPeriod;
|
private Integer keyDerivationPeriod;
|
||||||
|
|
@ -365,6 +366,15 @@ public class Config {
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getConnectToResolve() {
|
||||||
|
return connectToResolve;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConnectToResolve(Boolean connectToResolve) {
|
||||||
|
this.connectToResolve = connectToResolve;
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean getSuggestSendToMany() {
|
public Boolean getSuggestSendToMany() {
|
||||||
return suggestSendToMany;
|
return suggestSendToMany;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.sparrowwallet.sparrow.wallet;
|
package com.sparrowwallet.sparrow.wallet;
|
||||||
|
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import com.sparrowwallet.drongo.BitcoinUnit;
|
import com.sparrowwallet.drongo.BitcoinUnit;
|
||||||
import com.sparrowwallet.drongo.KeyPurpose;
|
import com.sparrowwallet.drongo.KeyPurpose;
|
||||||
|
|
@ -181,11 +182,29 @@ public class PaymentController extends WalletFormController implements Initializ
|
||||||
|
|
||||||
String dnsPaymentHrn = getDnsPaymentHrn(newValue);
|
String dnsPaymentHrn = getDnsPaymentHrn(newValue);
|
||||||
if(dnsPaymentHrn != null) {
|
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 dnsPaymentService = new DnsPaymentService(dnsPaymentHrn);
|
||||||
dnsPaymentService.setOnSucceeded(_ -> dnsPaymentService.getValue().ifPresent(dnsPayment -> setDnsPayment(dnsPayment)));
|
dnsPaymentService.setOnSucceeded(_ -> dnsPaymentService.getValue().ifPresent(dnsPayment -> setDnsPayment(dnsPayment)));
|
||||||
dnsPaymentService.setOnFailed(failEvent -> {
|
dnsPaymentService.setOnFailed(failEvent -> {
|
||||||
if(failEvent.getSource().getException() != null && !(failEvent.getSource().getException().getCause() instanceof TimeoutException)) {
|
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();
|
dnsPaymentService.start();
|
||||||
|
|
@ -393,7 +412,7 @@ public class PaymentController extends WalletFormController implements Initializ
|
||||||
address.setText(dnsPayment.hrn());
|
address.setText(dnsPayment.hrn());
|
||||||
revalidate(address, addressListener);
|
revalidate(address, addressListener);
|
||||||
address.leftProperty().set(getBitcoinCharacter());
|
address.leftProperty().set(getBitcoinCharacter());
|
||||||
if(label.getText().isEmpty()) {
|
if(label.getText().isEmpty() || label.getText().startsWith("To ₿")) {
|
||||||
label.setText("To " + dnsPayment);
|
label.setText("To " + dnsPayment);
|
||||||
}
|
}
|
||||||
label.requestFocus();
|
label.requestFocus();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue