mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
dont poll when signing
This commit is contained in:
parent
00db59c44f
commit
ddcabf721e
1 changed files with 5 additions and 1 deletions
|
@ -63,6 +63,7 @@ public class Hwi {
|
||||||
public boolean sendPin(Device device, String pin) throws ImportException {
|
public boolean sendPin(Device device, String pin) throws ImportException {
|
||||||
try {
|
try {
|
||||||
String output = execute(getDeviceCommand(device, Command.SEND_PIN, pin));
|
String output = execute(getDeviceCommand(device, Command.SEND_PIN, pin));
|
||||||
|
isPromptActive = false;
|
||||||
return wasSuccessful(output);
|
return wasSuccessful(output);
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
throw new ImportException(e);
|
throw new ImportException(e);
|
||||||
|
@ -78,6 +79,7 @@ public class Hwi {
|
||||||
output = execute(getDeviceCommand(device, Command.GET_XPUB, derivationPath));
|
output = execute(getDeviceCommand(device, Command.GET_XPUB, derivationPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isPromptActive = false;
|
||||||
JsonObject result = JsonParser.parseString(output).getAsJsonObject();
|
JsonObject result = JsonParser.parseString(output).getAsJsonObject();
|
||||||
if(result.get("xpub") != null) {
|
if(result.get("xpub") != null) {
|
||||||
return result.get("xpub").getAsString();
|
return result.get("xpub").getAsString();
|
||||||
|
@ -102,6 +104,7 @@ public class Hwi {
|
||||||
type = "--wpkh";
|
type = "--wpkh";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isPromptActive = false;
|
||||||
String output;
|
String output;
|
||||||
if(passphrase != null && !passphrase.isEmpty() && device.getModel().equals(WalletModel.TREZOR_1)) {
|
if(passphrase != null && !passphrase.isEmpty() && device.getModel().equals(WalletModel.TREZOR_1)) {
|
||||||
output = execute(getDeviceCommand(device, passphrase, Command.DISPLAY_ADDRESS, "--path", derivationPath, type));
|
output = execute(getDeviceCommand(device, passphrase, Command.DISPLAY_ADDRESS, "--path", derivationPath, type));
|
||||||
|
@ -124,12 +127,14 @@ public class Hwi {
|
||||||
try {
|
try {
|
||||||
String psbtBase64 = psbt.toBase64String();
|
String psbtBase64 = psbt.toBase64String();
|
||||||
|
|
||||||
|
isPromptActive = true;
|
||||||
String output;
|
String output;
|
||||||
if(passphrase != null && !passphrase.isEmpty() && device.getModel().equals(WalletModel.TREZOR_1)) {
|
if(passphrase != null && !passphrase.isEmpty() && device.getModel().equals(WalletModel.TREZOR_1)) {
|
||||||
output = execute(getDeviceCommand(device, passphrase, Command.SIGN_TX, psbtBase64));
|
output = execute(getDeviceCommand(device, passphrase, Command.SIGN_TX, psbtBase64));
|
||||||
} else {
|
} else {
|
||||||
output = execute(getDeviceCommand(device, Command.SIGN_TX, psbtBase64));
|
output = execute(getDeviceCommand(device, Command.SIGN_TX, psbtBase64));
|
||||||
}
|
}
|
||||||
|
isPromptActive = false;
|
||||||
|
|
||||||
JsonObject result = JsonParser.parseString(output).getAsJsonObject();
|
JsonObject result = JsonParser.parseString(output).getAsJsonObject();
|
||||||
if(result.get("psbt") != null) {
|
if(result.get("psbt") != null) {
|
||||||
|
@ -155,7 +160,6 @@ public class Hwi {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String execute(List<String> command) throws IOException {
|
private String execute(List<String> command) throws IOException {
|
||||||
isPromptActive = false;
|
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
return CharStreams.toString(new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8));
|
return CharStreams.toString(new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8));
|
||||||
|
|
Loading…
Reference in a new issue