mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
show warning dialog when a legacy multi output descriptor is entered
This commit is contained in:
parent
6ad81e1228
commit
ab2c77695b
2 changed files with 11 additions and 2 deletions
|
@ -66,13 +66,18 @@ public class Descriptor implements WalletImport, WalletExport {
|
|||
@Override
|
||||
public Wallet importWallet(InputStream inputStream, String password) throws ImportException {
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
inputStream.transferTo(baos);
|
||||
InputStream firstClone = new ByteArrayInputStream(baos.toByteArray());
|
||||
InputStream secondClone = new ByteArrayInputStream(baos.toByteArray());
|
||||
|
||||
try {
|
||||
return PdfUtils.getOutputDescriptor(inputStream).toWallet();
|
||||
return PdfUtils.getOutputDescriptor(firstClone).toWallet();
|
||||
} catch(Exception e) {
|
||||
//ignore
|
||||
}
|
||||
|
||||
String outputDescriptor = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
|
||||
String outputDescriptor = new BufferedReader(new InputStreamReader(secondClone, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
|
||||
OutputDescriptor descriptor = OutputDescriptor.getOutputDescriptor(outputDescriptor.trim());
|
||||
return descriptor.toWallet();
|
||||
} catch(Exception e) {
|
||||
|
|
|
@ -404,6 +404,10 @@ public class SettingsController extends WalletFormController implements Initiali
|
|||
(walletForm.getWallet().getPolicyType() == PolicyType.MULTI ? "\nKey expressions are shown in canonical order." : ""));
|
||||
Optional<String> text = dialog.showAndWait();
|
||||
if(text.isPresent() && !text.get().isEmpty() && !text.get().equals(outputDescriptorString)) {
|
||||
if(text.get().contains("(multi(")) {
|
||||
AppServices.showWarningDialog("Legacy multisig wallet detected", "Sparrow supports BIP67 compatible multisig wallets only.\n\nThe public keys will be lexicographically sorted, and the output descriptor represented with sortedmulti.");
|
||||
}
|
||||
|
||||
setDescriptorText(text.get().replace("\n", ""));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue