|
@ -325,12 +325,22 @@ public class DevicePane extends TitledDescriptionPane { |
|
|
passphrase.bind(passphraseField.textProperty()); |
|
|
passphrase.bind(passphraseField.textProperty()); |
|
|
HBox.setHgrow(passphraseField, Priority.ALWAYS); |
|
|
HBox.setHgrow(passphraseField, Priority.ALWAYS); |
|
|
|
|
|
|
|
|
Button sendPassphraseButton = new Button("Send Passphrase"); |
|
|
SplitMenuButton sendPassphraseButton = new SplitMenuButton(); |
|
|
|
|
|
sendPassphraseButton.setText("Send Passphrase"); |
|
|
sendPassphraseButton.setOnAction(event -> { |
|
|
sendPassphraseButton.setOnAction(event -> { |
|
|
setExpanded(false); |
|
|
setExpanded(false); |
|
|
|
|
|
setDescription("Confirm passphrase on device..."); |
|
|
sendPassphrase(passphrase.get()); |
|
|
sendPassphrase(passphrase.get()); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
MenuItem removePassphrase = new MenuItem("Toggle Passphrase Off"); |
|
|
|
|
|
removePassphrase.setOnAction(event -> { |
|
|
|
|
|
setExpanded(false); |
|
|
|
|
|
setDescription("Toggling passphrase off, check device..."); |
|
|
|
|
|
togglePassphraseOff(); |
|
|
|
|
|
}); |
|
|
|
|
|
sendPassphraseButton.getItems().add(removePassphrase); |
|
|
|
|
|
|
|
|
HBox contentBox = new HBox(); |
|
|
HBox contentBox = new HBox(); |
|
|
contentBox.setAlignment(Pos.TOP_RIGHT); |
|
|
contentBox.setAlignment(Pos.TOP_RIGHT); |
|
|
contentBox.setSpacing(20); |
|
|
contentBox.setSpacing(20); |
|
@ -343,6 +353,35 @@ public class DevicePane extends TitledDescriptionPane { |
|
|
return contentBox; |
|
|
return contentBox; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Node getTogglePassphraseOn() { |
|
|
|
|
|
CopyableLabel label = new CopyableLabel("Passphrase is currently disabled"); |
|
|
|
|
|
HBox.setHgrow(label, Priority.ALWAYS); |
|
|
|
|
|
|
|
|
|
|
|
Button togglePassphraseOn = new Button("Toggle Passphrase On"); |
|
|
|
|
|
togglePassphraseOn.setOnAction(event -> { |
|
|
|
|
|
setExpanded(false); |
|
|
|
|
|
hideButtons(importButton, signButton, displayAddressButton, signMessageButton); |
|
|
|
|
|
setDescription("Toggling passphrase on, check device..."); |
|
|
|
|
|
togglePassphraseOn(); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
HBox contentBox = new HBox(); |
|
|
|
|
|
contentBox.setSpacing(20); |
|
|
|
|
|
contentBox.setAlignment(Pos.CENTER_LEFT); |
|
|
|
|
|
contentBox.getChildren().addAll(label, togglePassphraseOn); |
|
|
|
|
|
contentBox.setPadding(new Insets(10, 30, 10, 30)); |
|
|
|
|
|
|
|
|
|
|
|
return contentBox; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void hideButtons(Node... buttons) { |
|
|
|
|
|
for(Node button : buttons) { |
|
|
|
|
|
if(button != null) { |
|
|
|
|
|
button.setVisible(false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void promptPin() { |
|
|
private void promptPin() { |
|
|
Hwi.PromptPinService promptPinService = new Hwi.PromptPinService(device); |
|
|
Hwi.PromptPinService promptPinService = new Hwi.PromptPinService(device); |
|
|
promptPinService.setOnSucceeded(workerStateEvent -> { |
|
|
promptPinService.setOnSucceeded(workerStateEvent -> { |
|
@ -356,7 +395,7 @@ public class DevicePane extends TitledDescriptionPane { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
promptPinService.setOnFailed(workerStateEvent -> { |
|
|
promptPinService.setOnFailed(workerStateEvent -> { |
|
|
setError(promptPinService.getException().getMessage(), null); |
|
|
setError("Error", promptPinService.getException().getMessage()); |
|
|
unlockButton.setDisable(false); |
|
|
unlockButton.setDisable(false); |
|
|
}); |
|
|
}); |
|
|
promptPinService.start(); |
|
|
promptPinService.start(); |
|
@ -379,6 +418,7 @@ public class DevicePane extends TitledDescriptionPane { |
|
|
setExpanded(true); |
|
|
setExpanded(true); |
|
|
} else { |
|
|
} else { |
|
|
showOperationButton(); |
|
|
showOperationButton(); |
|
|
|
|
|
setContent(getTogglePassphraseOn()); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
setError("Incorrect PIN", null); |
|
|
setError("Incorrect PIN", null); |
|
@ -418,13 +458,43 @@ public class DevicePane extends TitledDescriptionPane { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
enumerateService.setOnFailed(workerStateEvent -> { |
|
|
enumerateService.setOnFailed(workerStateEvent -> { |
|
|
setError(enumerateService.getException().getMessage(), null); |
|
|
setError("Error", enumerateService.getException().getMessage()); |
|
|
setPassphraseButton.setDisable(false); |
|
|
setPassphraseButton.setDisable(false); |
|
|
setPassphraseButton.setVisible(true); |
|
|
setPassphraseButton.setVisible(true); |
|
|
}); |
|
|
}); |
|
|
enumerateService.start(); |
|
|
enumerateService.start(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void togglePassphraseOff() { |
|
|
|
|
|
Hwi.TogglePassphraseService togglePassphraseService = new Hwi.TogglePassphraseService(device); |
|
|
|
|
|
togglePassphraseService.setOnSucceeded(workerStateEvent -> { |
|
|
|
|
|
device.setNeedsPassphraseSent(false); |
|
|
|
|
|
setPassphraseButton.setVisible(false); |
|
|
|
|
|
setDescription("Unlocked"); |
|
|
|
|
|
showOperationButton(); |
|
|
|
|
|
}); |
|
|
|
|
|
togglePassphraseService.setOnFailed(workerStateEvent -> { |
|
|
|
|
|
setError("Error", togglePassphraseService.getException().getMessage()); |
|
|
|
|
|
}); |
|
|
|
|
|
togglePassphraseService.start(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void togglePassphraseOn() { |
|
|
|
|
|
Hwi.TogglePassphraseService togglePassphraseService = new Hwi.TogglePassphraseService(device); |
|
|
|
|
|
togglePassphraseService.setOnSucceeded(workerStateEvent -> { |
|
|
|
|
|
device.setNeedsPassphraseSent(true); |
|
|
|
|
|
setPassphraseButton.setVisible(true); |
|
|
|
|
|
setPassphraseButton.setDisable(true); |
|
|
|
|
|
setDescription("Enter passphrase"); |
|
|
|
|
|
setContent(getPassphraseEntry()); |
|
|
|
|
|
setExpanded(true); |
|
|
|
|
|
}); |
|
|
|
|
|
togglePassphraseService.setOnFailed(workerStateEvent -> { |
|
|
|
|
|
setError("Error", togglePassphraseService.getException().getMessage()); |
|
|
|
|
|
}); |
|
|
|
|
|
togglePassphraseService.start(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void importKeystore(List<ChildNumber> derivation) { |
|
|
private void importKeystore(List<ChildNumber> derivation) { |
|
|
if(device.getFingerprint() == null) { |
|
|
if(device.getFingerprint() == null) { |
|
|
Hwi.EnumerateService enumerateService = new Hwi.EnumerateService(passphrase.get()); |
|
|
Hwi.EnumerateService enumerateService = new Hwi.EnumerateService(passphrase.get()); |
|
@ -439,7 +509,7 @@ public class DevicePane extends TitledDescriptionPane { |
|
|
importXpub(derivation); |
|
|
importXpub(derivation); |
|
|
}); |
|
|
}); |
|
|
enumerateService.setOnFailed(workerStateEvent -> { |
|
|
enumerateService.setOnFailed(workerStateEvent -> { |
|
|
setError(enumerateService.getException().getMessage(), null); |
|
|
setError("Error", enumerateService.getException().getMessage()); |
|
|
importButton.setDisable(false); |
|
|
importButton.setDisable(false); |
|
|
}); |
|
|
}); |
|
|
enumerateService.start(); |
|
|
enumerateService.start(); |
|
|