diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java index 658777bc..6fd51965 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/FileImportPane.java @@ -162,8 +162,8 @@ public abstract class FileImportPane extends TitledDescriptionPane { setError("Import Error", e.getMessage()); } } else if(result.outputDescriptor != null) { - wallets = List.of(result.outputDescriptor.toKeystoreWallet(null)); try { + wallets = List.of(result.outputDescriptor.toWallet()); importFile(importer.getName(), null, null); } catch(ImportException e) { log.error("Error importing QR", e); @@ -193,6 +193,10 @@ public abstract class FileImportPane extends TitledDescriptionPane { } } + protected List getScannedWallets() { + return wallets; + } + protected Keystore getScannedKeystore(ScriptType scriptType) throws ImportException { if(wallets != null) { for(Wallet wallet : wallets) { diff --git a/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java b/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java index 8d030d5d..a4abf902 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/FileWalletImportPane.java @@ -18,7 +18,13 @@ public class FileWalletImportPane extends FileImportPane { @Override protected void importFile(String fileName, InputStream inputStream, String password) throws ImportException { - Wallet wallet = importer.importWallet(inputStream, password); + Wallet wallet; + if(getScannedWallets() != null && !getScannedWallets().isEmpty()) { + wallet = getScannedWallets().iterator().next(); + } else { + wallet = importer.importWallet(inputStream, password); + } + if(wallet.getName() == null) { wallet.setName(fileName); } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java index 320cc4ea..ec2b3d39 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java @@ -53,6 +53,7 @@ import java.util.*; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import java.util.stream.IntStream; @SuppressWarnings("deprecation") @@ -542,7 +543,12 @@ public class QRScanDialog extends Dialog { private KeyDerivation getKeyDerivation(CryptoKeypath cryptoKeypath) { if(cryptoKeypath != null) { - return new KeyDerivation(Utils.bytesToHex(cryptoKeypath.getSourceFingerprint()), cryptoKeypath.getPath()); + if(cryptoKeypath.getComponents().stream().anyMatch(PathComponent::isWildcard)) { + throw new IllegalArgumentException("Wildcard derivation paths are not supported"); + } + + List path = cryptoKeypath.getComponents().stream().map(comp -> new ChildNumber(comp.getIndex(), comp.isHardened())).collect(Collectors.toList()); + return new KeyDerivation(Utils.bytesToHex(cryptoKeypath.getSourceFingerprint()), KeyDerivation.writePath(path)); } return null; diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Descriptor.java b/src/main/java/com/sparrowwallet/sparrow/io/Descriptor.java index afd16d73..1bea7d5a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Descriptor.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Descriptor.java @@ -136,6 +136,6 @@ public class Descriptor implements WalletImport, WalletExport { @Override public boolean isWalletImportScannable() { - return false; + return true; } }